Discussion:
No parsetree body accessible
Dmitry Ivankov
2007-06-19 18:17:03 UTC
Permalink
Hi

I've tried to improve regexp macro, making Regex static.
But attached patch doesn't work, sometimes it gets subject
error, for example when compiling testsuite/test.n.
It just defines new field in CurrentTypeBuilder.

What is the problem? It gets wrong builder or gets it too late?

Btw, http://nemerle.org/Defining_types_from_inside_macros contains outdated
info about tb.CannotFinalize, it's setter isn't accessible.
Kamil Skalski
2007-06-19 19:14:13 UTC
Permalink
Most probably this is because of initializer. At the moment of typing
method body constructors are already typed and you cannot add the
initialization code to them.
Post by Dmitry Ivankov
Hi
I've tried to improve regexp macro, making Regex static.
But attached patch doesn't work, sometimes it gets subject error, for
example when compiling testsuite/test.n.
It just defines new field in CurrentTypeBuilder.
What is the problem? It gets wrong builder or gets it too late?
Btw, http://nemerle.org/Defining_types_from_inside_macros
contains outdated info about tb.CannotFinalize, it's setter isn't
accessible.
_______________________________________________
https://nemerle.org/mailman/listinfo/devel-en
--
Kamil Skalski
http://nazgul.omega.pl
Michal Moskal
2007-06-19 19:38:56 UTC
Permalink
Post by Kamil Skalski
Most probably this is because of initializer. At the moment of typing
method body constructors are already typed and you cannot add the
initialization code to them.
Maybe we should hack the compiler, to type the static constructor last
(and maybe normal constructors next to last)? I don't see this being
problematic in any case, and in some cases (like this one) it would be
useful.
--
Micha³
Dmitry Ivankov
2007-06-19 19:51:12 UTC
Permalink
Post by Kamil Skalski
Most probably this is because of initializer. At the moment of typing
method body constructors are already typed and you cannot add the
initialization code to them.
Yes, looks like it.
Nested class with static initialized field seems to work, I'll try to use it
instead.
Post by Kamil Skalski
Maybe we should hack the compiler, to type the static constructor last
(and maybe normal constructors next to last)? I don't see this being
problematic in any case, and in some cases (like this one) it would be
useful.
I agree, it would be useful
hack. But probably typing in that order isn't always possible, so it
shouldn't be relied on too much :)


And returning to wiki & tb.CannotFinalize: should it be just removed
from examples,
or that property was somehow renamed or replaced with another one?
Kamil Skalski
2007-06-19 20:05:13 UTC
Permalink
Post by Dmitry Ivankov
Post by Kamil Skalski
Most probably this is because of initializer. At the moment of typing
method body constructors are already typed and you cannot add the
initialization code to them.
Yes, looks like it.
Nested class with static initialized field seems to work, I'll
try to use it instead.
Post by Kamil Skalski
Maybe we should hack the compiler, to type the static constructor last
(and maybe normal constructors next to last)? I don't see this being
problematic in any case, and in some cases (like this one) it would be
useful.
I agree, it would be useful hack. But probably typing in
that order isn't always possible, so it shouldn't
be relied on too much :)
I think this would fix all similar scenarios, when you want to
generate initializer during typing, which would be good. I don't think
it could cause any problems - order of typing methods is not
important.
Post by Dmitry Ivankov
And returning to wiki & tb.CannotFinalize : should it be just
removed from examples, or that property was somehow renamed
or replaced with another one?
public CannotFinalize : bool
{
get { cannot_finalize }
internal set { cannot_finalize = value; }
}

Looks like the setter bacame internal (or was such always?) I'm not
sure why it is needed - all examples in ncc/testsuite/macrolib.n just
uses Compile...
--
Kamil Skalski
http://nazgul.omega.pl
Dmitry Ivankov
2007-06-19 20:23:17 UTC
Permalink
Post by Kamil Skalski
I think this would fix all similar scenarios, when you want to
generate initializer during typing, which would be good. I don't think
it could cause any problems - order of typing methods is not
important.
Sure, just if macro from ctor defines new method we won't be able to
type it before all ctors.
Of course such methods hardly will add
initializers, so it doesn't matter in this context :)


Looks like the setter bacame internal (or was such always?) I'm not
Post by Kamil Skalski
sure why it is needed - all examples in ncc/testsuite/macrolib.n just
uses Compile...
I suppose that the property is managed automatically now
and it can be removed from wiki.

Loading...