develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [PATCH 5.005_62] First round of unpack

Thread Previous | Thread Next
From:
Ilya Zakharevich
Date:
November 11, 1999 12:10
Subject:
Re: [PATCH 5.005_62] First round of unpack
Message ID:
19991111151026.A14612@monk.mps.ohio-state.edu
On Thu, Nov 11, 1999 at 11:56:15AM -0500, John Porter wrote:
> In <19991102214104.A74@monk.mps.ohio-state.edu>,
> Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> > How one would
> > write a "universal" unmarshaller?  Obviously, one needs to store
> > unmarshalling instructions together with stringified data.
> > 
> > This leads to unpack 't' which I wrote.
> 
> I would like to see this (New Year's wish):
> 
> # -- on the sending side:
> 
>   $msg = pack 't', \&foo;
> 
> # -- on the receiving side:
> 
>   sub foo;
>   ( *foo ) = unpack 't', $msg;

I do not think such complicated functionality belongs to the "builtin"
pack.  When serialization of globs and subs becomes feasible, one can
design a hook for pack to serialize these things.  'unpack' already
has such hooks: it can call an arbitrary function for postprocessing
of the unpacked data.

So the hook for 'pack' might store a string combined with the extraction
template 

  ')T2/3A6 do_sub'

This template says that the following packed string should be extracted
as with C<unpack 't'>, then should be given as argument to do_sub($whatever).

Hope this helps,
Ilya

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About