[Gambas-user] Public and Private SUB in modules

Rolf-Werner Eilert eilert-sprachen at ...221...
Fri Dec 21 12:30:20 CET 2012



Am 21.12.2012 11:13, schrieb Tobias Boege:
> On Fri, 21 Dec 2012, Rolf-Werner Eilert wrote:
>>
>>
>> Am 20.12.2012 13:20, schrieb Beno?t Minisini:
>>> Le 20/12/2012 13:04, Rolf-Werner Eilert a ?crit :
>>>>
>>>> The event comes from another object, I understand that, so that's why.
>>>> Thank you!
>>>>
>>>> Rolf
>>>>
>>>
>>> To give you more details:
>>>
>>> In most languages, public / private / friend... are a mix of telling
>>> which symbols are exported at runtime and some syntactic sugar.
>>>
>>> In Gambas, I kept only the runtime definition, (which I could call the
>>> real effective one). "Public" means "accessible from another class", and
>>> "Private" means the contrary.
>>>
>>> And it's effective. If something is private, you won't see any symbol
>>> for it in the object file (unless debugging symbols are enabled).
>>>
>>> The only syntactic sugar is in the IDE : if a public symbol has an
>>> underscore in it, it will be usually hidden in automatic completion or
>>> debugging windows. But that's all. For the compiler and the interpreter,
>>> it is as public as any other public symbol.
>>>
>>> I did that for the sake of simplicity and clarity. Because people often
>>> don't understand the difference between what is syntactic sugar
>>> (implemented at the compiler level) and what is real (implemented at the
>>> interpreter level).
>>>
>>> Regards,
>>>
>>
>> Very interesting, yes that makes sense :-)
>>
>> On the other hand, I don't understand why the interpreter doesn't find
>>
>> Public Sub _myPrinter_Draw()
>>
>> anymore. Did I get that wrong?
>>
>> Regards
>>
>> Rolf
>
> Did you rename the actual object "myPrinter" to "_myPrinter", too? I assume
> that this must be done...
>
> Regards,
> Tobi
>

Aaaah yes - that was it:

Private myPrinter As Printer


in a SUB somewhat later:

myPrinter = New Printer As "_myPrinter"

myPrinter.Print()


BUT!

Public Sub _myPrinter_Begin()

This way it works here, but the SUBs are still visible when the 
completion list pops up in another module... Is that correct?

Regards

Rolf




More information about the User mailing list