chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] string-tokenize and fmt; maybe a module question


From: Taylor Venable
Subject: [Chicken-hackers] string-tokenize and fmt; maybe a module question
Date: Thu, 2 Sep 2010 17:31:51 -0400

Hi there, Chicken wranglers!  Earlier I was writing a program using the fmt egg and ran into a surprising problem: using it replaces the string-tokenize function from srfi-13 with an incompatible version, seemingly even if I didn't ask for it.  Here's an example using the REPL:

============================================================

> csi -n

CHICKEN
(c)2008-2010 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.5.7
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2010-08-12 on zareason (Linux)

#;1> (use srfi-13 srfi-14)
; loading library srfi-13 ...
#;2> (string-tokenize "GT1.2.1" (char-set-complement (char-set #\.)))
("GT1" "2" "1")
#;3> (use fmt)
; loading /opt/chicken/lib/chicken/5/fmt.import.so ...
; loading /opt/chicken/lib/chicken/5/scheme.import.so ...
; loading /opt/chicken/lib/chicken/5/chicken.import.so ...
; loading /opt/chicken/lib/chicken/5/ports.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-1.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-13.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-69.import.so ...
; loading /opt/chicken/lib/chicken/5/foreign.import.so ...
; loading /opt/chicken/lib/chicken/5/extras.import.so ...
; loading /opt/chicken/lib/chicken/5/data-structures.import.so ...
; loading /opt/chicken/lib/chicken/5/fmt.so ...
#;4> (string-tokenize "GT1.2.1" (char-set-complement (char-set #\.)))

Error: bad argument count - received 2 but expected 1: #<procedure>

        Call history:

        <syntax>          (string-tokenize "GT1.2.1" (char-set-complement (char-set #\.)))
        <syntax>          (char-set-complement (char-set #\.))
        <syntax>          (char-set #\.)
        <eval>    [#f] (string-tokenize "GT1.2.1" (char-set-complement (char-set #\.)))
        <eval>    [#f] (char-set-complement (char-set #\.))
        <eval>    [#f] (char-set #\.)   <--

==========
==================================================

Even more surprising to me was how it has the same problem if I try to rename it like so:

============================================================

;; test.scm

(module test
  (foo)

  (import scheme chicken)
  (require-library fmt)
  (import srfi-14)
  (import (rename srfi-13 (string-tokenize tokenize)))
  (import fmt)

  (define (foo)
    (tokenize "GT1.2.1" (char-set-complement (char-set #\.)))))

> csi -n

CHICKEN
(c)2008-2010 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.5.7
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2010-08-12 on zareason (Linux)

#;1> (load "test.scm")
; loading test.scm ...
; loading /opt/chicken/lib/chicken/5/scheme.import.so ...
; loading /opt/chicken/lib/chicken/5/chicken.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-14.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-13.import.so ...
; loading /opt/chicken/lib/chicken/5/fmt.import.so ...
; loading /opt/chicken/lib/chicken/5/ports.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-1.import.so ...
; loading /opt/chicken/lib/chicken/5/srfi-69.import.so ...
; loading /opt/chicken/lib/chicken/5/foreign.import.so ...
; loading /opt/chicken/lib/chicken/5/extras.import.so ...
; loading /opt/chicken/lib/chicken/5/data-structures.import.so ...
; loading /opt/chicken/lib/chicken/5/fmt.so ...
#;2> (import test)
#;3> (foo)

Error: bad argument count - received 2 but expected 1: #<procedure>

        Call history:

        <syntax>          (foo)
        <eval>    [#f] (foo)
        <eval>    [foo] (tokenize "GT1.2.1" (char-set-complement (char-set #\.)))
        <eval>    [foo] (char-set-complement (char-set #\.))
        <eval>    [foo] (char-set #\.)  <--

============================================================

I brought this up on #chicken but couldn't figure out why it was happening, if it was maybe the way the fmt egg works or perhaps a bug somewhere.  It seems as if the fmt egg's definition of string-tokenize shouldn't be able to leak outside the fmt module.  Or my reasoning about modules could be flawed as well.  I've been able to work around it in the intermediary (using string-split instead) but I'd still be interested in knowing why this happens, in case I should face it again.  I'm using version 0.703 of the fmt egg.  Thanks for any insight.

--
Taylor C. Venable
http://metasyntax.net/

reply via email to

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