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

Re: [Scheme-reports] fresh empty strings



Alaric Snell-Pym scripsit:

> Bringing it back to reality, however, I think it's fine and good for eq?
> of strings to be defined as it is. Two references to the same string
> should probably be eq? - (let ((a str) (b str)) (eq? a b)) - so that
> they're useful in hash tables,

Indeed.  (let ((a x) (b x)) (eq? a b)) is always true, except where x is
a character or number.

> but two references to strings with the
> same content should be left undefined to give implementations scope for
> implementing strings as in-memory objects, yet still being able to
> implement them as immediates or merging known identical strings together
> or whatever: (let ((a "hello") (b "hello") (eq? a b)) should not be
> defined by the standard.

Racket, Gauche, MIT, Gambit, Chicken, Bigloo, SISC, Chibi, Chez, SCM,
Ikarus/Vicare, Mosh, KSi, SigScheme, Tinyscheme, Scheme 9, Dream, Scheme 7,
BDC, XLisp, Rep, Schemik, Elk, UMB, Oaklisp, and Owl Lisp all return false.
Scheme48/scsh, Guile, Kawa, Larceny, Ypsilon, IronScheme, NexJ, STklos,
Shoe, RScheme, JScheme, VX return true.  There may be some false negatives
here, because an implementation might coalesce literals in the compiler
but not at the REPL.

I was quite surprised by how many implementations take the trouble to
return true.

> And, of course, "undefined" doesn't mean it has to return some unique
> "undefined value"! Just that the implementation gets to choose.

Naturally.

-- 
John Cowan    http://ccil.org/~cowan    cowan@x
Economists were put on this planet to make astrologers look good.
        --Leo McGarry

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports