Re: [code-review] Tie::Array::Bounded

Xavier Noria <[email protected]> Sat, 22 Nov 2003 14:35:01 +0100
Newsgroups gmane.comp.lang.perl.code-review-ladder
Message-ID <[email protected]>
On dissabte, nov 22, 2003, at 11:40 Europe/Madrid, Elizabeth Mattijsen 
wrote:

> At 08:39 +0100 11/21/03, Xavier Noria wrote:
>> On divendres, nov 21, 2003, at 08:07 Europe/Madrid, Peter Scott wrote:
>>> I've created my first module intended for CPAN, at 
>>> http://www.psdt.com/Tie-Array-Bounded-0.01.tar.gz pending review 
>>> from folks here.  It allows the user to specify upper (and, for 
>>> completeness' sake, lower) bounds on array indices, and throws 
>>> exceptions on violations.
>> The name is confusig to me. From that name I would expect to get tied 
>> arrays whose _values_ have to be in a certain range.
>
> I think that would have to be Tie::Scalar::Bounded.  Why limit 
> yourself to bounded values in arrays only?  Why not in scalars also. 
> And as hash values?

Tie::Scalar::Bounded, Tie::Array::Bounded, and Tie::Hash::Bounded could 
perfectly coexist in CPAN, suggesting one doesn't say anything about 
the convenience of the others.

I would expect scalars tied to Tie::Scalar::Bounded to live in some 
range (for some definition of range chosen by the author). My point was 
that the name Tie::Array::Bounded suggests constraints about allowed 
values to me, not about allowed indexes. Similarly, I would expect 
hashes tied to Tie::Hash::Bounded to control their values as well, not 
their keys.

Theoretically one could mimic Tie::Array::Bounded (interpretated that 
way) using normal arrays and scalars tied to Tie::Scalar::Bounded for 
values. But, you know, in practice both approaches are not the same.

-- fxn