Why import statements are not allowed in function bodies (or any block of code)?

Leandro Lucarella llucax at gmail.com
Mon Jan 28 06:02:48 PST 2008


Bill Baxter, el 28 de enero a las 12:16 me escribiste:
> Leandro Lucarella wrote:
> >Is there any good reason for not allowing import statements in function
> >bodies or any code block? I think it would be really useful for avoid
> >namespace polution, specially in unittests (it's really ugly to import
> >things a module will never use except for unittesting).
> 
> Did someone already suggest using the version(UnitTest) workaround?

Yes, but I was looking for a design desition for making me use a
workarround :)

> I do remember hearing some reason before, like it makes it easier for tools to scrape out all the imports from a file.  But seems like a lame excuse to me now 
> that DMD can spit out a list of imports itself.  I would guess it's just a matter of not having a pressing enough need for it.  But it would be nice.

Ok.

/me pressing

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Hey you, with you ear against the wall
Waiting for someone to call out
Would you touch me?



More information about the Digitalmars-d mailing list