Thoughts about modules

Derek Parnell derek at nomail.afraid.org
Thu Jun 29 22:28:00 PDT 2006


On Thu, 29 Jun 2006 21:09:42 -0700, Kirk McDonald wrote:

> from util.str import SetEnv, GetEnv, Expand, ExpandEnvVar, ends, begins, 
> enquote, ustrip, ustripr, IsLike, YesNo, TranslateEscapes;

Unfortunately this is not completely adequate because one can't always
import the existing name verbatim, sometimes you need an alias to
disambiguate it. Maybe something more like ...

import from util.str SetEnv, GetEnv, Expand, ExpandEnvVar, ends, begins, 
     enquote, strip as ustrip, stripr as ustripr, IsLike, YesNo,
     TranslateEscapes;

The "from" key would tell D that only the listed names are to come into the
namespace and all others are excluded, such that any attempt to reference
them in the code would cause an error. The current semantics could still
exists by not using the "from" keyword.

And notice the "strip as ustrip". This is because the real name is
util.str.strip but this clashes with std.string.strip so we have to create
an alias for one of them.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
30/06/2006 3:19:07 PM



More information about the Digitalmars-d mailing list