read / prin1 question

From: Chris Wright (caw_at_cs.mu.oz.au)
Date: 02/26/04


Date: 25 Feb 2004 22:55:29 -0800

I want to write a hash-table to a file and then read it later. I'm
relying on
"prin1 produces output suitable for input to read." from the
HyperSpec.

But I get an error. I've tried Googling and the lisp FAQ. I'd be
grateful for help

cheers

Chris

Code sample:

<17:34>~ $: uname -a
Darwin Chris-Wrights-Computer.local 7.2.0 Darwin Kernel Version 7.2.0:
Thu Dec 11 16:20:23 PST 2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC
Power Macintosh powerpc

 <17:37>~ $: sbcl
This is SBCL 0.8.8, 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.
* (defvar *t* (make-hash-table))

*T*
* (with-open-file (str "test" :direction :output)
        (prin1 *t* str))

#<HASH-TABLE :TEST EQL :COUNT 0 {48016829}>
* (with-open-file (str "test" :direction :input)
        (read str))

debugger invoked on a READER-ERROR in thread 457:
  READER-ERROR at 2 (line 1, column 2) on #<FILE-STREAM
                                            for "file
\"/Users/caw/test\""
                                            {4807EFD9}>:
illegal sharp macro character: #\<

You can type HELP for debugger help, or (SB-EXT:QUIT) to exit from
SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT ] Reduce debugger level (leaving debugger, returning to
toplevel).
  1: [TOPLEVEL] Restart at toplevel READ/EVAL/PRINT loop.
(SB-IMPL::%READER-ERROR
 3
 #<FILE-STREAM for "file \"/Users/caw/test\"" {4807EFD9}>
 "illegal sharp macro character: ~S")[:EXTERNAL]



Relevant Pages

  • Re: defconstant warnings
    ... SBCL attempts to be strict to ANSI Common Lisp issues to the point where ... The lists when read again are not ... and SBCL interrupts and makes ... "Skip constant redefinition if a #'test of the original and new value is ...
    (comp.lang.lisp)
  • Re: defconstant warnings
    ... >> SBCL attempts to be strict to ANSI Common Lisp issues to the point where ... >> variable named by name at the time defconstant is executed or if the value ... I am aware of destroying the compile-time effect of DEFCONSTANT. ...
    (comp.lang.lisp)
  • Re: Lisp backend protocol
    ... they can be really surprisingly fast. ... an implementation of ANSI Common Lisp. ... More information about SBCL is available at. ... I got a 0.001 runtime on a previous run without the load time, ...
    (comp.lang.lisp)
  • Re: How to create a standalone GNU/Linux binary using SBCL?
    ... >> I'm running SBCL on Debian GNU/Linux. ... > with your custom core and you got an standallone application. ... the SBCL docs tell me something but I was not ... an implementation of ANSI Common Lisp. ...
    (comp.lang.lisp)