[Gambas-user] Sharing libraries across projects : new proposal!
Christof Thalhofer
chrisml at ...3340...
Sun Jan 31 11:14:35 CET 2016
Am 31.01.2016 um 04:55 schrieb Benoît Minisini:
> You can already do that, except that vendor name should be included in
> the library name.
Ok. I can throw them all in one directory. But the library name
unfortunately does not act like a namespace, it does not separate the
Classnames. If you have two libraries which contain classes with
identical names, then BANG.
> I'm against using namespaces in Gambas, because I think it's mainly a
> workaround of the inhability to find good class names. :-)
I disagree. :-)
That is right with a handful applications/libs in mind (aka "inhouse").
Not everybody has the whole world in mind when programming it's good idea.
There are always common tasks inside a library for whom it is difficult
to find unique (and understandable) names, like "Template", "Cache" and
so on. So I usually name these classes "DegTemplate", "DegCache" and so
on. But that is also a workaround and even dangerous when giving the
library free to others.
To give away your good idea as library you actually would have to:
1: Take a vendor name in the libs name.
2: Name every class inside the lib with a vendor prefix and hope, that
it is not used elsewhere.
What stands against the ability to do:
/usr/lib/gambas3/lib/vendor1/this.gambas
and
/usr/lib/gambas3/lib/vendor2/this.gambas
/usr/lib/gambas3/lib/vendor2/that.gambas
?
You could separate them inside code like so:
Dim CacheV1 as vendor1.this.Cache
Dim CacheV2 as vendor2.this.Cache
Here there is no danger anymore. Everybody can freely exchange libs with
others.
In PHP the usage, quality and exchange of libraries literally exploded
with namespaces:
https://packagist.org/statistics
Ok. I do not know how difficult it is to realize such a thing in the
interpreter. And I like Gambas very much. Even without namespaces.
Alles Gute
Christof Thalhofer
--
Dies ist keine Signatur
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20160131/76a6b8d3/attachment.sig>
More information about the User
mailing list