develooper Front page | perl.bootstrap | Postings from July 2000

Re: perl 6 requirements

Buddha Buck
July 31, 2000 12:19
Re: perl 6 requirements
Message ID:
At 02:40 PM 7/31/00 -0400, Ted Ashton wrote:

>   P'raps you've not run across it, but there are situations where one is 
> given
>a datastructure created by another language (in my case, usually through being
>handed a file with records built by a certain structure).  I have to unpack
>those records, deal with the data, and likely pack up the data as a fixed-size
>record to ship on to the next (non-Perl) thing.  If I could define a data
>structure with fixed sizes and just say, "put the data in this space, 
>here," it
>would save my unpack and pack.

I want to comment on this, but I can't... it would be off-topic.  When will 
the perl6-language list be created?

OK, now I will comment on it...

The pack/unpack has to happen at sometime.  Perhaps what would work would 
be to create a module or core type that would remember its pack 
format.  Ideally, when used in a scalar context, it would look like its 
packed representation; when in a hash context, like its unpacked 
representation.  Something like:

# game message data consists of objectID; position x,y,z; orientation
# ux,uy,uz (up direction) and nx,ny,nz (nose direction), velocity
# vx,vy,vz, and acceleration ax,ay,az all as 32-bit integers in network
# byte order (packet size: 512B).  Object ID of 0 means update complete.
# $packet pre-defined to have a pack format of "NNNNNNNNNNNNNNNN"
   sysread SERVER, $packet, 512;
   last if $packet{'objectID'} == 0;
   $remoteobject[$packet{'objectID'}] = { %packet };

Is that sort of what you'd like? Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About