develooper Front page | | Postings from September 2000

RFC 247 (v1) pack/unpack C-like enhancements

Perl6 RFC Librarian
September 17, 2000 22:37
RFC 247 (v1) pack/unpack C-like enhancements
Message ID:
This and other RFCs are available on the web at

=head1 TITLE

pack/unpack C-like enhancements

=head1 VERSION

  Maintainer: Ilya Zakharevich <>
  Date: 16 September 2000
  Mailing List:
  Number: 247
  Version: 1
  Status: Developing


This RFC proposes C-like syntactic sugar to templates of pack/unpack.


An alternative style of type specifiers is allowed in pack()/unpack()
TEMPLATEs.  This style is used in the parts of the TEMPLATE enclosed
in braces, as in C<'{ C_STYLE_TEMPLATE }'>.  Optionally, if TEMPLATE
starts with C<'struct {'> (with possible intervening whitespace and comments)
C<struct> is ignored.

When this style is in scope, then 

=over 8

=item *

the counts of the form C<32> are prohibited, use C<[32]> instead;

=item *

C<struct {TEMPLATE}> should be used instead of C<(TEMPLATE)> for grouping;

=item *

instead of one-char type specifiers, the corresponding C-like specifiers
C<int>/C<char>/C<short>/C<long>/C<long long> should be used.  They may be
preceeded by C<unsigned>/C<signed>/C<native>/C<little-endian>/C<big-endian>,
(C<native> being the default).  The type C<string> should be used instead
of C<a>, with modifiers C<byte>/C<utf8> if needed.

C<ignore> may be used to replace C<'x'>. C<aligh(LEN)> may be used as a
prefix to replace C<'x!LEN'>;

=item *

C<I8>/C<I16>/C<I32>/C<U8>/C<U16>/C<U32> can be used too;

=item *

C9X syntax C<int_8> (sp?) etc. can be used too;

=item *

C<[]> should be used instead of C<*>, as in C<'{ int[4]; short[] }'>;

=item *

if a type is put inside C<[]>, it should start with C<sizeof>, as
in C<'{ string[ sizeof long ] }'> which is equivalent to C<a[L]>.







RFC 142: Enhanced Pack/Unpack

RFC 246: pack/unpack uncontrovercial enhancements Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About