thephoeron/cl-isaac

How can I script this? (Error: Too Many Dots?)

shillshocked opened this issue · 2 comments

I got sbcl and quicklisp installed. The code works as instructed, but I cannot get it to script so I can call it from a bash script. I can load the script via sbcl --load script1.lisp, but it crashes after the first command.

Here are the contents of script1.lisp:

* (ql:quickload "cl-isaac")
...
* (defvar *self-ctx* (isaac:init-self-seed :count 3 :is64 t))
* (format nil "~64,'0x" (isaac:rand-bits-64 *self-ctx* 65536))

And here is the command and error:
[user1@computer ~]$ sbcl --load /home/user1/scripts/script1.lisp
This is SBCL 1.2.2, an implementation of ANSI Common Lisp.
More information about SBCL is available at http://www.sbcl.org/.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
To load "cl-isaac":
Load 1 ASDF system:
cl-isaac
; Loading "cl-isaac"

debugger invoked on a SB-C::INPUT-ERROR-IN-LOAD in thread

<THREAD "main thread" RUNNING {1002C166B3}>:

READ error during LOAD:

too many dots

  Line: 2, Column: 3, File-Position: 30

  Stream: #<SB-SYS:FD-STREAM for "file /home/user1/scripts/script1.lisp"
            {10044B87B3}>

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT ] Abort loading file "/home/user1/scripts/script1.lisp".
1: [CONTINUE] Ignore runtime option --load "/home/user1/scripts/script1.lisp".
2: Skip rest of --eval and --load options.
3: Skip to toplevel READ/EVAL/PRINT loop.
4: [EXIT ] Exit SBCL (calling #'EXIT, killing the process).

(SB-C:COMPILER-ERROR SB-C::INPUT-ERROR-IN-LOAD :CONDITION #<SB-INT:SIMPLE-READER-ERROR "too many dots" {1004DE7633}> :STREAM #<SB-SYS:FD-STREAM for "file /home/user1/scripts/script1.lisp" {10044B87B3}>)

You seem to have copy-and-pasted the REPL prompt character and the ellipsis from the example verbatim into your Lisp source file before customizing it to your need. In the example provided, the implication is that you type each line of Lisp code at the REPL, which is what the prompt character signifies—and the ellipsis is there because the output from Quicklisp is suppressed in the example—so if you edit your script1.lisp file to read as follows:

(ql:quickload "cl-isaac")

(defvar self-ctx (isaac:init-self-seed :count 3 :is64 t))

(format t "~64,'0x" (isaac:rand-bits-64 self-ctx 65536))

That should do what you expect. Notice also that I have changed (format nil ...) to (format t ...). Since your script is not at the REPL, when you run this by $ sbcl --load script1.lisp, you won't see any return values from evaluated forms; you have to stream the output to *standard-output* to get it sent back to the terminal, and in this context t is a shortcut for that. See CLHS: Format for more info.

Awesome! Thanks for the quick fix AND explanation! :)