Skip to content
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

Document top-level funs #671

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HertzDevil
Copy link
Contributor

Resolves #667.

@netlify
Copy link

netlify bot commented Feb 27, 2023

Deploy Preview for crystal-book ready!

Name Link
🔨 Latest commit eb261aa
🔍 Latest deploy log https://app.netlify.com/sites/crystal-book/deploys/63fcf15845debe00082d42b5
😎 Deploy Preview https://deploy-preview-671--crystal-book.netlify.app/syntax_and_semantics/c_bindings/fun
📱 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.


Like lib funs, all parameter and return types are mandatory, and only valid types in C bindings are permitted. Like regular Crystal defs, they have a body and can be called directly by other Crystal code.

Because Crystal programs are not meant to be used as shared libraries, top-level methods should be defined using the `def` keyword instead of `fun`. Exceptions are entry points used by the underlying operating system, such as the C `main` on most systems.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "are not meant to be used as shared libraries" might be a bit strong. That applies mostly to stdlib which imposes restrictions on usefulness as a library. But this is the language specification, not stdlib.
I'd maybe tone that down a little bit.

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.

Document fun defs
2 participants