Hi Eugene,
Thanks for the fast feedback!
2012/7/4 Eugene Burmako <
eugene....@epfl.ch>:
> The concept looks good! Now we only need a pull request that incorporates
> this into trunk :)
Hehe, that's probably for my next "free night" slot :-)
> Some comments:
> 1) I've seen you needed some casts to go between a macro impl and your macro
> helper. You can try the approach employed in reification macros to get rid
> of those casts [1, 2].
Nice hack! I've gone a bit too caky though, so it would need some
tweaks to work in my case (I refer to dependent singletons such as
matcher objects: not sure I can implicitly convert them, and cannot
really import them accross the existential types...). Also, I'm
concerned about introducing implicit conversions to and from
existential types everywhere (<shiver> reflection... compilation
time...)
> 2) What's the justification for resetAllAttrs? If it's the necessity to
> remove all references to the lambda's parameter, then a transformer that
> does exactly that would be more robust.
I pulled it out of my hat when all other hope was gone... My guess is
that it gives the typer a chance to set a symbol to my shiny new "i"
reference (replacement of lambda parameter references). I believe
typer stops when it finds a typed (/ symbolized?) subtree, and I
didn't want to set the symbol myself because I thought we weren't
supposed to tamper with them too much them in macros.
> Sure, typically if you erase symbols
> and re-typecheck the tree, but sometimes it won't work:
>
https://issues.scala-lang.org/browse/SI-5464 (for one, do nested inlined
> loops work? labeldefs used to be especially unfriendly to re-typechecking).
> Also, if the body of a foreach contains expansions of macros, which
> establish non-standard bindings by manually assigning symbols, then these
> bindings will be wiped out and won't be able to be restored.
Oooh... so can we set create / symbols in macros ? (I just need to
create vals and vars, no fancy new methods or classes which I think I
read somewhere could not be created within macros)
> 3) (a minor one) Instead of definitions.IntClass.asType you can use IntTpe.
> Same for booleans and some other core classes [3].
Cool!
> 4) Nice trick with transform. Saves quite a bit of typing.
Every char matters ;-)