[Gambas-user] Library and File

Christof Thalhofer chrisml at deganius.de
Thu Nov 15 23:06:08 CET 2018


Hello Benoît,

Am 15.11.18 um 02:00 schrieb Benoît Minisini:

> Sorry it's late for me too, so I didn't see what your problem was exactly.

Sorry, for me also, currently I have to do a lot of things in my firm.

What I meant was namespaces as known from Java, PHP, Perl, Python, C#
and other languages. Just an example:

In PHP I can use different libraries of other vendors and it does not
matter if classes in them have the same names as in my code.

In PHP I can use libs from different vendors even when classes in them
share the same names. I can write sth like

Use \vendor1\Mail as Vendor1Mail
Use \vendor2\Mail as Vendor2Mail

And then I can use the methods in these classes independently from each
other in the same procedure:

Vendor1Mail->SendMail($to, $from, $subject, $body)
Vendor2Mail->SendMail($subject, $body, $to, $from, $do_encryption)

Both classes of different libraries provided by different vendors
(vendor1 and vendor2) are called "Mail". They both have a method
"SendMail", which does different things, with a different method signature.

But I can use both in one procedure, and it does not disturb my code nor
does my code disturb code in these libs. Even if I have an own class
Mail with a method called "SendMail" I could call it in the same
procedure like so:

Mail->SendMail($my, $own, $another, $signature)

Because "Mail" is a class in the current namespace which is different
from "vendor1" or "vendor2".

My Class Mail would not been overwritten by the other classes called
"Mail" in other libraries nor would mine overwrite other classes.

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

Currently I cannot use Gambas libs from other people because there is a
high potential for naming collisions.

If Gambas had namespaces then:

I could give my library with my special sort of Mail.Sendmail to the
public and other people could use it as

Christofs.Mail.Sendmail

but it would not inherit or overwrite their own existing class Mail.

And so we all could share code very easily without any naming
collisions. This would lead to a "creative explosion" like it happened
in other languages earlier.


Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181115/9de9fa5f/attachment.sig>


More information about the User mailing list