Conversation
|
@jasigal Hi Jesse, can you review this PR? |
|
Will do later this week! |
jasigal
left a comment
There was a problem hiding this comment.
Looks great, just some small changes suggested to be consistent with the other implementations, and some questions about Lexa.
|
|
||
| def set(i) { | ||
| s[0] := i; | ||
| 0 |
There was a problem hiding this comment.
Question: Why does this return 0 instead of the unit value?
|
|
||
| type generator = | ||
| | Empty | ||
| | Thunk of int * (cont <> unit -> generator) |
There was a problem hiding this comment.
Change: The other implementations appear to store functions here instead of continuations. I think to maintain consistency the same should be done here.
| def generate(f: <> [; yield_stub: Yield] () -> int): generator { | ||
| handle <> { | ||
| f:[; yield_stub](); | ||
| Empty() |
There was a problem hiding this comment.
Nit: Does Lexa have return clauses? It would be nice to maintain consistency if it does.
| Empty() | ||
| } with yield_stub: Yield { | ||
| hdl_1 yield(x, k) { | ||
| Thunk(x, k) |
There was a problem hiding this comment.
See above comment about storing functions versus continuations.
| match g with | ||
| | Empty -> { a } | ||
| | Thunk (v, f) -> { | ||
| sum(v + a, resume_final f (())) |
There was a problem hiding this comment.
See above comment about storing functions versus continuations.
| @@ -0,0 +1,56 @@ | |||
| effect Search { | |||
| pick: (int) -> int | |||
| fail: () -> int | |||
There was a problem hiding this comment.
Technically the return type of fail is prescribed to be void/empty. Does Lexa have this?
| parse:[;read_stub, emit_stub, stop_stub](0) | ||
| } | ||
|
|
||
| def sum_action [;emit_stub: Emit] (n: int): int { |
There was a problem hiding this comment.
Would you mind explaining what's going on here? Are the functions being passed by reference?
| @@ -0,0 +1,50 @@ | |||
| effect Choice { | |||
| flip: () -> int | |||
| fail: () -> int | |||
There was a problem hiding this comment.
Same question about void/empty.
| val j = choice:[; choice_stub](i - 1); | ||
| val k = choice:[; choice_stub](j - 1); | ||
| if i + j + k == s then | ||
| hash(i, j, k) |
There was a problem hiding this comment.
Question: Does Lexa have tuples? If so, hash should be moved to run to maintain consistency.
|
|
||
| def run(n: int, s: int): int { | ||
| handle <> { | ||
| triple:[; choice_stub](n, s) |
There was a problem hiding this comment.
See above, hash would be here.
|
Thanks Jesse, these are very useful comments! Some need modification to the Lexa compiler itself, and I'll resolve them next week. |
This PR adds the Lexa language.
https://github.com/lexa-lang/lexa