How to get the type of a symbol in a macro?

I want to write a macro where i can convert the symbols to types and do some type based programming?

How can i do that for ex:

@linearize Type1 Type2 Type3

Type1-3 will be accessible as a symbol within the macro but i want to access them as types.
How can i do that?


This is not possible. Macros only have access to the literal code itself, never its values (nor types). What is the actual problem you’re trying to solve?

Thank you,
I was writing a linearization system, but that means, i need to stage the computation of linearization in the macro to be run at runtime.


Can i use eval within the macro and get the type?
such as:

You need to give it the right module. And you need to be aware that it happens at compile time. It’s valid code pattern but it may not be what you want.

Maybe you actually want a @generated function instead?

1 Like


can you show me an example which would help my case?


If you could tell us what you are trying to accomplish, it would be easier to help you implement it.