Discussion:
[Chicken-users] pp and write ignore keyword-style
Sven Hartrumpf
2018-11-20 21:51:55 UTC
Permalink
Hi.

pp and write (in chicken 5) do not respect the parameter (keyword-style);
Only display respects keyword-style.

#;1> (import (chicken pretty-print))
; loading /usr/local/chicken-5.0.0-x32/lib/chicken/9/chicken.pretty-print.import.so ...
#;2> (keyword-style)
#:suffix
#;3> (write '(arg1: 1))
(#:arg1 1)#;4> (pp '(arg1: 1))
(#:arg1 1)
#;5> (display '(arg1: 1))
(arg1: 1)#;6>

Ciao
Sven
John Cowan
2018-11-20 21:56:59 UTC
Permalink
IMO, `write` should not respect `keyword-style` but use the invariant
syntax `#:foo` for keywords, as that always works, whereas `foo:`
and `:foo` don't. The whole point of `write` is that you can reread
the output with `read` and get something that is the same (in the
sense of `equal?`) to what was written, modulo unwritable objects.
Post by Sven Hartrumpf
Hi.
pp and write (in chicken 5) do not respect the parameter (keyword-style);
Only display respects keyword-style.
#;1> (import (chicken pretty-print))
; loading /usr/local/chicken-5.0.0-x32/lib/chicken/9/
chicken.pretty-print.import.so ...
#;2> (keyword-style)
#:suffix
#;3> (write '(arg1: 1))
(#:arg1 1)#;4> (pp '(arg1: 1))
(#:arg1 1)
#;5> (display '(arg1: 1))
(arg1: 1)#;6>
Ciao
Sven
_______________________________________________
Chicken-users mailing list
https://lists.nongnu.org/mailman/listinfo/chicken-users
Sven Hartrumpf
2018-11-21 06:34:58 UTC
Permalink
Post by John Cowan
IMO, `write` should not respect `keyword-style` but use the invariant
syntax `#:foo` for keywords, as that always works, whereas `foo:`
and `:foo` don't. The whole point of `write` is that you can reread
the output with `read` and get something that is the same (in the
sense of `equal?`) to what was written, modulo unwritable objects.
I see.
But my argument is about interoperability between implementations, e.g.
reading with Scheme implementation A code written by Scheme implementation B.
Many Schemes only support SRFI-88 keywords (arg1: , #:suffix).

Is there any Chicken function that can write code in this way?
('display' won't help here because of strings etc.)
If not, I would suggest a new parameter pretty-print-keyword-style for
the module (chicken pretty-print).

Ciao
Sven
Post by John Cowan
Post by Sven Hartrumpf
Hi.
pp and write (in chicken 5) do not respect the parameter (keyword-style);
Only display respects keyword-style.
#;1> (import (chicken pretty-print))
; loading /usr/local/chicken-5.0.0-x32/lib/chicken/9/
chicken.pretty-print.import.so ...
#;2> (keyword-style)
#:suffix
#;3> (write '(arg1: 1))
(#:arg1 1)#;4> (pp '(arg1: 1))
(#:arg1 1)
#;5> (display '(arg1: 1))
(arg1: 1)#;6>
Ciao
Sven
_______________________________________________
Chicken-users mailing list
https://lists.nongnu.org/mailman/listinfo/chicken-users
John Cowan
2018-11-21 16:05:30 UTC
Permalink
On Wed, Nov 21, 2018 at 1:35 AM Sven Hartrumpf <***@gmx.net> wrote:

But my argument is about interoperability between implementations, e.g.
Post by Sven Hartrumpf
reading with Scheme implementation A code written by Scheme implementation B.
I fear that is a lost cause. Of 22 Schemes that I tested, only 8 support
keywords at all. (Racket has something it calls keywords, but they are not
self-evaluating or even expressions at all: only quoted keywords are
expressions. They use SRFI 88 syntax.)

Each of the :foo and foo: styles are supported by most of the 9, whereas
the SRFI-88 style was supported by only 4. See
https://bitbucket.org/cowan/r7rs-wg1-infra/src/default/KeywordSyntax.md for
details
--
John Cowan http://vrici.lojban.org/~cowan ***@ccil.org
Business before pleasure, if not too bloomering long before.
--Nicholas van Rijn
Marc Feeley
2018-11-21 17:01:51 UTC
Permalink
Each of the :foo and foo: styles are supported by most of the 9, whereas the SRFI-88 style was supported by only 4. See https://bitbucket.org/cowan/r7rs-wg1-infra/src/default/KeywordSyntax.md for details
For your information, the last line of that page

“If we adopt the #:foo style, Chicken, Bigloo, Guile, S7, Kawa and to some extent Racket will work out of the box.”

is incorrect concerning Bigloo that only supports the :foo and foo: syntax.

So in fact the foo: syntax is the most widely supported (by 7 implementations).

Also, the #:foo syntax is used by Gambit for uninterned symbols (probably other implementations too because I remember taking that syntax from another Scheme implementation but I don’t remember which).

Marc

Evan Hanson
2018-11-20 22:13:52 UTC
Permalink
Hi Sven,
Post by Sven Hartrumpf
pp and write (in chicken 5) do not respect the parameter (keyword-style);
Only display respects keyword-style.
This behaviour is intentional, for the reasons John describes.

Refer to ticket #1332 for specifics about the change:

https://bugs.call-cc.org/ticket/1332

Cheers,

Evan
Loading...