Leonardo Boiko | 29 Jul 17:32
Picon

write-object from write vs. from display

Hi.  According to gauche manual,

     When `write' and `display' encounter an object of a user-defined
     class, they call the generic function `write-object'.

The same generic is called for both methods? How do I make my objects
react differently to 'write' and 'display'?

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Shiro Kawai | 29 Jul 23:10

Re: write-object from write vs. from display

Right now there's no way to distinguish them.  
I've been planning to replace the object write protocol to passing
around context information (including write/display distinction).

--shiro

From: "Leonardo Boiko" <leoboiko <at> gmail.com>
Subject: [Gauche-devel] write-object from write vs. from display
Date: Tue, 29 Jul 2008 12:33:04 -0300

> Hi.  According to gauche manual,
> 
>      When `write' and `display' encounter an object of a user-defined
>      class, they call the generic function `write-object'.
> 
> The same generic is called for both methods? How do I make my objects
> react differently to 'write' and 'display'?

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Leonardo Boiko | 29 Jul 23:16
Picon

Re: write-object from write vs. from display

On Tue, Jul 29, 2008 at 6:10 PM, Shiro Kawai <shiro <at> lava.net> wrote:
> Right now there's no way to distinguish them.
> I've been planning to replace the object write protocol to passing
> around context information (including write/display distinction).

That's a bit over my level… If I just patched in a display-object
method (defaulting to write-object) and made display use it, would you
accept? =)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gauche-devel mailing list
Gauche-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gauche-devel
Shiro Kawai | 30 Jul 00:02

Re: write-object from write vs. from display

From: "Leonardo Boiko" <leoboiko <at> gmail.com>
Subject: Re: [Gauche-devel] write-object from write vs. from display
Date: Tue, 29 Jul 2008 18:16:24 -0300

> On Tue, Jul 29, 2008 at 6:10 PM, Shiro Kawai <shiro <at> lava.net> wrote:
> > Right now there's no way to distinguish them.
> > I've been planning to replace the object write protocol to passing
> > around context information (including write/display distinction).
> 
> That's a bit over my level… If I just patched in a display-object
> method (defaulting to write-object) and made display use it, would you
> accept? =)

The bottom problem is that the current write-object API is broken;
it's not only about write/display distinction.  There's another
special circumstances when write-object is called, one of which is
the 'walk' stage of write/ss and format/ss (I omit lengthy
explanation here, but the point is that currently I use nasty duct-
taping to hide this case, which may break in some edge cases).
Realizing generic pretty-printer also requires the context information.

I've been thinking how to support this context problem without
changing the current API drastically.  I think the best way, from
the user's point of view, is using dynamic parameters.  Since
you brought up the topic, it may be a good time to hammer out
the concrete implementation.

How about this.  In your write-object method you can call write-mode
procedure that returns a symbol indicating which mode it is called.

(Continue reading)

Leonardo Boiko | 30 Jul 00:57
Picon

Re: write-object from write vs. from display

Thanks for the attention Shiro, I'll wait more then to see how it will
turn out then.  I'm serializing the objects of my game's world with
write-object plus srfi10 read-time constructors (via a simple generic
printer/constructor for arbitrary gauche classes; dunno if someone
tried this already?) — so far I didn't notice any problems, but then
I'm not using shared/nested structures.

2008/7/29 Shiro Kawai <shiro <at> lava.net>:
> How about this.  In your write-object method you can call write-mode
> procedure that returns a symbol indicating which mode it is called.
>
>  (write-mode) => a symbol

I still don't get it; will the user ever need to set the write-mode?
If not, wouldn't it be simpler to just make write-object receive two
arguments, the object and the write-mode?
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gauche-devel mailing list
Gauche-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gauche-devel
Shiro Kawai | 2 Aug 05:36

Re: write-object from write vs. from display

From: "Leonardo Boiko" <leoboiko <at> gmail.com>
Subject: Re: [Gauche-devel] write-object from write vs. from display
Date: Tue, 29 Jul 2008 19:57:25 -0300

> 2008/7/29 Shiro Kawai <shiro <at> lava.net>:
> > How about this.  In your write-object method you can call write-mode
> > procedure that returns a symbol indicating which mode it is called.
> >
> >  (write-mode) => a symbol
> 
> I still don't get it; will the user ever need to set the write-mode?
> If not, wouldn't it be simpler to just make write-object receive two
> arguments, the object and the write-mode?

That was the original plan.  The problem is this: It is quite
common to call 'format' from write-object, but there's no way
to pass the mode info to 'format'.

(define-method write-object ((obj <my-object>) port mode)
  (format port "...." ...))

We can add a new function, say 'format/mode' and 'format/ss/mode',
that takes extra mode argument.  But we can't save the existing
write-object methods that are using standard 'format'---it means
for any recursive structure, we can't rely on the mode argument to 
propagate down.  With the parameter approach, we don't need to
worry about propagation part.

--shiro

(Continue reading)


Gmane