Closed yewscion closed 2 years ago
The REPL doesn't merge multiple lines together, instead executing each immediately (I find REPLs that enter the multiline mode on mismatched brackets extremely annoying to use, and it's unimplementable without making a custom REPL (i.e. replacing rlwrap
) interface anyways).
You can still use single-line blocks, e.g. updown ← {up ← ↕5 ⋄ down ← ⌽up ⋄ up∾down}
.
Programmatic interfaces can use )escaped "updown ← {\n…\n}"
to allow for multiline definitions.
Thank You for the response!
I've been able to modify the code I mentioned to run arbitrary code simply by always using the )escape
interface You mentioned (and a few substitutions on the way).
Are there any other idiosyncracies You know of with that mechanism, where one might not want to run code through it? I can imagine a scenario with a string that includes escapes (possibly for use with printf or similar), but no others come to mind right away.
For that specific scenario, I suppose replacing known escapes in the raw code with double backslashes (\n, for instance) would solve the issue. Is that a reasonable way to deal with that problem?
)escaped
is always fine to use; you can even )escaped ")escaped \"2+2\""
.
)escaped
accepts the escape sequences \\
, \"
, \n
, and \r
with their standard meanings, so e.g. )escaped "<\"\\n\""
evaluates to an enclosed string of a literal backslash followed by n
, i.e. the code <"\n"
.
Awesome to hear. Thank You for helping me understand.
Are blocks only supposed to exist in files? For some reason, I get an error when I try to execute something like the following (which comes from the BQN documentation in my CBQN repl:
If so, this also means that for things like https://github.com/museoa/bqn-mode executing the buffer You are working on is impossible if it contains a block, as it would pass the buffer as a string to the running REPL rather than saving the file and loading it into CBQN.