Open dnewhall opened 7 years ago
Unfortunately, there's no good way to support this.
using
is a macro, and macros can have expressions as arguments, and a Block
as the body. But variable as type = SomeValue
is a DeclarationStatement
, which is a Statement
rather than an Expression
, and trying to change that would require changing the parser and the AST and potentially breaking a lot of things.
Maybe one way to achieve this more easily is with the experimental 'var' macro. using var f = Acq...
this way 'f = Acq' is an expression while the inner var macro can add the declaration statement to the AST.
@popcatalin81 That still won't parse, because macros are Statements, not Expressions.
It would be very useful to be able to write this:
using f as Foo = AcquireAndReturnSubtypeOfFoo(): f.DoFooStuff()
This is currently not allowed by the compiler (the "as Foo" part) but similar constructions are allowed in C# and Visual Basic and it would be nice to have this behavior.