On Mon, 23 Oct 2006, [EMAIL PROTECTED] wrote:

[...] I looked at the definition of symbol->string and found out that it is not a constant operation (like returning some pointer) but constructs a string. Does anyone have a more efficient comparison of symbols implemented? [...]

Hello,

as far as I know, symbols with identical names are always pointer equal in CHICKEN unless one of them has been created using gensym, so if you just need equality comparisons, eq? will be the fastest option.

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! 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,
Thomas


_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to