-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delete! semantics for vector vs. set #3023
Comments
How about |
Sounds good to me.
|
Since we probably want the same function for vectors and hashes, this needs a little more thought. Maybe deletekey!? |
|
The semantics are also different. After removing a key |
Good point about the rather different semantics. This is all part of the final collections API bikeshedding push we need to do. |
Stefan and I decided we will rename
|
In other words, the default value of the third argument to |
We could also support variants where the indices to remove/replace are non-contiguous, although that would obviously be more complicated to implement, but that's kind of why it's useful to have, actually. |
Actually, scratch that since when the range isn't contiguous it's ambiguous where to put the replacement values. |
While I can see the problem highlighted here, I'm wondering if there is a better fix than the one committed? One of the things I like about julia is that it combines performance with enough common sense that most things are intuitive and just work. I think this change goes against that. |
I agree with Kevin that this is a non-intuitive change of names. -- John On May 31, 2013, at 8:36 PM, Kevin Squire notifications@github.com wrote:
|
I'd agree with @kmsquire that there should be a more intuitive and searchable name for ''splice!'' when two arguments are used. |
The cool part is that |
I actually like those names for the array-modifying interface--they're familiar and intuitive. (Reminds me of the debate between unix and perl philosophies...) |
I don't think I'd actually remove all of them; for one thing, manipulating a single item (as in It looks like the only other name idea out there is |
From the original issue:
While having vectors partially implement set functions might seem useful, perhaps that is the real issue here. When I'm using an array, I'm not expecting to be able to intersect it with another array. Why not remove the set functionality from vectors (what functionality is this?), and require users to wrap them in sets (or simply use) sets if they want set functionality.
@mlubin, can you elaborate on what the bigger problem is here? Even with the current fix, |
The bigger problem was exactly that delete meant different things for vectors and sets while vectors are sometimes used as sets. |
The |
I understand the point about semantics of (On the other hand, having separate names for these makes an array-based implementation of Cheers! |
One possibility is only allowing set operations on |
@StefanKarpinski: Wouldn't it still be very useful to provide a two argument version of |
Yes, that would make sense and would work. It's a bit weird that the two-argument version can take any enumeration of indices whereas the three argument version can only take a range. It feels kind of strange. |
I guess that an alternative would be to leave |
There's an issue with the overloaded use of
delete!
to mean removing both a particular index from a vector and a particular element from a set: vectors partially implement set functions, and some set functions return vectors. See below.This particular case would be fixed by implementing
union(s::IntSet,sets::IntSet...)
to return anIntSet
, but I think the problem is a bit bigger than this.The text was updated successfully, but these errors were encountered: