[gambit-list] Bug
Christian Jaeger
christian at pflanze.mine.nu
Sat May 12 05:55:53 EDT 2007
Marc Feeley wrote:
> Another way to avoid name clashes is to use Gambit's "namespace"
> declaration.
Sure. That's what I've been meaning to tell Brad Lucier: don't misuse
the namespacing feature (by using the ## namespace) as decoration for
unsafe function names. Use e.g. @ instead. Example:
(##namespace ("foo#"))
(define (@string-copy! s1 start1 s2 start2 len)
(let lp ((i 0))
(if (##fixnum.>= i len)
s1
(begin
(##string-set! s1 (##fixnum.+ start1 i)
(##string-ref s2 (##fixnum.+ start2 i)))
(lp (##fixnum.+ i 1))))))
(##namespace (""))
(foo#@string-copy! a b c d)
;; (Or put @string-copy! into the "" or whatever namespace or use snow
(or use chjmodule until I've looked into merging with snow))
The @ is my visual indicator that a function does not check the type (or
sometimes also the lengths) of it's arguments. It is visually somewhat
similar to ##, but doesn't interfere with namespacing.
Christian.
(PS. I've recently referred to "namespaces" using the colon, in the
context of SXML templates, example |xhtml:p|; I consider it best to use
colons for user visible namespacing, and only use the # based
namespacing behind the scence for package separation. This allows
flexibility: import some html handling package with a "user-namespace"
prefix like |xhtml:| into package foo, |xhtml:p| is then actually
|foo#xhtml:p| there, and distinct from someone else writing a bar
package who imports some other html handling package providing |p| as
|bar#xhtml:p|. (Well in the example I mention from lately those were not
actually bindings, but just syntax handled by the custom expander, but I
hope the idea gets through.))
More information about the Gambit-list
mailing list