[Gambas-user] Proposal for namespace support

Christof Thalhofer chrisml at deganius.de
Wed May 12 10:31:19 CEST 2021


Am 12.05.21 um 02:14 schrieb Benoît Minisini:

>> If we could do as a shortcut:
>>
>> ' Class MyClass
>> Export As NameSpace:
>>
>> and this were extended to 'NameSpace:MyClass', that would be fine. Here
>> I think about typos where one would name the class file 'MyClass', then
>> writes 'Export As NameSpace:MzCass'.
> 
> I don't really like the syntax, but I get the point.

Ack. As an alternative we could do

'Export To NameSpace'

and

'Export To Namespace:MyAlternativeClassName'

But think about it ... do we really have the need to rename the class
when we export it with a Namespace? I would deny this and I would also
think that could lead to confusion in the same way as aliases on
import/usage.

So why not reduce the possibilities to this:

'Export'

= exporting the class to the default namespace of the project, or – if
that is not set – the 'default default' namespace Null.

And:

'Export To NameSpace'

= exporting the class to 'NameSpace'.

> Not a good idea to export all classes of a project.

Sorry, my fault. I thought of automatically export all *exported
classes* with NameSpace if 'namespace=NameSpace' is set in the
'.project' file but didn't write it.

> But we can imagine that 'Export' alone will export to the default 
> namespace of the project, and that the "default default" namespace is 
> the global symbol table.

Yes, that was what I meant.

>> With static classes this happens analogously? So that we can write:
>>
>> 'NameSpace:MyModule.MyMethod()'
> 
> I didn't think about class names used for calling static methods.
> 
> Yes, logically we should be able to do that. It's just problematic for 
> the compiler parser... must think about that.

Hmm. I thought of modules also being classes as you often use the term
as a synonym. I have no idea of the internals and therefor I am not able
to imagine why it is complicated.

>> 'use MyReallyVeryLongNamespace as MyLong;'
> 
> This is a common feature I don't really want. Because then you can 
> mismatch the reader of the code, which cannot be sure which namespace we 
> refer at first sight.

Ok, I agree, this is something I also find confusing with PHP. So let's
forget that idea.

Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210512/8183cba0/attachment.sig>


More information about the User mailing list