[nem-en] doesn't work: using(def a = A())

Michal Moskal michal.moskal at gmail.com
Mon Feb 6 08:23:04 CET 2006


On 2/6/06, Valient Gough <valient at gmail.com> wrote:
> If class A inherits from IDisposable, then the following would work in C#:
>
> using(A a = new A())
> { ... }
>
> But in Nemerle, trying this gives a compiler error:
>
> using(def a = A())
> { ... }

Just use:

using (a = A ()) { ... }

(in case you didn't know).

> So it looks like ncc is treating the expression as something closer to:
>
> mutable _tmp = null;
> using(_tmp = (def a = A()) )
> { ... }
>
> Which doesn't work..  But should it?  The C# syntax looks cleaner to me...

In C# they needed the type to be given explicitly, hence the syntax.
Maybe we should make using (def ...) work in Nemerle, though. We allow
using (mutable ...) anyway.

What do others think?

--
   Michal Moskal,
   http://nemerle.org/~malekith/



More information about the devel-en mailing list