Front page | perl.perl5.porters |
Postings from November 2008
Re: [perl #969] [PATCH] Draft: shifting of bitvecs considered broken
Thread Previous
|
Thread Next
From:
Rafael Garcia-Suarez
Date:
November 17, 2008 03:43
Subject:
Re: [perl #969] [PATCH] Draft: shifting of bitvecs considered broken
Message ID:
b77c1dce0811170343i3a31fd44u5ae7aaad88b2572f@mail.gmail.com
2008/11/17 Chip Salzenberg <chip@pobox.com>:
> On Mon, Nov 17, 2008 at 09:36:07AM +0100, Rafael Garcia-Suarez wrote:
>> 2008/11/14 Chip Salzenberg via RT <perlbug-comment@perl.org>:
>> > How about adding leftshift() and rightshift() as functions in a standard
>> > bitvec.pm, rather than fiddling with the meaning of >> and << ?
>>
>> Except the obligatory bikeshedding session on the new module name,
>> (which I like, by the way), I think that's a good idea.
>
> Well ... does it count as bikeshedding if it's your own module? Here's a
> first cut at the 'vec' module. Please don't commit it just yet, it needs
> review. So ... review, please? (including the module name, I suppose)
I expect this one will need to be dual-lived. At which point occurs the
question, is it really needed in the core...
Some minor nits:
> =item insert_low_bits STRING, COUNT
>
> Accept a bitvector STRING, a la L<vec>, and an integral bit COUNT. Return a
à la L<perlfunc/vec>
(same link to be fixed in vec.pm)
> new bitvector that is a copy of the original STRING but with COUNT zero bits
> inserted at the low end of the vector; that is, at the front of the string.
> COUNT must be nonnegative.
>
> =item remove_low_bits STRING, COUNT
>
> Accept a bitvector STRING, a la L<vec>, and an integral bit COUNT. Return a
> new bitvector that is a copy of the original STRING but with COUNT bits
> removed from the low end of the vector; that is, from the front of the
> string.
What about "shift" and "unshift" instead of insert and remove ?
> diff --git a/ext/vec/Makefile.PL b/ext/vec/Makefile.PL
> new file mode 100644
> index 0000000..ff8910a
> --- /dev/null
> +++ b/ext/vec/Makefile.PL
> @@ -0,0 +1,7 @@
> +use ExtUtils::MakeMaker;
> +
> +WriteMakefile(
> + VERSION_FROM => "vec.pm",
> + NAME => "vec",
> + OPTIMIZE => '-g',
Add to that C<MAN3PODS => {}> (to avoid converting the manpage needlessly)
if $ENV{PERL_CORE} is true.
> diff --git a/ext/vec/t/vec.t b/ext/vec/t/vec.t
> new file mode 100644
> index 0000000..57a21b2
> --- /dev/null
> +++ b/ext/vec/t/vec.t
Maybe add some tests with strings flagged as utf8 ? Just to be sure it
won't break ?
> diff --git a/ext/vec/vec.xs b/ext/vec/vec.xs
> new file mode 100644
> index 0000000..41d45e8
> --- /dev/null
> +++ b/ext/vec/vec.xs
> @@ -0,0 +1,83 @@
> +/* Copyright (c) 2008 Graham Barr <chip@pobox.com>. All rights reserved.
You're Graham Barr in disguise ? :)
Thread Previous
|
Thread Next