small changes

master
Araozu 2024-05-20 16:53:14 -05:00
parent 957921b793
commit 79bdee91d0
2 changed files with 64 additions and 11 deletions

View File

@ -176,7 +176,7 @@ const serialized_inst = JSON.stringify(instructionSet);
break; break;
} }
case InstructionType.Out: { case InstructionType.Out: {
data.stdout += i.v0 data.stdout += i.v0.slice(1, -1) + "\n"
break; break;
} }
case InstructionType.Set: { case InstructionType.Set: {
@ -186,7 +186,7 @@ const serialized_inst = JSON.stringify(instructionSet);
break; break;
} }
case InstructionType.Unset: { case InstructionType.Unset: {
delete data.state[i.v0]; delete data.state[i.v0.slice(1, -1)];
break; break;
} }
} }

View File

@ -153,17 +153,70 @@ In the previous example:
Try/return will assign a new value if an expression fails. Try/return will assign a new value if an expression fails.
```thp <InteractiveCode
fun run() code={`
{ fun run(Int!Exception possible_value)
val result = try dangerous() else 322 {
val mid = try possible_value else 666
print(result) print("The value is: {mid}")
} }
```
- If `dangerous()` fails, the value `322` will be assigned to `result`. run(777) // With an actual value
- If `dangerous()` succeedes, its value will be assigned to `result`. run(Exception("oh uh")) // With an exception
`}
steps={`
step {line 8}
step {line 1}
step {
set "= = =" "run() = = = ="
set "possible_value" "Int 777"
line 2
}
step {line 3}
step {
line 5
set "Int mid" "Int 777"
}
step {
line 6
out "The value is: 777"
}
step{
unset "= = ="
unset "possible_value"
unset "Int mid"
line 8
}
step{line 9}
step{line 1}
step {
set "= = =" "run() = = = ="
set "possible_value" "Exception(\\"oh uh\\")"
line 2
}
step{line 3}
step {
line 5
set "Int mid" "666"
}
step {
line 6
out "The value is: 666"
}
step{
unset "= = ="
unset "possible_value"
unset "Int mid"
line 9
}
step{line 0}
`}
>
</InteractiveCode>
- If `possible_value` is an error, the value `666` is used.
- If `possible_value` is not an error, its value will be used.
Either way, the function will continue executing. Either way, the function will continue executing.