chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] symbol->string


From: Sven . Hartrumpf
Subject: Re: [Chicken-users] symbol->string
Date: Mon, 23 Oct 2006 11:22:31 +0200 (CEST)

Hello Thomas.

> If you want alphabetic ordering, you should avoid symbol->string, because
> it copies the name of the symbol to a new string -- this is necessary as
> Scheme's strings are mutable objects!

With some exceptions, like ... symbol->string :-)
"It is an error to apply mutation procedures like string-set! to
strings returned by this procedure."
from
<www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_sec_6.3.3>

> I would suggest accessing the name
> slot of the symbol directly and defining
>
>     (define (symbol-compare a b)
>       (##sys#check-symbol a 'symbol-compare)
>       (##sys#check-symbol b 'symbol-compare)
>       (string-compare (##sys#slot a 1) (##sys#slot b 1)))
>
> I hope that helps,

Thanks, I will test it now.
Sven

Attachment: pgpQWiaeR0x7A.pgp
Description: PGP signature


reply via email to

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