WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

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