develooper Front page | perl.perl5.porters | Postings from October 2001

Re: Clamp, wherefor art thou

Thread Previous | Thread Next
From:
Jeffrey Friedl
Date:
October 30, 2001 13:22
Subject:
Re: Clamp, wherefor art thou
Message ID:
200110301852.f9UIqbK74833@ventrue.corp.yahoo.com

Nick Ing-Simmons wrote:
|> I think that allowed (but not existing) entries in HV could be represented
|> by having an HE but with its SV * being Nullsv - or perhaps a pointer
|> to a "special" SV

In the patch I submitted, Pl_sv_undef is used (as per Tim's suggestion
when the thread appeared before). It's a very clean approach.

|> I don't think special casing "scalar keys" is necessary - the allowed keys
|> are counted so the existing count in the header is fine.

I suppose that there's no real "right" answer to this, but it makes sense to
me to have "scalar keys" return the same number as items you get back with
an array "keys". With Tim's suggestion, it's implemented w/o additional
storage overhead, and no real computational overhead[*]

Once it's in the core, you can export it to the user however you like,
providing ways to get the number of keys there, allowed, existing, etc...

|> What I really do not like is the 'Clamp' name - it does not suggest to me
|> anything vaguely like the proposed semantics.

With the core-only patch, it allows people to export the functionality as
they wish. I'm sure that as people play with it and see what others do, a
clear winner will emerge that will probably be better than anything I/we
could design "by committee".

      Jeffrey


[*]The way the counts are implemented in the patch I just submitted is
fairly light weight (one extra integer increment per hash element addition
or subtraction), but I just thought of a way that it could be done with no
overhead for those operations in the normal (non-clamp) case. I'll either
make the change to the next patch, or make an incremental patch if the
previous one gets applied......

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