-
-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add section about lib
function visibility in macro
#662
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 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but if it's important, it should be clear. anyway, we can leave it for a future improvement.
Co-authored-by: Beta Ziliani <[email protected]>
cf. crystal-lang/crystal#12848