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

Re: explicit quoting/unquoting of strings



If Scheme had a standard notion of string ports, then except for the
state part, these conversions could be implemented easily with string
ports, `write', and `read'. (For the state part of `string-unquote',
it seems like you really want a stream and `read', anyway.)

My personal opinion --- which, as always, not an opinion from the
editors --- is that string ports should be added to Scheme, and
functions like this should be left to another library.

Matthew

At Tue, 12 Jul 2005 11:58:18 +0200, Sebastian Egner wrote:
> The SRFI specifies an escape mechanism for expressing strings in a
> reduced character set (Section "Quoted strings").
> 
> It would substantially increase portability and convenience if the quoting
> and unquoting mechanism is also made available explicitly to application
> programs---for example through procedures like this:
> 
> (string-quote str)
>         produces a representation of string str in the reduced set of 
> characters
>         <<specify here>> by introducing backslash escape sequences.
>         The result is a newly allocated string s satisfying
>                 (string=? (string-unquote s) str)
> 
> (string-unquote str [ state ] ) -> str' state'
>         interprets backslash escape sequences in string str and constructs 
> the
>         string being represented.
>             The optional argument state, and the second return value 
> state',
>         represent the state of the interpreter (a finite state machine) 
> before and
>         after processing str. By passing the state from one invokation of
>         string-unquote to the next, it is possible to unquote arbitrary 
> substrings
>         of a stream of characters---even if the stream is broken within 
> escape
>         sequences. The state #f (default for state) is the start state 
> (taking letters
>         etc. at face value.) Other states are <<specify?; need to know?; 
> ints?>>.
> 
> ----
> Dr. Sebastian Egner
> Senior Scientist
> Philips Research Laboratories
> Prof. Holstlaan 4 (WDC 1-051, 1st floor, room 51)
> 5656 AA Eindhoven
> The Netherlands
> tel:       +31 40 27-43166
> fax:      +31 40 27-44004
> email: sebastian.egner@xxxxxxxxxxx