Skip to content
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

Handle delay, function, and/or command types in read #2232

Open
byorgey opened this issue Dec 26, 2024 · 0 comments
Open

Handle delay, function, and/or command types in read #2232

byorgey opened this issue Dec 26, 2024 · 0 comments
Labels
C-Moderate Effort Should take a moderate amount of time to address. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. L-Parsing Parsing the Swarm language from a string into an AST. L-Pretty-printing Pretty-printing ASTs or values into a string representation. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Feature A new feature to be added to the game.

Comments

@byorgey
Copy link
Member

byorgey commented Dec 26, 2024

As implemented in #2224 , the read command can only handle first-order values with no captured environment, which excludes delay types, function types, and commands. In some cases, however, handling these would be straightforward, for example format move == "move" and read "move" : Cmd Unit should be easy to implement. In other cases it is a bit tricker, and might even require fixing some bugs in format. For example, currently we pretty-print function closures using let bindings:

> def x = 3 end
> format (\y. y + x)
it0 : Text = "let x = 3 in \y. y + x"

In order to read such values we would need to specially handle let bindings to turn them into an environment (or possibly simply run the resulting Term through the interpreter until it becomes a Value --- but we would have to be careful to only do this for terms that we can statically tell will really turn into values in finite steps, since otherwise read would essentially be eval and could cause the game to hang).

In other cases, however, it looks like format doesn't actually do the right thing. For example, delayed values can also close over the environment, but this does not currently get formatted with let:

> def z = 2 end
> format {z + 3}
it1 : Text = "{z + 3}"
@byorgey byorgey added Z-Feature A new feature to be added to the game. C-Moderate Effort Should take a moderate amount of time to address. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. L-Parsing Parsing the Swarm language from a string into an AST. L-Pretty-printing Pretty-printing ASTs or values into a string representation. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Moderate Effort Should take a moderate amount of time to address. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. L-Parsing Parsing the Swarm language from a string into an AST. L-Pretty-printing Pretty-printing ASTs or values into a string representation. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

No branches or pull requests

1 participant