Page 1 of 1

Use of [noDefaultConstructor]

Posted: 6 Jan 2016 15:18
by Harrison Pratt
The Language Reference is not completely clear on use of noDefaultConstructor. It took me a while to sort out that it needs to follow the open statements. Perhaps the LR could be clarified on the next iteration of VIP.

Code: Select all

class graphParms : graphParms             [noDefaultConstructor]                 open core   % <== SYNTAX ERROR HERE     open vpiDomains   constructors       new : ( string GraphTypeID ).     new_fromFile : ( string QFN ).
This compiles without error:

Code: Select all

class graphParms : graphParms       open core     open vpiDomains               [noDefaultConstructor]  % <== Must follow 'open' statements   constructors       new : ( string GraphTypeID ).     new_fromFile : ( string QFN ).

Posted: 6 Jan 2016 16:11
by Thomas Linder Puls
To a (lazy) person that already know where to write such attributes and who also have to write the language reference; it seem sufficient to write:
The attributes of interfaces, classes and implementations are right after the scope qualifications.
Which is what that lazy person ;-) wrote in the language reference: Attributes: Insertion Points.

But in reality it clearly is not sufficient. Maybe you could assist with suggesting what (in some details) you think would have helped you. (E.g. a better formulation; another location to write about it; explicit examples).

Posted: 6 Jan 2016 19:14
by Harrison Pratt
Thomas,
Here's what led me astray:
http://wiki.visual-prolog.com/index.php ... onstructor

Example
class classWithoutPublicConstructors : myInterface
[noDefaultConstructor]
...
end class classWithoutPublicConstructors


In that example, the close spacing between the class declaration and [noDefaultContructor] led me to believe that [noDefaultConstructor] should immediately follow the declaration.

I did not think to search for Insertion Points ... actually, I had never read that until now! (oops!)

Perhaps modifying the example to read somewhat like the following would help:

Example
class classWithoutPublicConstructors : myInterface
open core
[noDefaultConstructor]
...
end class classWithoutPublicConstructors

Posted: 7 Jan 2016 22:32
by Thomas Linder Puls
Yes, good idea. I have done that.

Posted: 8 Jan 2016 4:30
by Harrison Pratt
You are too hard on the people who compiled the excellent on-line reference material -- it is hard for experts to anticipate all the possible misinterpretations made by amateurs! :lol: