gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Import/Export everything from a module?


From: Hưng Hưng
Subject: Fwd: Import/Export everything from a module?
Date: Tue, 24 Mar 2020 21:35:15 +0700



---------- Forwarded message ---------
Từ: Hưng Hưng <address@hidden>
Date: Th 3, 24 thg 3, 2020 vào lúc 21:34
Subject: Re: Import/Export everything from a module?
To: Benjamin Kowarsch <address@hidden>


I know this style, from Oberon. I played a bit with Oberon but I found I want something more like a proper language and of course more powerful so I choose GM2.

If I just IMPORT EXAMPLE; the procedure inside EXAMPLE doesn't automatically available to me but I have to prepend EXAMPLE. before every procedure I want to use. It's very time consuming and imagine if our module has a very long name... it will be a nightmare.

Vào Th 3, 24 thg 3, 2020 vào lúc 21:29 Benjamin Kowarsch <address@hidden> đã viết:
You should not use unqualified imports.

FROM Foo IMPORT Bar, Baz, Bam; (* VERY BAD STYLE *)

Use qualified import instead.

IMPORT Foo; (* PROPER/CLEAN STYLE *)

This way you do not need to import identifiers one by one.

This also saves you the hassle of making up longer more specific names.

Instead of

FROM StringLib IMPORT stringsAreEqual;

IF stringsAreEqual(str1, str2) THEN ...

you do

IMPORT StringT;

IF StringT.equal(str1, str2) THEN ...


On Tue, 24 Mar 2020 at 22:27, Hưng Hưng <address@hidden> wrote:
I found it's too time consuming to write a long list of import, export. Is there any syntax to import everything from a module? e.g: FROM EXAMPLE IMPORT */ALL/EVERYTHING/... or IMPORT EXAMPLE.*? Python has a syntax like this: from example import *; which I think heavily influenced by M2.

I wonder the same thing for Export, too. Thanks.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]