-
Notifications
You must be signed in to change notification settings - Fork 12
Add the Lexa language #64
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
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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