[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Wed, 10 Dec 2008 12:59:57 +0100
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
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!!
(##sys#check-symbol s 'symbol->string)
- [Chicken-users] symbol->string,
F. Wittenberger <=