Edit 4: It turns out that this is actually just a limitation of TTY input in general; there's nothing specific about OCaml, Coq, or Emacs which is causing the problem.
I'm working on a Coq program using Proof General in Emacs, and I've found a bug with input that's too long. If a region to submit to coqtop
through Proof General contains more than 1023 characters, Proof General (though not Emacs) hangs while waiting for a response, and the *coq*
buffer contains one extra ^G
character for every character over 1023. For instance, if a 1025-character region was sent to coqtop
, then the *coq*
buffer would end with the two extra characters ^G^G
. I can't proceed past this point in the file, and I have to kill the coqtop
process (either with C-c C-x or a kill
/killall
from the terminal).
Something about this limitation arises from coqtop
itself. If one generates a 1024-character or longer string and pipes it in, such as by running
perl -e 'print ("Eval simpl in " . (" " x 1024) . "1.\n")' | coqtop
then everything works fine. (Similarly, coqc
works fine as well.) However, if I run coqtop
in a terminal, I can't type more than 1024 characters on one line, including the ending return character. Thus, typing a 1023-character line and then hitting return works; but after typing 1024 characters, hitting any key, including return (but not including delete, etc.), does nothing but produce a beep. And it turns out that ocaml
(the OCaml toplevel) has the same behavior:
perl -e 'print ((" " x 1024) . "1;;")' | ocaml
works fine, but I can't type more than 1024 characters on one line if running ocaml
from a terminal. Since my understanding is that coqtop
relies on the OCaml toplevel (more obviously when run as coqtop -byte
), I imagine this is a related limitation.
The relevant software versions are:
- OCaml 3.12.1 from Homebrew;
- Coq 8.3pl3 (and 8.3pl2) from Homebrew;
- Proof General 4.1;
- The build of GNU Emacs 24.1.1 from Emacs for Mac OS X; and
- Mac OS X 10.6.7.
And my questions are:
- What about
ocaml
andcoqtop
is enforcing this character limit? And why only for input from the terminal or Emacs, as opposed to input from a pipe or a file? - Why does Proof General's (apparent) ignorance of this limit cause hanging errors and mysterious
^G
s? - How can I work around this limitation? My end goal is to use Coq inside Proof General/Emacs, so workarounds which dodge the underlying issue are fine.
Edit 3: After finding that the 1024-character input limitation also exists in the Ocaml toplevel (something which I imagine is related), I've added that information and deleted the original problem description, as it's been completely obscured and superseded. (See the edit history if necessary).