[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Copying hashes



In article <20000201013158.A196328@linguist.dartmouth.edu>,
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>On Mon, Jan 31, 2000 at 11:40:11PM -0500, Andrew Pimlott wrote:
>> On Mon, Jan 31, 2000 at 11:01:16PM -0500, Jeff Pinyan wrote:
>> > You can get this kind of override by doing this (although it's damn slow):
>> > 
>> >   %hash = (%values_get_overridden, %hash);
>> >   %hash = (%hash, %values_override_hash);
>> 
>> Of course, but if those %'s were @'s, you'd say, "No, silly!  That's
>> what unshift and push are for!".  I want to be able to say the same
>> thing for hashes.

Graham Barr did a patch for this about a year ago (see the Jan'99 thread
"hash concatenation" on comp.lang.perl.moderated).  It doesn't seem to
have gotten in.
>
>And if those were @'s, then the data structures would be inherently
>ordered, contiguous, and indexed numerically.
>
>> You may be able to optimize your examples under the hood, but I would
>> find this optimization highly unintuitive.  Is there currently any list
>> context in which arrays or hashes are magically not expanded?
>
>It does not matter whether the optimization is intuitive or not.  The
>optimization is completely hidden from the user; there is no need to intuit
>it.  The behavior would be the same as it always has been.

Despite apparent support for such an optimization, it doesn't seem to have
been done.  Assuming %hash = 1..2000, try timing %hash = %hash, 1..6 vs.
@hash{1,3,5} = (2,4,6).  With an optimization they should be close to the
same;  without, there is a difference of a few orders of magnitude.
>
>> PS.  I support delete and exists on arrays ;)
>
>P.S.  I support file test operators on regular expressions.

You're missing the subtext here.  delete and exist on arrays will be
in 5.5.64 (and presumably in 5.6).  This raised quite a ruckus on p5p
even after Larry Wall blessed it and indicated no further discussion
was needed.

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe