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

Re: [PATCH 5.005_62] First round of unpack

Thread Previous | Thread Next
Ilya Zakharevich
November 11, 1999 12:10
Re: [PATCH 5.005_62] First round of unpack
Message ID:
On Thu, Nov 11, 1999 at 11:56:15AM -0500, John Porter wrote:
> In <>,
> Ilya Zakharevich <> 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

  ')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,

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About