chicken-hackers
[Top][All Lists]
Advanced

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

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


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

(Sorry, Jim, resending because I hit "reply" instead of "reply all" like I meant.)

On Thu, Sep 2, 2010 at 6:31 PM, Jim Ursetto <address@hidden> wrote:
On Thu, Sep 2, 2010 at 17:15, Jim Ursetto <address@hidden> wrote:
> It looks like we can avoid this by not importing string-tokenize from srfi-13,
> e.g. (import (except srfi-13 string-tokenize)).  If someone can confirm
> this is the right solution, I'll commit the change.

Eh, I fixed it.

I just updated and can confirm that it works now.  Thanks!

Is that expected behaviour then, if you replace an imported binding inside a module, even if you don't re-export it?  A quick check shows that doing it at the REPL at least produces a warning, but when using the fmt egg no warning was emitted.

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

#;1> (module foo (one) (import scheme chicken) (define (one) 1))
#;2> (module bar (three) (import scheme chicken foo) (define (one) 2) (define (three) 3))

Note: redefinition of imported value binding: one

Note: assignment to imported value binding: one
#;3> (module quux (test) (import scheme chicken foo bar) (define (test) (list (one) (three))))
#;4> (import quux)
#;5> (test)
(2 3)


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


And I just figured out, that even if I redefine something like string-tokenize (which I thought may be slightly different from the above because of how or where string-tokenize is defined) in the REPL I get a warning:

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


#;1> (module foo (one) (import scheme chicken srfi-13) (define (one) 1) (define (string-tokenize) #f))
; loading /opt/chicken/lib/chicken/5/srfi-13.import.so ...

Note: redefinition of imported value binding: string-tokenize

Note: assignment to imported value binding: string-tokenize
#;2> (import foo)
#;3> (string-tokenize)
#f

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


But if I put that into a file and compile it, there's no warning.  After playing a bit more, it seems like that's what happens in general; there is no warning for bindings redefined in compiled code when you load it:

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

;; bar.scm

(module foo
  (one)
  (import scheme chicken)
  (define (one) 1))

(module bar
  (three)
  (import scheme chicken foo)
  (define (one) 2)
  (define (three) 3))

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


#;1> (load "bar.scm")
; loading bar.scm ...
; loading /opt/chicken/lib/chicken/5/scheme.import.so ...
; loading /opt/chicken/lib/chicken/5/chicken.import.so ...

Note: redefinition of imported value binding: one

Note: assignment to imported value binding: one
#;2>

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

#;1> (load "bar.so")
; loading bar.so ...
; loading /opt/chicken/lib/chicken/5/scheme.import.so ...
; loading /opt/chicken/lib/chicken/5/chicken.import.so ...
#;2>

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


So that's the difference with the warnings at least.  If one worked exclusively with compiled code while writing a module, it seems like it would not be too difficult to accidentally redefine something critical and potentially affect everything that uses your module.

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

reply via email to

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