* #:printer filed in language specification.
@ 2021-09-17 22:50 Justin Veilleux
2021-09-18 14:47 ` Maxime Devos
0 siblings, 1 reply; 6+ messages in thread
From: Justin Veilleux @ 2021-09-17 22:50 UTC (permalink / raw)
To: guile-user
Hello, everyone.
To familiarize myself with guile's compiler tower, I implemented a
lambda calculus interpreter using guile.
It works relatively well. However, I also wanted it to print a human
readable version of the procedures created. (It is hard to tell whether
#<procedure 1e39a38 (s)> is a correct church encoding of the number 3)
With a lot of fiddling, I managed to write a function that turns a
procedure into an S-expression.
However, when I tell guile to use it as a pretty printer using the
#:printer keyword, the repl doesn't actually use it. What can I do to
fix this ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: #:printer filed in language specification.
2021-09-17 22:50 #:printer filed in language specification Justin Veilleux
@ 2021-09-18 14:47 ` Maxime Devos
2021-09-18 15:24 ` Justin Veilleux
2021-09-19 12:11 ` Zelphir Kaltstahl
0 siblings, 2 replies; 6+ messages in thread
From: Maxime Devos @ 2021-09-18 14:47 UTC (permalink / raw)
To: Justin Veilleux, guile-user
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
Justin Veilleux schreef op vr 17-09-2021 om 18:50 [-0400]:
> It works relatively well. However, I also wanted it to print a human
> readable version of the procedures created. (It is hard to tell whether
> #<procedure 1e39a38 (s)> is a correct church encoding of the number 3)
> With a lot of fiddling, I managed to write a function that turns a
> procedure into an S-expression.
The #:printer is only used by things like "guild compile -o ..." I think.
One option is to create ‘applicable structs’ (unfortunately they aren't
documented), setting the procedure to the actual procedure, and the record
printer (set-record-type-printer!) to something printing the S-exp of the
applicable struct.
Greetings,
Maxime
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: #:printer filed in language specification.
2021-09-18 14:47 ` Maxime Devos
@ 2021-09-18 15:24 ` Justin Veilleux
2021-09-19 12:11 ` Zelphir Kaltstahl
1 sibling, 0 replies; 6+ messages in thread
From: Justin Veilleux @ 2021-09-18 15:24 UTC (permalink / raw)
To: Maxime Devos, guile-user
Thanks a lot.
On September 18, 2021 10:47:56 a.m. EDT, Maxime Devos <maximedevos@telenet.be> wrote:
>Justin Veilleux schreef op vr 17-09-2021 om 18:50 [-0400]:
>> It works relatively well. However, I also wanted it to print a human
>> readable version of the procedures created. (It is hard to tell whether
>> #<procedure 1e39a38 (s)> is a correct church encoding of the number 3)
>> With a lot of fiddling, I managed to write a function that turns a
>> procedure into an S-expression.
>
>The #:printer is only used by things like "guild compile -o ..." I think.
>
>One option is to create ‘applicable structs’ (unfortunately they aren't
>documented), setting the procedure to the actual procedure, and the record
>printer (set-record-type-printer!) to something printing the S-exp of the
>applicable struct.
>
>Greetings,
>Maxime
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: #:printer filed in language specification.
2021-09-18 14:47 ` Maxime Devos
2021-09-18 15:24 ` Justin Veilleux
@ 2021-09-19 12:11 ` Zelphir Kaltstahl
2021-09-19 12:24 ` Maxime Devos
1 sibling, 1 reply; 6+ messages in thread
From: Zelphir Kaltstahl @ 2021-09-19 12:11 UTC (permalink / raw)
To: Maxime Devos; +Cc: Guile User
Hi Maxim!
Do you know of any simple example anywhere for applicable structs? I might have
another use for them.
Regards,
Zelphir
On 9/18/21 4:47 PM, Maxime Devos wrote:
> Justin Veilleux schreef op vr 17-09-2021 om 18:50 [-0400]:
>> It works relatively well. However, I also wanted it to print a human
>> readable version of the procedures created. (It is hard to tell whether
>> #<procedure 1e39a38 (s)> is a correct church encoding of the number 3)
>> With a lot of fiddling, I managed to write a function that turns a
>> procedure into an S-expression.
> The #:printer is only used by things like "guild compile -o ..." I think.
>
> One option is to create ‘applicable structs’ (unfortunately they aren't
> documented), setting the procedure to the actual procedure, and the record
> printer (set-record-type-printer!) to something printing the S-exp of the
> applicable struct.
>
> Greetings,
> Maxime
--
repositories: https://notabug.org/ZelphirKaltstahl
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: #:printer filed in language specification.
2021-09-19 12:11 ` Zelphir Kaltstahl
@ 2021-09-19 12:24 ` Maxime Devos
2021-09-20 8:04 ` Zelphir Kaltstahl
0 siblings, 1 reply; 6+ messages in thread
From: Maxime Devos @ 2021-09-19 12:24 UTC (permalink / raw)
To: Zelphir Kaltstahl; +Cc: Guile User
[-- Attachment #1: Type: text/plain, Size: 938 bytes --]
Zelphir Kaltstahl schreef op zo 19-09-2021 om 12:11 [+0000]:
> Hi Maxim!
>
> Do you know of any simple example anywhere for applicable structs? I might have
> another use for them.
From NEWS in the Guile source code:
** Applicable struct support
One may now make structs from Scheme that may be applied as procedures.
To do so, make a struct whose vtable is `<applicable-struct-vtable>'.
That struct will be the vtable of your applicable structs; instances of
that new struct are assumed to have the procedure in their first slot.
`<applicable-struct-vtable>' is like Common Lisp's
`funcallable-standard-class'. Likewise there is
`<applicable-struct-with-setter-vtable>', which looks for the setter in
the second slot. This needs to be better documented.
For a not-very-simple example, see modules/oop/gooops.scm in Guile's source code.
I don't know any simple examples.
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: #:printer filed in language specification.
2021-09-19 12:24 ` Maxime Devos
@ 2021-09-20 8:04 ` Zelphir Kaltstahl
0 siblings, 0 replies; 6+ messages in thread
From: Zelphir Kaltstahl @ 2021-09-20 8:04 UTC (permalink / raw)
To: Maxime Devos; +Cc: Guile User
Hi Maxim!
Thank you for your reply!
I do not know how to create such a vtable, what it means to have a vtalbe which
is `<applicable-struct-vtable>` or how to set it for a struct, but I should have
a look at the manual and see, what comes up when searching for vtable.
Regards,
Zelphir
On 9/19/21 2:24 PM, Maxime Devos wrote:
> Zelphir Kaltstahl schreef op zo 19-09-2021 om 12:11 [+0000]:
>> Hi Maxim!
>>
>> Do you know of any simple example anywhere for applicable structs? I might have
>> another use for them.
> From NEWS in the Guile source code:
>
> ** Applicable struct support
>
> One may now make structs from Scheme that may be applied as procedures.
> To do so, make a struct whose vtable is `<applicable-struct-vtable>'.
> That struct will be the vtable of your applicable structs; instances of
> that new struct are assumed to have the procedure in their first slot.
> `<applicable-struct-vtable>' is like Common Lisp's
> `funcallable-standard-class'. Likewise there is
> `<applicable-struct-with-setter-vtable>', which looks for the setter in
> the second slot. This needs to be better documented.
>
> For a not-very-simple example, see modules/oop/gooops.scm in Guile's source code.
> I don't know any simple examples.
>
> Greetings,
> Maxime.
--
repositories: https://notabug.org/ZelphirKaltstahl
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-20 8:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 22:50 #:printer filed in language specification Justin Veilleux
2021-09-18 14:47 ` Maxime Devos
2021-09-18 15:24 ` Justin Veilleux
2021-09-19 12:11 ` Zelphir Kaltstahl
2021-09-19 12:24 ` Maxime Devos
2021-09-20 8:04 ` Zelphir Kaltstahl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).