Last active
October 21, 2017 03:40
-
-
Save Yardanico/7b961cbeb5c8d797e5f4ecf80ff639b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros, tables | |
macro echoType(x: typed): untyped = | |
let impl = x.symbol.getImpl() | |
# we're called on some type | |
if impl.kind == nnkTypeDef: | |
echo "type ", toStrLit(impl) | |
# we're called on a variable | |
else: | |
echo "type ", impl.getTypeInst(), " = ", toStrLit(impl.getTypeImpl()) | |
type | |
MyObj = object | |
x: int | |
echoType(MyObj) | |
let a = MyObj(x: 5) | |
echoType(a) |
Now I get: type Response = ref Response:ObjectType
.. I guess it's surprisingly hard to see the attributes of Response at runtime!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent!!