At 03:36 PM 12/18/2001 -0500, Melvin Smith wrote:

>Dan writes:
> >*) Filehandles get treated like arrays. Filters (which will be plain
> >coderefs) can be push/pop/shift/unshift/spliced onto them.
>
>By coderef I'm assuming you mean something like this Perl pseudo code...
>
>sub filter_dos_newlines {
>      my $pmc = shift;
>      my $op = shift;
>
>      if( $op >= 0 && $op < MAX_IO_FUN ) {
>           &{$myfilter_vtable[$op]}( \$pmc->data );
>      }
>
>      return $pmc;
>}

Yup, something like that, I think. Probably with a ($data, Int $op) 
signature or something, but that's niggly detail.

> >*) Filters get passed a PMC and an int. The int is a function number
> >(1=read, 2=write, 3=seek, 4=tell, 5=control, or something like that) and
> >the PMC represents the source data. They return a mutated PMC that's
>passed
> >on to the next filter.
>
>Sounds like layers except with layers layer[i] is chained with layer[i+1]
>and calls it directly.

I'd rather the various filters be able to act as if they were standalone. 
That's why they don't call each other. (Though we could do tail calls if 
the did. Hrmph. I'll think on that)

> >I'd like the whole filter chain to run in its own interpreter, but that
> >means the filters can't ultimately return objects and things like that,
> >which is sort of bad.
>
>I'll let you think on that.

'Kay, here's the thought. Exactly one filter may be (optionally) marked as 
an interpreter terminal filter. It runs in the context of the interpreter 
that made the I/O request, and gets (or returns) a real PMC. All the other 
filters run in the context of a separate interpreter, and while they can 
also pass PMCs between each other, communication between the terminal 
filter and the source filter interpreter is via a non-reallocable string. 
(Yes, the string buffer is static. We can cope... :)

So if a non-terminal filter returns a PMC, it works OK until we talk to the 
calling interpreter, in which case it gets the stringified version of that 
PMC. If it's a reference, well, say Hi to "Foo(0xdeadbeef)" :)

I think that makes sense. I might be wrong, but I think so. Good enough?

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to