"Brent Dax" <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED]:
> # I was wondering how perl6 would stringify (as in Data::Dumper):
> 
> As Dan said, that's serialization.  I don't know if Perl will support
> that built-in.  But if it does...
> 
> #     1) objects with 'my' and 'our' variables
> 
> Those would have to be dumped from the pads or stashes.  I don't think
> there's any way around that.

The semantics of this are unclear.  Say I have (sorry if the syntax is
wrong)

  {
    my $t;
    my ($x,$y) = (-> { ++$t }, -> { $t-- });
  }

(The intent is I can use C<$x.()> and C<$y.()> to count backwards and
forwards).


Now, if I say C<print FH serialize($x,$y)> (assume suitable encoding,
delimiting, etc.; I'm not asking about those), I'd expect to get a
copy of C<$x> and C<$y>, and they should share the same C<$t>.  Right?


What does the list C<($x.serialize(), $y.serialize)> give me?  Given
that there's no way to know that both serializations will end up going
to the same file, they have to give me the equivalent of

  {
    my $t;
    my $x = -> { ++$t };
  }
  {
    my $t;
    my $y = -> { $t-- };
  }

So we've broken the meaning of the code (and serialization can't just
be a UNIVERSAL method, we have to be able to call it as a function on
a list).  Is this a Good Thing?  (Can we Do Better???)


OK, so now say I'm reading the original (C<serialize($x,$y)>).  And I
do it twice.  Following the previous logic, I get 2 copies of C<$t>,
one for each reading.  This might make sense, or it might not.


How do I read "half" of C<serialize($x,$y)>?  (That is, can I get just
C<$x>?)  The easy answer is to say I can't.  This creates an
uncomfortable situation.  Every time I want to serialize a bunch of
closures, I have to serialize all of them in one go.  And I have to
deserialize them all if I want to access any bit of them.  What do I
do if I have 10_000 copies of some huge bunch, and I want to access
just one bit of it?  Seems like I have to deserialize everything --
even though I<for this case> we could be doing a lot better!


I guess I just don't understand how serializing closures is supposed
to work.

[...]

-- 
Ariel Scolnicov        |http://3w.compugen.co.il/~ariels
Compugen Ltd.          |[EMAIL PROTECTED]    "Sometimes people write an
72 Pinhas Rosen St.    |Tel: +972-3-7658117       accidental haiku.  Damn!
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555       It just happened!"

Reply via email to