[plt-scheme] Default string and byte string representation

From: Jakub Piotr Cłapa (jpc-ml at zenburn.net)
Date: Wed Dec 17 19:22:30 EST 2008

Matthew Flatt wrote:
> At Wed, 17 Dec 2008 13:05:18 +0100, Jakub Piotr Cłapa wrote:
>> Why does Scheme defaults to using octal notation in (byte)string escape 
>> codes?
> Only byte strings print with octal. Strings print with \u escapes,
> right?

Yeah, sure. ;-)

> Octal is used for byte strings mostly because octal was always used for
> byte strings. It does have two minor redeeming qualities: a nul byte
> prints relatively compactly as \0 (unless followed by a digit), and
> UTF-8 encodings of non-ASCII characters show up as \3oo \2oo ...
> sequences (while encodings of ASCII characters never print as \2oo or
> \3oo).

I see. So it's probably a tradeoff between visual-greping utf-8 text 
versus random binary encoded data. I prefer the hex notation since I am 
often doing the latter (since I use Scheme to interface some hardware; 
USB & Modbus stuff).

>> AFAICT more people are familiar with hexadecimal than octal so maybe 
>> defaulting to "\xFF" escapes (which are handled correctly on input) 
>> would be better? Or maybe a parameter to set that?
> I'm reluctant to change the default, because the reward seems low given
> the risk of breaking something. But we could add a parameter.

A parameter would be excelent for my needs.

Jakub Piotr Cłapa

Posted on the users mailing list.