Skip to content

When are nullary functions implicitly called? #629

Answered by osa1
osa1 asked this question in Q&A
Discussion options

You must be logged in to vote

To answer my own question "when are nullary functions are implicitly called":

  • Implicit calling only happens in method/field selection syntax (x.y), so nullary functions are never implicitly called.
  • However if the x.y selecting a field, then the field's value is not implicitly called, even if the types are right (i.e. the field's type is a nullary function).

Example:

fun nullary-fun()
  println("In the nullary fun")

fun unary-fun(i: int)
  println("In the unary fun")

effect my-effect
  ctl nullary-effect-op(): ()
  ctl unary-effect-op(i: int): ()

val my-handler = handler
  ctl nullary-effect-op()
    println("Handling nullary op")
    resume(())

  ctl unary-effect-op(i: int)
    prin…

Replies: 2 comments 1 reply

Comment options

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

Comment options

You must be logged in to vote
0 replies
Answer selected by osa1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants