[r6rs-discuss] Re: [Formal] formal comment (ports, characters, strings, Unicode)

Per Bothner per at bothner.com
Mon Mar 19 13:21:02 EDT 2007


Thomas Lord wrote:
> Why can't I write a procedure that, say, reverses a string-like
> value which can be either a BUCKY-STRING or a STRING
> and which is a strictly portable procedure using just the core
> functionality for strings?

Because there is no such thing as "portably reversing a string".
The semantics of doing so depends on what you consider the
"character units", which depends not only on language but also
on context.

The way to do it is with some kind of matcher/parser that
gets "the next character", extracts the corresponding sub-string,
and then concatenates the substrings in reverse order.

I.e. even this artificial (i.e. non-real-world puzzle-only) use-case
should be solved using string operations, rather than character
operations.
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the r6rs-discuss mailing list