I tried to do a little housekeeping among all these "types (s)".MrSwiss wrote:There is another (small, typo) somewhere in floating text, where you write "types" but clearly refer to: instance(s) of the type.
Wiki improvements
Re: Wiki improvements
Re: Wiki improvements
This is one of my old manias.MrSwiss wrote:Question: why use 'Dim As' (in type) as opposed to: 'As' (without Dim)?
I like to explicit the declarations, even for the type data fields:
Dim As ...
similarly to:
Static As ...
Re: Wiki improvements
I corrected an error in the explanation on 'Singleton':
Only the copy constructor may have no implementation.
Only the copy constructor may have no implementation.
Re: Wiki improvements
Because for me, the answer is obvious and more general:MrSwiss wrote:While (in some cases) the need to Declare, is clearly explained, there isn't anything related to Implementation (do I have to, or not?).
(this is especially true, when it concerns EMPTY (without body) constructors/operators, since all others 'have to be written' anyhow.)
A procedure (declared for any reason) may have no implementation (no body defining) if it is never actually called in the program.
I added such a sentence in the article (in paragraph 6).
Re: Wiki improvements
This isn't what I mean by Implementation: "do I have to write out such 'empty body' thingy?fxm wrote:Because for me, the answer is obvious and more general:
A procedure (declared for any reason) may have no implementation (no body defining) if it is never actually called in the program.
That's the real question.
To me, its only clear on procedures, not necessarily on constructors, e.g.:
Code: Select all
Type something extends Object ' there will be a derived type
Private:
Declare Constructor() ' derived types use, only (in order to replace default, implict Constructor)
Public:
Declare Constructor(overloaded) ' default for user (destroys default, implict Constructor)
...
End Type
Constructor something()
End Constuctor ' doesn't make much sense, to me ...
'
Constructor something(overloaded) ' must be implemented
' instead of action code
End Constructor
Last edited by MrSwiss on Jun 12, 2018 20:32, edited 1 time in total.
Re: Wiki improvements
I do not understand the meaning of your code.
What is the "overloaded" expression, a parameter declaration?
What is the "overloaded" expression, a parameter declaration?
Re: Wiki improvements
Just a 'proxy' or 'dummy' for any variables etc.fxm wrote:What is the "overloaded" expression, a parameter declaration?
What I gathered from your article:
- 1) if a overloaded Constructor exists, then implicit, default Constructor is destroyed!
2) since a derived type always calls: Base() Constructor first, we have to have one (but not user callable, thus Private:)
Re: Wiki improvements
In your code, change "Private" to "Protected", otherwise one cannot access this constructor from a derived type.
Re: Wiki improvements
Should have known that, because I've checked the manual on those, yesterday.
However, apart from mentioning "inheritance" on Protected, there isn't much on:
details on them, or a direct comparison (except as stated above).
What you are saying is: Private: Type.Member isn't "inheritable", yes?
Does that cover any Member? Variables/Procedures/Operators etc. ?
However, apart from mentioning "inheritance" on Protected, there isn't much on:
details on them, or a direct comparison (except as stated above).
What you are saying is: Private: Type.Member isn't "inheritable", yes?
Does that cover any Member? Variables/Procedures/Operators etc. ?
Re: Wiki improvements
Yes and yes.
Re: Wiki improvements
Code: Select all
Type UDT
Dim As Integer I
End Type
Dim As UDT u '' this code calls the default constructor,
' '' the implicit default constructor built by the compiler in this case
Code: Select all
Type UDT
Dim As Integer I
Declare Constructor (Byval I0 As Integer)
End Type
Dim As UDT u '' this code calls the default constructor,
' '' but as an explicit constructor exists,
' '' there is no longer an implicit default consructor built by the compiler,
' '' so no default constructor at all,
' '' that induces a compile error
Re: Wiki improvements
Well, that truely clears yet another one, of those mysteries ... thanks.
A Note on doc, related to Private: should imho state:
Everything with "private" access, cannot be inherited, as opposed to "protected" access rights.
A Note on doc, related to Private: should imho state:
Everything with "private" access, cannot be inherited, as opposed to "protected" access rights.
Re: Wiki improvements
A quick quirk with private constructors.
Code: Select all
Type UDT
Dim As Integer I=23
private:
Declare Constructor ()
End Type
constructor UDT ()
print "Hi"
end constructor
redim as udt temp(0)
dim as udt u=temp(0)
print u.i
'Dim As UDT u2 ''' NO
sleep
Re: Wiki improvements
KeyPgVisPrivate → fxm [Highlight that private members are not accessible from inside derived types]
Re: Wiki improvements
@dodicat,
For me a bug.
'Redim' with sizing does not seem to check the right of access to the constructor.
For me a bug.
'Redim' with sizing does not seem to check the right of access to the constructor.