Skip to content

Add section about lib function visibility in macro#662

Merged
straight-shoota merged 4 commits intocrystal-lang:masterfrom
straight-shoota:feature/lib-function-visibility
Jan 9, 2023
Merged

Add section about lib function visibility in macro#662
straight-shoota merged 4 commits intocrystal-lang:masterfrom
straight-shoota:feature/lib-function-visibility

Conversation

@straight-shoota
Copy link
Copy Markdown
Member

@straight-shoota straight-shoota commented Jan 7, 2023

@straight-shoota straight-shoota self-assigned this Jan 7, 2023
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 7, 2023

Deploy Preview for crystal-book ready!

Name Link
🔨 Latest commit a7ec17d
🔍 Latest deploy log https://app.netlify.com/sites/crystal-book/deploys/63bc46b1d7980a000819fa94
😎 Deploy Preview https://deploy-preview-662--crystal-book.netlify.app/syntax_and_semantics/c_bindings/lib
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Co-authored-by: George Dietrich <george@dietrich.app>
Copy link
Copy Markdown
Member

@beta-ziliani beta-ziliani left a 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.
Copy link
Copy Markdown
Member

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.

Suggested change
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):

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

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.

@straight-shoota straight-shoota merged commit 867b2c8 into crystal-lang:master Jan 9, 2023
@straight-shoota straight-shoota deleted the feature/lib-function-visibility branch January 9, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants