[Gambas-user] Idea for 3.17

Christof Thalhofer chrisml at deganius.de
Thu May 6 10:34:01 CEST 2021


Am 06.05.21 um 09:27 schrieb Bruce:

> On 6/5/21 4:08 pm, Christof Thalhofer wrote:
>> As long as there is no namespace definition before the symbol name
>> everything is as before.
>>
>> Think as there is a global namespace in which everything happens –
>> currently. This one should not be disturbed.
> 
> This is the problem! The Gambas system does not understand the concept 
> "before".  For example and why I have an interest in this thread, some 
> time ago I wanted to create a library that contained a "Color" class. 
> This proved to be impossible as the gb.gui component already has a 
> static "Color" class. I specifically wanted a non-static class. 
> Notwithstanding that, every reference to "Color" before adding my now 
> hypothetical library refers to the gb.gui Color class. After I add my 
> library what do the un-namespaced references refer to? The compiler DOES 
> NOT KNOW that I have added a new library! It has no understanding of 
> what the project was like "before"!

I am not sure if I understand exactly, what you mean. And I also think
that I may not always express myself correctly due to the language barrier.

Gambas currently has in fact one single namespace. This one where all
the symbols reside. Therefor if you load a library which has the class
'Color' in it, it will overwrite the already existing class 'Color'.*

We can call this now already existing namespace "Global".

And this is the point where the concept of namespaces addresses your
problem (and a lot of others). If we could have additional namespaces
then you could define that symbols in your library reside in a namespace
that you created and they will never collide with other symbols in other
namespaces even when they have the same name.

Then you can create your own 'Color' class in the namespace
'Brucesoftware.com'.

And I can load a library you have written into my program and refer to
this class by the name 'Brucesoftware.com:Color'.

'Dim MyColor as new Brucesoftware.com:Color'

If the Gambas interpreter would be able to distinguish between the
different namespaces and we get used to write libraries with own
namespaces we can easily exchange code and I can use code you wrote and
you can use code I wrote, even if we use the same names for our symbols.

Ok?

I have written an ORM and I'd like to give it to the public later. I
called it 'DegOrm' and since then I pray every night before going to bed
that noone in the Gambas universe ever comes to the idea to call another
Class also 'DegOrm' – maybe in a component. Because if that happens and
I would need that component in my software I had do rename every
occurrence of 'DegOrm' in my software to make it work again.

That the Gambas interpreter currently has no understanding of namespaces
hinders us all to exchange our code.

Alles Gute

Christof Thalhofer

*The interpreter does not allow you to overwrite the symbols with
different signatures.

-- 
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/20210506/57c65eff/attachment.sig>


More information about the User mailing list