Add section about lib function visibility in macro#662
Conversation
✅ Deploy Preview for crystal-book ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Co-authored-by: George Dietrich <george@dietrich.app>
beta-ziliani
left a comment
There was a problem hiding this comment.
It's a bit odd that we're saying this about libs, but not about other types. But I guess it's better to have something somewhere than anything, so OK.
|
|
||
| ## Reflection | ||
|
|
||
| Lib functions are visible in the macro language anywhere in the program. |
There was a problem hiding this comment.
I don't think it's clear what "anywhere" means here. Also, probably we want to link to the API.
| Lib functions are visible in the macro language anywhere in the program. | |
| Lib functions are visible in the macro language using the method [`TypeNode#methods`](https://crystal-lang.org/api/1.6.2/Crystal/Macros/TypeNode.html#methods%3AArrayLiteral%28Def%29-instance-method): |
There was a problem hiding this comment.
"anywhere" might not be very clear, but it's important. TypeNode#methods for other types only works within method context. The point we're mentioning this here is that for lib types it also works outside of methods.
There was a problem hiding this comment.
but if it's important, it should be clear. anyway, we can leave it for a future improvement.
Co-authored-by: Beta Ziliani <beta@manas.tech>
cf. crystal-lang/crystal#12848