Skip to content
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

Unify differences between multi and multi sub #1189

Open
trosel opened this issue Feb 11, 2017 · 19 comments
Open

Unify differences between multi and multi sub #1189

trosel opened this issue Feb 11, 2017 · 19 comments
Labels
docs Documentation issue (primary issue type) meta RFCs, general discussion, writing style, repository organization, etc. wishlist "nice to have" issues; might require a lot of work or a big change or be low priority xt Regarding current or new xt/ tests or the utils/

Comments

@trosel
Copy link
Contributor

trosel commented Feb 11, 2017

Some code is like:

multi sub hello($name) {say "hi $name"}

Other code is like:

multi hello($name) {say "hi $name"}

I'm not sure what is going on here, but this is something that should be decided upon. I think multi sub makes sense because you always clarify multi method in classes. And yet, I've never seen a proto sub. I've only seen proto by itself.

Thoughts?

@zoffixznet
Copy link
Contributor

It defaults to sub, so you can omit it. In core, though, we always add it anyway. Makes it easier to grep 'sub blah' the source.

@Altai-man
Copy link
Member

Judging by

> grep -I -r 'multi sub ' doc/ | wc -l
278
> grep -I -r 'multi [^sm]' doc/ | wc -l
50

plain multi case is less common. For the reasons of consistency we can edit such cases to full form. It is quite easy job too, if you have a good editor and some time on board.

@trosel
Copy link
Contributor Author

trosel commented Feb 11, 2017

I think consistency in the docs is a worthwhile goal

@coke coke added the docs Documentation issue (primary issue type) label Feb 11, 2017
@gfldex
Copy link
Contributor

gfldex commented Feb 12, 2017

I do not agree. You don't learn how to deal with complexity by reading code that does it's best to hide it. If we prefer one style we should prefer the shorter version because lazyness is a programmers virtue.

@trosel
Copy link
Contributor Author

trosel commented Feb 12, 2017

@gfldex Whether the docs show multi sub or just multi, I still think consistency should be the goal.

Programmers can learn complexity by reading real world code / books / tutorials. The docs should feel as if they're all written by one person, no? Hence unifying the comment styles, etc.

@awwaiid
Copy link
Contributor

awwaiid commented Feb 12, 2017

So how about unifying on multi alone, only using multi sub long-hand when explaining that it is long-hand.

@trosel trosel added the meta RFCs, general discussion, writing style, repository organization, etc. label Feb 13, 2017
@trosel
Copy link
Contributor Author

trosel commented Mar 4, 2017

I just read in the docs that one reason why --> is preferred over returns is for consistency in the docs.

So someone at some time deemed consistency in documentation worthwhile. Whoever wrote that 😸

@Altai-man
Copy link
Member

@WildYorkies, you can read #1024 (comment) - it explains the choosing of "-->" and there are more reasons: It is more universal(you can use it for constant values) and there are no plans about deprecation, TimToady likes it, etc. The consistency made only one thing in that issue: the issue was opened because of that.

If the docs don't clearly say about possible deprecation and constant values, it is bad. Though, I take a peek now and as for me, it is still explained.

About this issue itself. I'm agreeing with @awwaiid, we can use multi, though it is slightly more work to do.
I don't think that "it is easier to grep" is a nice reason to do otherwise. I mean, why the feature of omitting was added in the first place, if nobody uses it because of greping?

@coke coke added the xt Regarding current or new xt/ tests or the utils/ label Aug 26, 2017
@coke
Copy link
Collaborator

coke commented Aug 26, 2017

What about examples that are contrasting sub vs. method, e.g.:

    multi sub    shift(Array:D )
    multi method shift(Array:D:)

Also, what about 'proto sub'? should we also drop the sub there?

(I can write a test for this, but would like feedback on these items first)

@coke
Copy link
Collaborator

coke commented Aug 26, 2017

WIP on the coke/multi branch

@Altai-man
Copy link
Member

@coke, I am working on some new definitions #1494 - here, so, please, ping me somewhere after your work will be finished, so I could follow the changes painlessly.

@coke coke closed this as completed Sep 2, 2017
@coke coke reopened this Sep 2, 2017
@Altai-man
Copy link
Member

Don't worry, I have already looked into your branch and did appropriate changes.

@rafaelschipiura
Copy link
Contributor

@JJ
Copy link
Contributor

JJ commented Jun 28, 2018

@coke are you still working on this? Should we attempt to merge the branch?

@coke
Copy link
Collaborator

coke commented Jun 28, 2018

Haven't touched it in some time. I think the question from last August is still unanswered.

@JJ
Copy link
Contributor

JJ commented Jun 28, 2018

Also, what about 'proto sub'? should we also drop the sub there?

Yes.

@JJ
Copy link
Contributor

JJ commented Jun 28, 2018

What about examples that are contrasting sub vs. method

In that case it would be better to leave them that way and either whitelist them in the test.

@coke coke removed their assignment Sep 27, 2019
@JJ
Copy link
Contributor

JJ commented Aug 2, 2020

Coming back here, and trying to summarize: a single form, "multi" or "multi sub/method" should be used in the "defined as" part of the docs.
My answer here: in general, we try to use the same form, or as close as possible, as defined in the source. That's the kind of consistency we aim for in the documentation. Since multi sub is preferred in Rakudo, well, we should do the same here. In general, however, creating an issue with 100 (or whatever) tasks is not very actionnable. So the way to solve this is to create, as tagged, an author test that deals with this, and at least fails for pages that are changed.

@JJ
Copy link
Contributor

JJ commented Aug 2, 2020

I'm checking @coke's branch and it seems to be about using multi sub (or multi) everywhere, not only in definitions, which, anyway, are difficult to single out (maybe we should fix that, too). So this is even more difficult to do, and not clear it's really desirable (other than to keep it consistent with source).

@JJ JJ added the wishlist "nice to have" issues; might require a lot of work or a big change or be low priority label Aug 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type) meta RFCs, general discussion, writing style, repository organization, etc. wishlist "nice to have" issues; might require a lot of work or a big change or be low priority xt Regarding current or new xt/ tests or the utils/
Projects
None yet
Development

No branches or pull requests

8 participants