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

Should nullary function *syntax* be shorthand for applying to Unit? #70

Closed
stylewarning opened this issue Sep 6, 2021 · 3 comments · Fixed by #80
Closed

Should nullary function *syntax* be shorthand for applying to Unit? #70

stylewarning opened this issue Sep 6, 2021 · 3 comments · Fixed by #80

Comments

@stylewarning
Copy link
Member

If we adopt a convention that

(declare f (Unit -> Foo))

represents something stateful or perhaps allocating in nature (e.g., creating a fresh object like a vector), then maybe it’s nice to have a syntax that is Lispy, like

(f)

which at parse-time is rewritten

(f Unit)

Thoughts?

@stylewarning
Copy link
Member Author

My main qualm is that it can just be confusing, especially if (f) ends up being a type error.

At the same time, (make-vector Unit) is odd to see.

@eliaslfox
Copy link
Collaborator

eliaslfox commented Sep 6, 2021

(match e
  ((Some (None)) (error "am I matching on None or calling the function None?"))

@eliaslfox
Copy link
Collaborator

Actually that isn't ambitious. Patterns can't contain arbitrary expressions.

eliaslfox added a commit that referenced this issue Sep 7, 2021
eliaslfox added a commit that referenced this issue Sep 7, 2021
eliaslfox added a commit that referenced this issue Sep 7, 2021
eliaslfox added a commit that referenced this issue Sep 7, 2021
eliaslfox added a commit that referenced this issue Sep 7, 2021
eliaslfox added a commit that referenced this issue Sep 7, 2021
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 a pull request may close this issue.

2 participants