-
|
What are the rules of when a function with no arguments will be implicitly called? Is there a difference between I'm also confused about the "suspender" syntax. User manual says: (https://koka-lang.github.io/koka/doc/book.html#why-mingen)
But in this example, the suspended code is evaluated: This program prints According to the book section linked above, I would expect |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Variable declarations implicitly define a block scope so that you can use multiple lines to define the variable. This is how you can do: val x =
with handler
...
...Any place a block scope occurs adding explicit braces will not change the meaning. In all cases struct xtype
f: () -> int
g: (int) -> int
...
// generates
fun f(x : xtype)
match x
X(f_) -> f_
fun g(x : xtype)
match x
X(_, g_) -> g_
fun main()
val x = X(fn(){1})
x.f // access the f function and doesn't call it
x.g // access the g function
// in the latest dev version of koka we can do the following to actually call the functions accessed from a datatype.
x.f.()
x.g.(0) |
Beta Was this translation helpful? Give feedback.
-
|
To answer my own question "when are nullary functions are implicitly called":
Example: To call a function in a struct field, we need double This is because the first |
Beta Was this translation helpful? Give feedback.
To answer my own question "when are nullary functions are implicitly called":
x.y), so nullary functions are never implicitly called.x.yselecting 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: