[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] symbol->string
From: |
F. Wittenberger |
Subject: |
[Chicken-users] symbol->string |
Date: |
Wed, 10 Dec 2008 12:59:57 +0100 |
Hi all,
my reading of R5RS allows symbol->string to be implemented more
efficiently - though not as safe:
"""
procedure: (symbol->string symbol)
Returns the name of symbol as a string. ... It is an error to apply
mutation procedures like string-set! to strings returned by this
procedure.
"""
I'm reading: "it is ok to return some interned string, which, when
mutated will cause all sorts of harm to the Scheme system, but if the
implementer chooses to return a fresh copy each time and keep the Scheme
running, it's ok too".
In other words: the source shows: chicken goes the safe path here.
(In case of qualified symbols, it's worse: the string is copied twice
and one copy always discarded.)
But that might be costly! I have a lots of cases, where the result of
string->symbol is used and, since I've been careful about the above
cited sentence from R5RS, none which mutate the resulting string.
Hence I tried.
In my case the following definition (in the lowest level module of my
app) gains me a factor of two in runtime!!
(global-set! 'symbol->string
(lambda (s)
(##sys#check-symbol s 'symbol->string)
(##sys#symbol->string s)))
YMMV however.
Best regards
/Jörg
- [Chicken-users] symbol->string,
F. Wittenberger <=