develooper Front page | perl.perl5.porters | Postings from May 2004

RFC: proposed extension of unpack

Thread Next
From:
perl5-porters
Date:
May 21, 2004 08:24
Subject:
RFC: proposed extension of unpack
Message ID:
c8l6st$sn8$1@post.home.lunix
On perlmonks I just noticed
http://www.perlmonks.com/index.pl?node_id=355284, which indeed seems
you can't currently do with plain unpack and seems useful.

So i thought it would be nice to have:
 "return current absolute position counted from the start of the string"

At first look I thought that @ would be nice for this, but it already
does something useful, namely moving to a given position and continue
unpacking there.

However, it's actually not documented what it does if you don't give it
a numeric argument (the section on repeat counts defines the @ behaviour
only for n and *). In that case it seems to go to fixed offset 1
(1 being the logical default for the repeaters of course), which doesn't
seem particularly useful and can easily be done by using @1, and
probably *IS* done that way by all existing code, so it would probably
break no existing code to make @ without followup number in unpack
return a position (and if something does break, well, they were using
an undocumented feature...)

The returned offset would be relative to the innermost () to keep it
consistent. You probably wouldn't want to use an absolute position
modifier inside a () anyways, so it doesn't really seem to lose
anything.

Opinions ?

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