Wiki improvements

Forum for discussion about the documentation project.
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 14:22

MrSwiss wrote:There is another (small, typo) somewhere in floating text, where you write "types" but clearly refer to: instance(s) of the type.

I tried to do a little housekeeping among all these "types (s)".
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 14:38

MrSwiss wrote:Question: why use 'Dim As' (in type) as opposed to: 'As' (without Dim)?

This is one of my old manias.
I like to explicit the declarations, even for the type data fields:
Dim As ...
similarly to:
Static As ...
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 15:24

I corrected an error in the explanation on 'Singleton':
Only the copy constructor may have no implementation.
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 15:55

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.)

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.

I added such a sentence in the article (in paragraph 6).
MrSwiss
Posts: 2672
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Postby MrSwiss » Jun 12, 2018 20:12

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.
This isn't what I mean by Implementation: "do I have to write out such 'empty body' thingy?
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.
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 20:28

I do not understand the meaning of your code.
What is the "overloaded" expression, a parameter declaration?
MrSwiss
Posts: 2672
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Postby MrSwiss » Jun 12, 2018 20:35

fxm wrote:What is the "overloaded" expression, a parameter declaration?
Just a 'proxy' or 'dummy' for any variables etc.

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:)
Therefore we *must* (do we?) Declare/Implement (our own, freshly aka: again)
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 20:46

In your code, change "Private" to "Protected", otherwise one cannot access this constructor from a derived type.
MrSwiss
Posts: 2672
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Postby MrSwiss » Jun 12, 2018 21:04

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. ?
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 21:07

Yes and yes.
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 21:08

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
MrSwiss
Posts: 2672
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Postby MrSwiss » Jun 12, 2018 21:18

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.
dodicat
Posts: 5009
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Wiki improvements

Postby dodicat » Jun 12, 2018 21:40

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

 
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 21:42

KeyPgVisPrivate → fxm [Highlight that private members are not accessible from inside derived types]
fxm
Posts: 8160
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » Jun 12, 2018 21:58

@dodicat,

For me a bug.
'Redim' with sizing does not seem to check the right of access to the constructor.

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest