[nem-en] A macro-related question
d
d at hell.art.pl
Wed Jun 7 02:11:28 CEST 2006
On Jun 4, 2006, at 4:49 PM, Kamil Skalski wrote:
>> >> or
>> >> public TraverseExpr (ctx : option[Typer], expr : PExpr,
>> >> in_pattern : bool,
>> >> call : bool * bool * PExpr -> PExpr) :
>> PExpr
>> >
>
> I added some comments in the method. It allows you to rewrite
> expression easily - the specified function should capture <[ this ]>
> kind of node and replace it with <[ instead_of_this ]> expression.
Thanks.
In some cases I'll have to use the functions mentioned by you, but
there are places, where I can get away with doing "def arg = this"
and all arg.X references would work as though this.X was called. At
least I was hoping this would work. So here's a part of my code that
does that:
// [...]
| <[ $alias_name ]> =>
tb.Define (<[ decl:
public $(alias_name.ToString () : usesite) : $
(meth.ReturnType : typed) {
get { def $(parms.Head.name.ToString () : usesite) = $
("this" : usesite); $(meth.Body) }
}
]>)
// [Alias (G)] static F (x)
// A property G is generated and instead of [x], [this] is used.
// So it's a situation like static Head (l) { match (l) { | x :: xs
=> x } }
// and Head { get { def l = this; match (l) { | x :: xs => x } } }
When I try to use some code using this macro, compilation fails
with "error: unbound name `this'". I don't really know why it doesn't
work. I thought maybe this is because the source method is static and
the newly generated one is not.. Kamil - I guess you could shed some
light on this ;-)
later,
d
--
https://hell.art.pl == terror.org.pl == terror.icm.edu.pl/~d/gpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /mailman/pipermail/devel-en/attachments/20060607/851a8f58/PGP.bin
More information about the devel-en
mailing list