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
.exists and .delete are internal methods and should be renamed #56
Comments
|
[13:32:39] #56 .exists and .delete are internal methods and should be renamed |
|
If .exists and .delete continue to exist as non-internal methods, then they should be specced. |
|
+1 to exists_key and delete_key |
http://perlcabal.org/syn/S32/Containers.html#exists Pm |
|
There is no spec for .exists / .delete on hashes. |
|
I suspect the absence of .exists / .delete on hashes in S32 is more accidental than intentional, it could be added quickly enough. I concur with jnthn and masak and others that .exists and .delete should remain, or at least not disappear for a long while. The implementation of adverbs was slushy and complicated enough (in both STD and Rakudo) that the method forms were the only mechanism available for programmers to use. I find the analogy with .at_pos and .at_key to be somewhat telling. In some sense they're "internal methods", but they're not internal in the sense that they're really the preferred way for someone to implement a new indexable aggregate type. Properly overloading I agree with TimToady that the method forms may need some changes to deal with LoL arguments... but I think this is another area where spec will have to follow implementation, not precede it. Pm |
|
Then I propose I spec .exists and .delete to always only be able to handle a single key, and that they're mainly intended for internal use only. For both arrays and hashes. And finish this discussion once and for all. |
|
Specced Hash.exists and Hash.delete in 9b6b82a |
I propose to rename .exists to .exists_at_key, and .delete to .delete_at_key, because they are really internal methods, not to be used in non-system oriented code. I propose I will do the work for this. This will be done in the following steps:
*wait one month
Do the same in parallel for .delete.
Part of a recent dialogue.
http://irclog.perlgeek.de/perl6/2013-06-20#i_7226826
18:21 TimToady I don't mind something like .exists and .delete as internal methods, but they're more in the category of at_key and at_pos, not something that should be used much in Userland
18:22 so maybe a rename to exists_at_key and such
18:22 masak TimToady: this will break a lot of code.
18:22 masak a lot of code.
18:22 TimToady but all of those internals are subject to renegotiation as soon as S09 starts getting implemented
18:22 :exists is supposed to be S09-proof
18:23 we can't guarantee that for .exists
18:23 not without an explicit mapping of multidimensional args to single dimensional...
18:24 TimToady we know we have subscripts, and we know that we want to delete and test existence using subscript notation; the rest is still unspecced
18:26 TimToady what does this turn into: my Things @things[3,3,]; @things[1;2;$min..$max]:delete
18:27 TimToady er, my Things @things[3;3;]; @things[1;2;$min..$max]:delete
18:27 TimToady s'posed to use ; consistently...
18:28 TimToady currently .exists only knows about single keys, afaik
18:29 TimToady we'd need a .exists that knows about LoLs, where each sublist can be lazy
18:29 the :exists form is more straightforward as soon as you get out of single dimensions
18:53 lizmat TimToady: I like the .exists_at_key idea, since .exists currently is really an at_key cut short
18:54 TimToady but again, what's a "key" look like when you add slicing and multidimensionality?
18:55 * TimToady isn't sure
18:55 lizmat If necessary, I can do this rename of .exists internally + test-suite
18:56 I agree with your argument about S09, :exists is the way to do this, as it will easily allow you to specify on which slice you want things to be applied
18:57 .exists should only handle a single key (as in perl 5), and to make it an "internal" method, rename it to ".exists_at_key"
The text was updated successfully, but these errors were encountered: