crystal-community / icr

Interactive console for Crystal programming language
MIT License
505 stars 40 forks source link

What is the state of macro support? #45

Closed bew closed 7 years ago

bew commented 7 years ago
macro a_macro
  42
end
icr(0.22.0) > macro a_macro
icr(0.22.0) >   42
icr(0.22.0) >   end
can't define macro inside def

  macro a
  ^
icr(0.22.0) > 

Are macro unsupported? if yes, maybe add a section in the readme mentionning that? Is it possible to support them in any way?

jwoertink commented 7 years ago

They are slightly supported:

icr(0.22.0) > class Test
icr(0.22.0) >   macro a_macro
icr(0.22.0) >   42
icr(0.22.0) >   end
icr(0.22.0) >   end
 => ok
icr(0.22.0) > Test.a_macro
 => 42

They currently can't be supported outside of a class or module without some big rewrite (which will probably need to happen soon).

jwoertink commented 7 years ago

actually.. scratch that. I think I can add this in 🤓

bew commented 7 years ago

Oh that's nice! 3 addition to support almost all macros... really neat!