[nem-en] Field initializers specification
Dmitry Ivankov
divanorama at gmail.com
Fri Mar 16 14:43:15 CET 2007
Also we need to make a ctor specification (calls to base ctor or
another_this ctor).
C# specification is possibly too strict.
In C# ctor has 2 forms:
1) this : another_this(..). it is another_this(..); body
2) this : base(..). it is init_fields; base(..); body
And it cannot have default parameters.
Currently we compile even "base();base();" without any warning/error.
Extension compared to c# can be for example "this(x){def smth=g(x); if
(smth) base(); else this(2);}"
So recursive ctor can be created :))
I suppose something like this will be acceptable:
0) wait until all macros are run, or more exactly until class won't change
in future (also wait for default c-tor generation)
1) if some c-tor doesn't have calls to base or this, inject base() to it's
the beginning
2) replace all calls to base with field_init; base(..) (so initializer
macro will be used only to generate field_init, but not to inject it)
And additional things:
3) ctor can have default parameters (currently it can)
4) do some execution flow check to ensure that base/this was called exactly
once in each ctor body (and recursion is ok, but must be reported as
warning). Emit warnings/errors if we can't be sure about this.
5) maybe do same runtime checks
6) check access to "this" before base/this is called. Do a warning at least.
Field init is before "base()", so "this" references will be reported.
Some things are tricky to implement, but must be specified at least :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman/pipermail/devel-en/attachments/20070316/28e102d0/attachment.html
More information about the devel-en
mailing list