The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
#get
method that returns the related Callable
instance that you could then directly invoke #call
on
A macro generates code only in the location in which it is executed.
However.....you can make what you want to do work with macros.
Macros have access to constants.
So, if you generate all of your procs, assigned to a constant name, under a common namespace, then in your main.cr you can iterate over
that namespace (see Crystal::Maros::TypeNode in the Crystal API docs), find the names of all of your Proc constants, and build your master hash.
#register
method then too
macro some_name
are reusable portions of macro code, but you can also use the macro code outside of them