-
Notifications
You must be signed in to change notification settings - Fork 292
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
Talk about collections rather than containers #3980
Conversation
In Raku parlance, a container generally refers to a scalar container. Arrays and hashes are mutable _collections_ that store values in scalar containers. To avoid confusion it's better to refer to these composite types as collections.
Not really. A container in Raku is generally called "variable" somewhere else; it tries to distinguish the content, a value, from what contains it, which is also an object by and of itself. In general, I would appreciate a previous issue to arrive to a consensus on this kind of things. However, I'll take a look at the PR because it's probably more straightforward than that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great clarificaton. You might want to address the nits before merging, anyhow.
doc/Type/independent-routines.pod6
Outdated
|
||
Calls method C<pop> on the C<Positional> container. That method is supposed to | ||
Calls method C<pop> on the C<Positional> collection. That method is supposed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alt: positional "argument" or "collection passed as a positional argument"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is a bit tricky. We have a positional argument that should do the Positional
role. How about "the @collection
passed as a positional argument"?
This b.t.w. illustrates why I prefer parameter name @collection
instead of @a
, because I don't think there's as much meaning in the phrase "the @a
passed as a positional argument".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a Positional
argument. It's a Positional
argument that's also a positional argument. There's a tongue-twister for you 😸
doc/Type/independent-routines.pod6
Outdated
@@ -1213,14 +1213,14 @@ for an example. | |||
|
|||
Defined as: | |||
|
|||
multi sub shift(@container) is raw | |||
multi sub shift(@collection) is raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is simply defined as
As long as we're changing it, the best is to just use the original, as is the default policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your review of PR #3973 you still agreed that it was better to use more meaningful parameter names.
I don't mind changing the parameter name if you now think that @a
is better after all, because the @
sigil probably adds enough meaning. But as an aside, I think that Rakudo should not restrict the argument to Positional
as non-Positional
collection types may implement a shift
method too. And I don't think that \a
would be meaningful enough.
So should I change the parameter to @a
or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem, again, is unambiguously making something that is really better. "Collection" is implicit in the sigil, for instance. And that's also correct, it's not positional, it's "thing-with-shift". I seem to remember I opened an issue somewhere about that, to create more atomic roles. Anyway, to the point, it's really up to you. I really appreciate the effort for improving the documentation you've put in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of more atomic roles. Then, for example, we could document that the "Shiftable" role has a stub
method shift(Shiftable:D:)
and change the subroutine form to something like
multi sub shift(Shiftable:D \object)
which will probably give us a more awesome error message when attempting to shift
something that is not shiftable.
Maybe we could even combine such roles into more complex ones, like:
role Stacky does Pushable does Poppable {}
role Queuey does Pushable does Shiftable {}
so we can have a
class Array does Stacky does Queuey ...
showing what an Array
can be used for.
doc/Type/independent-routines.pod6
Outdated
@@ -1235,17 +1235,17 @@ say shift @a; # ERROR: «Cannot shift from an empty Array[Int]» | |||
|
|||
Defined as: | |||
|
|||
multi sub push(\container, **@values is raw) | |||
multi sub push(\container, \arg) | |||
multi sub push(\collection, **@values is raw) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here. It uses \a as an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case using \a
instead of \collection
would really make the signature less meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's what it is. If we want to get really picky about it, it's \object_can_push
. Which is why in the absence of a consensus, it's really the best to stick to the source. But, again, your call. We at least agree that the original \container
was not a good idea.
Fwiw I'd love to see introduction of the word "collections" as a generic term covering lists and hashes. I've seen it used to mean this in a lot of other PLs.
That may be where we've ended up, and I may have contributed to that, but I think it's unfortunate and that it's wise to move toward using the word container strictly to mean
I'm with you on the need for consensus but would say a PR like this one is a classic healthy way to get to that. By "like this" I mean one that's simple, small, done well, and with a humble attitude, all of which I think apply here.
Indeed. Your follow ups are notably sweet, and I thank you for your continued careful stewardship of the doc. I love this shift. :) |
Well... on the pure terminological side, a collection might include anything that's not "atomic". Would Junctions be collections? Hashmaps? On the low-level side, however, it breaks down to "thing-with-a-push", "thint-with-a-shift" and so on an so forth. Is an
Well, if I had to steer it towards something, I'd go for something "meta". A container is a meta-object, because it adds structure and metadata (roles, HOWs) to single values.
As I have commented, the PR is great work. The underlying issue, however, would probably need an, er, different issue. Think that what we're discussing here will be lost when merged.
👍 |
In these cases it's probably not so bad to have less meaningful parameter names because these subroutines just implement indirection.
Then we should probably rename Rakudo's array_operators.pm6 to collection_operators.pm6 (or collection_operators.rakumod). I can change the heading in the independent routines documentation from "Array manipulation" to "Collection operators" already, if we agree that is a better name. |
Er... No renaming, please. Again, implies loss of incoming links. Creating a new one that would point to all included concepts would be OK. |
I searched for "Array_manipulation" in the whole project and found nothing, so I don't think there are any links inside the project. I created the heading not so long ago so I doubt there are incoming links from other resources. |
The principle is still the same. Pages disappear from search engines, lose their ranking. We aren't even fond of losing fragments in URLs. There's an alternative, which I'm not fond of, because it implies ops, that's returning a redirect. Also, let me remind you we're not agreed either in what's a collection, or if we should call it that way. Please open an issue and we'll discuss terminology, and what to do about it either. |
Okay, I'll keep that change out of this PR. Please let me know if you agree with the changes in my second commit. |
Like the proverbial credit card, it was already pre-approved. I really appreciate the effort you have put into accommodating my nits. |
Yeah, I got carried away with excitement at @dumarchie having a go, and have already inappropriately over-simplified. Some things I think we can agree on are the goodness of the desire to improve things, and of @dumarchie's intent and writing skills, and of the need for patient discussion and nuanced thinking about the conceptual, terminological, and practical complications (don't break links!) related to what are really a fundamentally thorny and intertwined mess of conundrums.
I'll mostly postpone my further commentary about the term "collections" for now. The issue is, as you've said, complicated.
I would be quite unhappy to see us use what is already a precisely defined and scary term ("meta-object") to mean anything other than what it currently does in Raku. It's just a scarier name for a Perhaps consistently using the specific term "
Yeah. I've written this comment fully aware that it's plausible that, at most, only you and/or @dumarchie will read it. Also, no need to reply. I'm really just thinking out loud... |
In Raku parlance, a container generally refers to a scalar container.
Arrays and hashes are mutable collections that store values in scalar
containers. To avoid confusion it's better to refer to these composite
types as collections.