in reply to Re^7: Using exists to check element in array
in thread Using exists to check element in array

> exists isn't consistent.

No exists is/was consistent, keys ARRAY came later and is inconsistent.

It doesn't make any sense that a $x[9]=1 on an empty array will make keys return 10 indices. And right after delete $x[9] keys will return none.

DB<6> x @x empty array DB<7> $x[9]=1 DB<8> p keys @x 0123456789 DB<9> delete $x[9] DB<10> p keys @x DB<11>

> Next you'll say that scalar(@a) and scalar(%h) are inconsistent!

No not next, I already said that scalar @array is inconsistent.

I keep saying that all of this depends on the definition of exists and that orthogonality to hashes was respected.

You keep insisting that your definition of exists is the only possible one.

And you still haven't shown any code were delete and exists alone produce different results on arrays than on hashes.

Even more your example with the reference is consistent for both.

And keys ARRAY is obviously troubled.

Actually what's happening here is that two inconsistent concepts were interwoven.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^9: Using exists to check element in array
by ikegami (Patriarch) on Feb 04, 2024 at 03:39 UTC

    You keep insisting that your definition of exists is the only possible one.

    Don't lie about what I've done. I've been purposefully avoiding the word "exists" since my first post to avoid this very issue. I've only been saying exists is inconsistent, and I showed that it does something different for hashes and arrays using both code and illustrations.

    Actually what's happening here is that two inconsistent concepts were interwoven.

    Or at least people could conflate two concepts. And that's why there's a warning.