question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REPL: definition support

See original GitHub issue

Support definitions in REPL, to aid exploration of TLA by new users. Requested already in #586; here is a proposed design.

The REPL should maintain a sequence of operator definitions and (optionally named) module instantiations, which, when evaluating an expression, are emitted in order as part of the tlarepl module. (Supporting module instantiations also allows the REPL to be used to explore existing constant-level modules.)

New definitions and instantiations are input by the user using the same syntax as in a TLA module. If the definition or instantiation results in a parse error, it should be rejected with the error shared to the user.

Since the REPL now maintains state, it is helpful for users to see and record that state. A new LIST command should display (in order) all existing definitions and instantiations. A new SAVE <filename> command should write out a module containing the definitions and instantiations to a file. (Probably <filename> can be either a proper filename, or just a bare module name.)

Additionally, it should be possible to modify or remove existing definitions. Prefixing a definition or instantiation with the word REDEFINE should replace the named definition or instantiation of the named module from the sequence with the new definition or instantiation, without changing the relative position of the item in the sequence. As with new definitions, if the replacement results in an error, it should be rejected.

Finally, it should be possible to remove existing definitions. The new commands FORGET DEFINITION <name> and FORGET INSTANCE <name> should remove the named operator or instance from the sequence, again rejecting the operation if it results in an invalid module. (Is OPERATOR a better word to use here than DEFINITION?) To permit easily returning to a clean slate, FORGET ALL simply wipes all recorded operators and instances.

Optional: Leverage TLC to detect incomplete operator definitions, and prompt the user to complete the definition on one or more subsequent lines. This is similar behavior to Python’s REPL, and especially helps when pasting a multiline definition.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:35 (35 by maintainers)

github_iconTop GitHub Comments

1reaction
cpacejocommented, Nov 4, 2021

Apologies, I haven’t had time to dedicate to this the past few months (as you can tell). I am actually about to introduce a few colleagues to TLA next week and plan to point them at the CLI for exploratory purposes, so I will have my head space back in TLA-land at least. But until things slow down a bit with my current project (at least another few months) I can’t promise I’ll have time to dedicate to CLI improvements – please housekeep accordingly.

1reaction
cpacejocommented, May 20, 2021

my efforts are better directed elsewhere (e.g., VSCode terminal)

I hope you did not interpret my request as a suggestion for what to spend your time on; I did not mean it that way. I thought I expressed my intention to do the legwork for this in my initial e-mail to the list, but maybe it got lost in translation.

(I do recognize that long-term maintenance ultimately rests on your shoulders; I am trying to keep the proposed behavior simple and self-contained to minimize coupling and future maintenance but I know it’s not perfect.)

Alternatively, why not fork tlc2.REPL to your.package.REPL and load it from the classpath?

This is actually what I started doing (writing my own, linking to tlatools) when I discovered that a REPL had been added since last I updated tlatools. My goal in opening this discussion was to make sure I would not be stepping on toes or duplicating work, if you or @will62794 already had design plans or code in progress.

I appreciate the feedback given on my design; I think the latest iteration I proposed, having jettisoned all new keywords while maintaining most functionality, is much better than what I came in with.

I’ll proceed with implementing this design in a separate branch in my own repo, and keep fixes for any bugs I find in error reporting on the main branch to submit back to the official repo.

I’ll be interested to hear your findings after running the training, thanks. I have two colleagues who are independently learning TLA right now; I will make sure to get their feedback on whatever changes I make to the REPL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Read–eval–print loop - Wikipedia
A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes ...
Read more >
What is a REPL? - Code With Mu
The REPL is actually a part of the amazing Jupyter project - a way of creating and sharing documents that contain live code,...
Read more >
What is REPL? - Computer Hope
Short for read-eval-print loop, REPL is the interactive top level of a programming language interpreter or command line shell.
Read more >
What does repl stand for? - Replit
Repl stands for Read Eval Print Loop. ... Ah, ok. Do you have any idea why it is named this way or what...
Read more >
Node.js - REPL Terminal - Tutorialspoint
Node.js - REPL Terminal, REPL stands for Read Eval Print Loop and it represents a computer environment like a Windows console or Unix/Linux...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found