Import proposals (Ideas)

Oskar Linde oskar.lindeREM at OVEgmail.com
Mon Jul 10 11:17:21 PDT 2006


2 comments:

Dave skrev:
> Regan Heath wrote:
>> Sub-thread for ideas.
> 
> My preference for syntax and semantics would be:
> 
> // regular import w/ optional alias (*)
> import std.stdio, std.c.stdlib as stdlib, std.date;
> 
> // symbol specific lookup w/ optional alias (**)
> import from std.stdio writef, writefln as print, readf;

How would the parser disambiguate the import of the module readf from 
the symbol readf in std.stdio?

> // combined
> import std.stdio, from std.thread wait as wait, pause, std.date as date;
> 
> * Importing an entire module as an alias would then require a FQN to 
> access any of the members, for example given the above:
> malloc(...); // error
> std.c.stdlib.malloc(...); // error
> stdlib.malloc(...); // Ok
> 
> ** A specific symbol that was not aliased would require a FQN to access. 
> For example from above:
> std.stdio.writef(...);

Just to clarify, does this mean that to import std.c.stdlib as FQN only, 
you would have to do:

import std.c.stdlib as std.c.stdlib; //(1)

Or, indirectly:

import from std.c.stdlib a_symbol_I_will_never_use;

?

1) When you import something as fqn-only, you must be ok with typing out 
the full name quite a lot, so once more will not make much of a 
difference I guess...

/Oskar



More information about the Digitalmars-d mailing list