[Gambas-user] Idea for 3.17

Christof Thalhofer chrisml at deganius.de
Sun May 9 12:34:06 CEST 2021


Am 09.05.21 um 04:17 schrieb Bruce:

> It's not "confusing" but as I said originally it's not that simple. All 
> your example addresses is the case of a local variable.  Consider all 
> the declarations in the Gambas language where the specific Orm would 
> need to be stated ...
> 
> ' Gambas class file
> Inherits <ns>Orm
> Event Whatever(AnOrm as <ns>Orm)
> Class <ns>Orm
> Public/Private MyOrm as <ns>Orm
> Public/Private LotsOfOrms as <ns>Orm[]
> Property ThisOrm as <ns>Orm
> Sub DoSomething(OrmThingy as <ns>Orm)
> Function WhichOrm() as <ns>Orm
> others?

Yes for eyery symbol which is owned by a class in a different namespace.
Only classes (Class, Module, Form, Testmodule ) can be in namespaces.

But if your class is in the same namespace as 'Orm' we could do things
like that:

------------------------------------------------------------
' Gambas class file

Namespace Brucesoftware.Db

' ":" followed by the name of a symbol means
' the current namespace.

Inherits :Orm
Event Whatever(AnOrm as :Orm)
Public MyOrm as :Orm
Private LotsOfOrms as :Orm[]
Property ThisOrm as :Orm
Sub DoSomething(OrmThingy as :Orm)
Function WhichOrm() as :Orm
------------------------------------------------------------

If your class is in another namespace as 'Orm' we could do things like that:

------------------------------------------------------------
' Gambas class file

' we are in Brucesoftware
Namespace Brucesoftware

' and need classes in another NS but don't always
' want to write it's lengthy name
Use Brucesoftware.Db as Db

Inherits Db:Orm
Event Whatever(AnOrm as Db:Orm)
Public MyOrm as Db:Orm

------------------------------------------------------------

This would lead to such code:

------------------------------------------------------------
' Gambas class file

Namespace Brucesoftware.Db
Use Brucesoftware.Crypt as Crypt

' The class Orm is in the same namespace, so we do not
' need to write it explicitly as ":" refers
' to the current one

Inherits :Orm

' "String" is not in this ns so we have to
' refer to the Default ns. But no namespace
' means the default one:

Property Something as String

Public Sub Main()

    Print Crypt:Hash.Random()

End

------------------------------------------------------------

We have to look how other languages handle this. We have the advantage
that there have been other people who have puzzled over this problem.

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/20210509/4deb3cf5/attachment.sig>


More information about the User mailing list