Import proposals (Ideas)

Anders Runesson anders at runesson.info
Wed Jul 12 12:08:44 PDT 2006


ons 2006-07-12 klockan 10:25 -0700 skrev BCS:
> jcc7 wrote:
> > 
> > 
> > I'm just not a big fan of using with for this since it seems like importing to
> > me.
> > 
> > "with(module fooTooLong)" would be somewhat better, but I think "import" should
> > be there. How about this?
> > 
> > # import select fooTooLong
> > # {
> > #    alias reallyTooLong tooShort;    /* alias */
> > #    alias reallyTooLong2 tooShort2;  /* alias 2 */
> > #    alias notReallyTooLongAtAll notReallyTooLongAtAll; /* No alias */

Seems redundant to have to type "notReallyTooLongAtAll" twice though.
Just declaring which symbols you are interested in should be enough,
with the option of declaring aliases at the same time for convenience.

Also, I don't see the point of adding a keyword like "select" in all of
it. I think it is pretty clear whats going on if import is followed by a
block as opposed to just a module path and name:
import mypackage.mymodule;
where the whole module is imported.

> > # }
> > 
> > or if you just want to import one it'd be something like this:
> > 
> > import select std.string.replace alias replace;
> > 
> > or maybe even this if it's not being renamed...
> > 
> > import select std.string.replace;
> > 
> > I think there's a really good syntax in here somewhere. I'm just not sure what
> > it is yet...
> > 
> > jcc7
> 
> Yeah, that "with" doesn't look to good. OTOH that "select" looks kind of 
> funny also. I think just switching to the "alias <name> [<name>];" 
> syntax would be best. IIRC all {} block use ";" as a separator, so it 
> would be more consistent than a comma separated list.

Well, enums use commas. I think an import block somehow seems more
related to an enum than, say, a struct. It is just a declaration of
names/symbols, not types.

/Anders




More information about the Digitalmars-d mailing list