[Gambas-user] Idea for 3.17
chrisml at deganius.de
Sun May 9 00:13:32 CEST 2021
Am 08.05.21 um 23:11 schrieb Bruce:
> Yes, for source code you would be writing just now, it would work.
> But imagine 230 projects, libraries and components written over the last
> 10 years all of which uae my (un-prefixed) Orm class and use gb.db as
> well. Imagine then that Benoit changes gb.db in Gambas 3.16+ and creates
> a Orm class therein. As I see it all my source code and p-code would
> then be broken or at least have a high probability of being broken.
If you have a class called 'Orm', yes in this case your code will break.
Because Benoît always writes in the 'Default' namespace, as you do also,
as everyone does until now. If he creates an 'Orm' class, and you had a
class called 'Orm', your code will break. This is the current situation.
This is the reason, why I called my Orm class 'DegOrm' and I prefix all
my classnames with 'Deg' as a very primitive namespace replacement. I
hope nobody gets the idea to call a class 'DegCrypt', 'DegString',
If you continue to use the namespace 'Default' (which must be the
default also in future, if not defined otherwise by the author of a
program) nothing changes for your code. You won't be sure that your code
would not been broken by future Gambas that introduces a class with the
same name as yours – so nothing changes for you.
In PHP there is the 'namespace' Keyword with which the author explicitly
defines the namespace of a class, look at this example:
If we can adopt this idea in Gambas then we can put classes into
different namespaces. If no namespace is defined for a class, the class
will be in 'Default' as before.
If we introduce namespaces you would have the possibility to let your
own code use it's own namespace. Then no change in the 'Default'
namespace could break your code any more.
So the introduction of namespaces won't break your old code. Never! But
it gives you the opportunity to put your code in your own namespace and
so make it more stable in future.
Dies ist keine Signatur
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: OpenPGP digital signature
More information about the User