[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

RE: exists $foo[7] and delete $foo[7]



From: Jarkko Hietaniemi [mailto:jhi@iki.fi]
> 
> I vote for NOT extending delete() and exists() to work on array
> elements.  I fail to see the usefulness of the feature.  Exposing the
> internal implementation is irrelevant and I dare say too confusing.
> That "delete $a[12]" should leave the element in a different state
> than "undef $a[12]" sounds like too much fun to try to explain.  Well,
> yes, the element is in different internal state.  But *what for*,
> externally?  What would this feature give to the programmer?  (And as
> Tom pointed out, the terms "uninitialized" and "undefined" have been
> used interchangeably in the past.)

I'm against too, based on the various comments made so far. Making
pseudo-hashes feature-complete is one thing (exists/delete should work on
them, as on normal hashes). But this is not a reason for implementing new
functionality on arrays.

From Sarathy's comments, I get the impression that the two aspects are/were
independent. It is possible to support exists/delete on pseudo-hashes,
without that support "leaking" into the array interface. This is what I
believe should be implemented.

> I also will step forth and say that I find the current Perl-level
> interface to pseudohashes most vile and think it should not get out
> alive to 5.6.  The concept as such is okay, but that $a[0] is elevated
> to a special role, stinks really bad.  I'd rather see, say,
> a pragma interface.

Agreed again. I haven't said anything so far as I have had no need for
pseudo-hashes, so my opinion is uninformed at best. But the "pseudo-ness" is
a pure implementation issue on a hash interface. It should be possible to
transparently drop in a better implementation in a new Perl version (eg,
"real" named array elements) with no Perl-level visible difference. This is
not true of the current situation. Effectively, I am arguing that once
creation is over, there should be no way in Perl (modulo Devel::Peek and the
like) to determine whether %x is a hash or a pseudo-hash. And probably not
via XS use of published APIs either...

Of course, this is what Topaz is aiming for...

Paul.


[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]