Re: [Scheme-reports] Write procedure is not backwards compatible
Jonathan Rees
(01 Jul 2012 21:26 UTC)
|
Re: [Scheme-reports] Write procedure is not backwards compatible
Jonathan Rees
(01 Jul 2012 21:55 UTC)
|
Re: [Scheme-reports] Write procedure is not backwards compatible
John Cowan
(02 Jul 2012 00:18 UTC)
|
Re: [Scheme-reports] Write procedure is not backwards compatible
Alex Shinn
(01 Jul 2012 22:05 UTC)
|
Re: [Scheme-reports] Write procedure is not backwards compatible
Aaron W. Hsu
(01 Jul 2012 22:57 UTC)
|
Re: [Scheme-reports] Write procedure is not backwards compatible
Marc Feeley
(02 Jul 2012 13:15 UTC)
|
Re: [Scheme-reports] Write procedure is not backwards compatible Alex Shinn (02 Jul 2012 14:32 UTC)
|
On Mon, Jul 2, 2012 at 10:14 PM, Marc Feeley <feeley@iro.umontreal.ca> wrote: > > On 2012-07-01, at 6:57 PM, Aaron W. Hsu wrote: > >> Jonathan Rees <jar@mumble.net> wrote: >> >>> Ouch! If true, I second this comment. Backward compatibility >>> for write is pretty important. Consider the case of running >>> an R5RS (or R7RS) program in an R7RS implementation to generate >>> a file that will be consumed by an R5RS implementation. >>> >>> There is no mention of this incompatibility in the section >>> "Language changes since R5RS". >> >> Marc Feeley wrote: >> >>> Formal Comment >>> >>> Submitter's name: Marc Feeley >>> Submitter's email: feeley at iro.umontreal.ca >>> >>> Summary: Write procedure is not backwards compatible >>> >>> R7RS introduces a new output procedure called write-simple, which has >>> the same semantics as the R5RS write procedure. On the other hand, >>> the R7RS write procedure handles shared structures differently than >>> the R5RS. For example : >>> >>> (let ((x (list 1 2))) (write (list x x))) >>> >>> displays ((1 2) (1 2)) in an R5RS system >>> and displays (#0=(1 2) #0#) in an R7RS system >> >> People are reading this wrong. The intention here is that WRITE >> properly handle circular structures that cannot be printed in >> fully expanded form without infinite output. That is to say, the >> above interpretation of write is incorrect, IIRC. We do not >> guarantee the same shared structure layout of a written structure, >> but provide a means of serializing circular structures that >> cannot be serialized with WRITE-SIMPLE. >> >> This was not added to the R5RS list of incompatibilities because it >> is not incompatible. Any defined output of R5RS in this case, >> dealing with normal, non-self referential (circular) structures, >> should end up the same way; it is circular structures whose contents >> refer to itself that will be specified now, where they were not, >> to my understanding, in R5RS. >> >> If the standard is not clear on this, we should fix this, as this is >> not an issue of whether we should swap WRITE-SIMPLE with WRITE, but >> one of clearly indicating what should use the circular structure >> formatting. > > That's not what I understood. > > By the way, I'd like to see how this is implemented. I tried the latest Chibi Scheme, which is meant to be more or less a reference implementation for R7RS, and it gives an infinite loop on: > > (write (let ((x (cons 1 2))) (set-cdr! x x) x)) To get R7RS in Chibi you need to write an R7RS program, e.g. beginning with (import (scheme base)) although write was moved so you need to (import (scheme write)) as well for this example. As a shortcut you can run "chibi-scheme -xscheme.base", or you can use the extended repl: (import (chibi repl)) (repl) @import-only (scheme base) which allows ^C interrupts in case you do write an infinite loop (note you want latest dev to use (chibi repl)). (chibi repl) uses the R7RS write by default so you don't actually need to import anything else. This is documented more thoroughly in the manual. -- Alex _______________________________________________ Scheme-reports mailing list Scheme-reports@scheme-reports.org http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports