chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] tinkering with the reader


From: Michele Simionato
Subject: [Chicken-users] tinkering with the reader
Date: Wed, 15 Dec 2004 09:17:45 +0100

I was looking at the example for set-reader-syntax! in the manual:

          ; A simple RGB color syntax:
          
          (set-read-syntax! #\%
            (lambda (port)
              (apply vector
                (map (cut string->number <> 16)
                     (string-chop (read-string 6 port) 2) ) ) ) )
          
          (with-input-from-string "(1 2 %e0e0e0 3)" read)
          ; ==> (1 2 #(240 240 240) 3)


Apart from the fact that hex(e0) == 224, and not 240, it works ;-)
However I did some experiment like this:

(print '(1 2 %e0e0e0 3))

If I run this from the interpreter the reader works, but if I compile
the script it does
not:


$ csi reader2.scm
  _, _,_ _  _, _,_ __, _, _
 / ` |_| | / ` |_/ |_  |\ |
 \ , | | | \ , | \ |   | \|
  ~  ~ ~ ~  ~  ~ ~ ~~~ ~  ~
Version 1, Build 74 - linux-unix-gnu-x86
(c)2000-2004 Felix L. Winkelmann
; loading reader2.scm ...
(1 2 #(224 224 224) 3)
#;1>
address@hidden examples]$ csc reader2.scm
address@hidden examples]$ ./reader2
(1 2 %e0e0e0 3)


Any hint on why it is so and how to fix that?

            Michele Simionato




reply via email to

[Prev in Thread] Current Thread [Next in Thread]