scoped imports

Timothee Cour thelastmammoth at gmail.com
Sat Aug 17 16:56:06 PDT 2013


On Sat, Aug 17, 2013 at 3:36 PM, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:

> On Sat, Aug 17, 2013 at 03:29:56PM -0700, Timothee Cour wrote:
> [...]
> > Related question:
> >
> > Why isn't the following allowed:
> > ----
> > void fun(){
> > // code without version=A
> >   version=A;
> > // code with version=A
> >   vesion(none):
> > //code versioned out
> > }
> > ----
> > I understand the grammar doesn't allow it, but what's the rationale,
> > and can it be fixed?
>
> Not exactly sure what you're trying to achieve, but isn't this what you
> want:
>
>         void fun() {
>                 version(A) {
>                         ...
>                 } else {
>                         ..
>                 }
>         }
>
> ?
>
> Or are you trying to change version=A inside the function?
>

The latter:  having 'version=A '  inside the function.
Currently we can only set version=A at module scope, not function scope. I
don't understand the rationale for this limitation.
Likewise with 'version(A):' which is allowed at module scope but not
function scope, ; this would be  especially useful with 'version(none):'.


>
> T
>
> --
> "Outlook not so good." That magic 8-ball knows everything! I'll ask about
> Exchange Server next. -- (Stolen from the net)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130817/6c9bd888/attachment.html>


More information about the Digitalmars-d-learn mailing list