Skip to content

User-defined functions? #484

Answered by cueckoo
cueckoo asked this question in General
Jul 3, 2021 · 4 comments · 26 replies
Discussion options

You must be logged in to vote

Original reply by @myitcv in cuelang/cue#484 (comment)

The current best answer is:

foo: {#a: int, #b: int, #a + #b } // struct with embedded scalar
call: foo&{_, #a: 1, #b: 2}         // 3

(a change from the previously marked answer because we now have full support for embedded scalars)

There is a proposal to support a syntactic sugar based on this:

foo: { #a: int, #b: int, #a + #b } // struct with embedded scalar
call: foo(#a: 1, #b: 2) // 3

Replies: 4 comments 26 replies

Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
5 replies
@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@myitcv
Comment options

Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
4 replies
@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

Answer selected by cueckoo
Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
1 reply
@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

Comment options

You must be logged in to vote
16 replies
@steeling
Comment options

@verdverm
Comment options

@steeling
Comment options

@verdverm
Comment options

@myitcv
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants