Can the double semicolon be removed in the toplevel?

From what I vaguely remember while working on down, this is a bit more tricky than it looks.

You need some kind of clear convention to declare to the line editor that you want to issue the code for evaluation. There are alternatives like M-enter, if your can enter it conveniently (e.g. it’s not by default on my input method/terminal combo).

So in the end a clear marker followed by a newline is perhaps not so bad to serve for that intent. (Perhaps a double newline could work aswell, I don’t know).

1 Like

I imagine the suggestion for the removal of the toplevel double semi-colon is not intended seriously. But in case I am wrong about that, as it is at present valid syntax for both scripts and compiled code (although informally deprecated at least in compiled code), how much code breakage by this change would be acceptable and in pursuit of what worthwhile aim?

Surely some things inherited from the past just have to be lived with.

I am fairly sure we are talking about the toplevel ie REPL only, not removing it as valid syntax from OCaml source code. In fact we wouldn’t even need to remove it, we could just provide an alternative way to send code for evaluation to the REPL, eg pressing Shift-Enter.

1 Like

So I think the proposal then becomes that ;; would be kept in order to terminate directives in a script or REPL, and it would remain a (possibly deprecated) syntactic way of terminating a definition or expression, but it would no longer force an evaluation by the interpreter at the REPL.

I suppose this would reduce the range of overloaded meanings of ;;, but would it be worth the effort?

I don’t think there’s even any need to change this behaviour. What I am thinking is purely additive–just recognize Shift-Enter as an additional way to terminate input and start evaluation. Then we could just ‘advertise’ the new way in all REPL documentation.


OK. I was responding to the suggestion that the double semi-colon should be removed in the top level.

As this thread is I think about beginners getting a hold on the language, or has become so, I don’t believe beginners use the REPL very much once they get past the 1 + 1 or print_endline "Hello world" stage. Instead I think they probably begin writing scripts and the REPL is something you come back to for live evaluation during development.

Utop already has such an option. But I don’t remember how to enable it.

I haven’t followed the entire discussion (frankly, I don’t see the problem – “;;” is a way to terminate input, and it makes parsing EASY, what’s the downside again?) but sure, this makes perfect sense: Shift-Enter adds a “;;” to the end of the input and … wheeeee!!! off we go!

Don’t see the problem.

It’s mentioned in this down issue.

But then there are also advantages in the marker being visually there. It helps for writing tutorials and you need a separator anyways in history. Having ;; as the separator means that your history (or session file), if it keeps only successful parses, becomes a plain ml file (EDIT well apparently down uses (**) in history files, no longer sure exactly why). This means that you can use your regular editor tooling on it etc.

Also people should be aware that the bare ocaml does absolutely no line editing/tty interaction, it can’t use a control sequence for that. So you will likely see ;; as long as this is going to be the case. Personally I don’t think it’s a bad idea, I routinely get tripped off when trying to enter multline shell commands.

  • Most people write their OCaml code without ;; so it introduces confusion for the new comers. Sometimes this end marker is necessary and sometimes it’s not and it’s not clear why.

  • I’m lazy and when I copy paste a bit of code I don’t want to also type ;; (but I’m lucky enough that’s I’m not newcomer and I found my way to ~/.config/utop/ :slight_smile:

1 Like

Sorry @cvine, I wrote

And can the double semicolon be removed in the top-level, too?

But what I had in mind was what @yawaramin described: a way to interact with the top-level that doesn’t require typing double semicolons. As @beajeanm replied to @Chet_Murthy, this is for newbies and copy-pasting friendliness. Shift-Enter could do the job. I’d also buy double newline as suggested by @dbuenzli.

P.S. Sorry to have derailed this thread into something unrelated to the initial topic. Can someone split the thread?

I looked at the referenced utop issue ( Analog to utop’s accept-current-phrase · Issue #24 · dbuenzli/down · GitHub ) and … this looks like it just squirts a “;;\n” into the stream to the toplevel ?

Maybe what you mean is that -users- who use GUIs and other front-ends to interact with the top-level, shouldn’t need to type “;;” ? That is, when I use Emacs, Shift-RET should squirt that “;;” down the pipe ? If so, then sure, that’s wonderful. But it’s also different from eliminating “;;” from the grammar, right?

Concretely, we communicate with toplevel via character I/O streams. As Marshall Rose put it so well (so long ago), there are three ways to signify the end of a packet (in this case, a top-level phrase):

  1. a sentinel
  2. a length-count
  3. connection-blasting

In the context of a language with a grammar, length-counting corresponds to ensuring that the grammar’s phrases always terminate at a point where no lookahead is needed to conclude termination. That’s … complicated. connection-blasting is a non-starter (it means to open a separate connection for each phrase). And a sentinel … well, that’s “;;”.

I just want to be clear: I love the idea of mapping Shift-RET to “do what is needed to tell the top-level that the current input terminates a top-level phrase”. I just don’t see how that changes the raw top-level and its grammar.