develooper Front page | perl.perl5.porters | Postings from August 2012

Re: RFC: pack()ing long words

Thread Previous | Thread Next
From:
David Cantrell
Date:
August 13, 2012 10:16
Subject:
Re: RFC: pack()ing long words
Message ID:
20120813171609.GA6193@bytemark.barnyard.co.uk
On Mon, Aug 13, 2012 at 01:51:03PM +0200, H.Merijn Brand wrote:

> Counterintuitive in that order
> 
> l4 is 4 longs, so if the 4 in your example matches the 4 in l4, I'd
> guess that
> 
>   X5>4
> 
> would be more intuitive

But then you have a problem if someone wants native endian-ness - you
can't tell whether X54 is a single word of 54 bytes, or four words of
five bytes each.

Leon's suggestion of putting the word length in {curlies} works nicely.

> I kinda like your approach though. What about bits? Why restrict to
> multiple of 8 bits?

Hmmm ... and just have X{40}4 instead of X{5}4 for a five byte
(== 40 bits) word.  I haven't looked at the source (and am somewhat
terrified to do so TBH) but I can see that getting a bit tricky.  If you
consume just three bits with X3, does the next template thingy, and all
the ones after it, have to start and stop half way through a byte?
Yuck.

Maybe that's something to allow for in the syntax, but leave the
implementation until even later.

-- 
David Cantrell | Bourgeois reactionary pig

Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt

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