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

Function objects, @|| meta key #163

Closed
irh opened this issue May 4, 2022 · 1 comment
Closed

Function objects, @|| meta key #163

irh opened this issue May 4, 2022 · 1 comment
Labels
enhancement New feature or request v0.12

Comments

@irh
Copy link
Contributor

irh commented May 4, 2022

It would be useful to be able to define function objects in Koto.

This could be achieved by adding a @|| meta key that can be defined in Maps, which would then allow the map to be treated as a function.

e.g.

my_function = 
  @||: || 42

my_function_with_args =      
  @||: |x, y| x + y

my_instance_function =      
  data: [1, 2, 3]
  @||: |self| self.data

print my_function()
# 42

print my_function_with_args 2, 3
# 5

print my_instance_function()
# [1, 2, 3]
@irh irh changed the title Function objects, @() meta key Function objects, @|| meta key May 4, 2022
@irh irh added enhancement New feature or request v0.12 labels May 10, 2022
@irh
Copy link
Contributor Author

irh commented Jan 5, 2023

Implemented in #197.

@irh irh closed this as completed Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v0.12
Projects
None yet
Development

No branches or pull requests

1 participant