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
RakuAST: implement for { } otherwise { }
#5390
Conversation
I was looking at what would need to be done to port the Slang::Otherwise module to work with RakuAST, and realized it was probably less work to just implement the functionality in the Raku grammar. This does: - Implement a :otherwise argument to RakuAST::Statement::For - Adapts the QAST generation accordingly if an otherwise was found - Adds preliminary grammar support for "otherwise" This does NOT adapt .raku or .DEPARSE yet. It also doesn't answer the question on whether "otherwise" should be a 6.e feature, or should also be available in 6.c and 6.d. It feels that it should also be available in 6.c and 6.d so that users of the Slang::Otherwise module can just remove it, and/or have the Slang::Otherwise module not do anything if it spots that it is being called with the Raku grammar.
It's probably always "less work" to implement a slang in the main language, or at least not more work. That isn't a sufficient reason to add syntax to the whole language, possibly even retrospectively. What was the process for introducing this language change? What is the rationale? Who wants to use it? Out of the people who may use it or are willing to use it, who thinks that it should be in the main grammar? Hoping that there will be some sufficient decision process, rather than a PR silently getting merged, I would argue against this change.
|
As author of the module, I thought I should comment. Regarding "culture"... Part of the culture of Raku is way it names thing; we like to have a little fun with names. If you are too serious, there are plenty of languages to suit your level of seriousness. Trying to make Raku like those languages erodes what makes us unique. A lot of people coming to the language don't know what I also don't think The part where I partly agree is... even as the author of that module, I don't use it much. I published the module primarily because Damian didn't. I'm not sure it enjoys the broad usefulness of other constructs, but then, Raku has a lot of constructs which I don't use, so maybe I'm a bad sample. This doesn't mean those constructs are not useful. So where do I stand? Unfortunately, I don't have strong feelings either way. I guess it depends on a few factors: -
As for a language additions in general... Maybe there should be a formal language enhancement process for users, but in almost any language, the designers and maintainers ultimately decide what gets implemented, so I guess I lean in the direction of being fine with it being added. |
I think it could just derail the discussion if we got too much into the "fun with the names" part; iffy-diffy-fiddly-gobbling-etc. come to mind. I do think they backfire a lot when you are a newcomer or not an English native, or worse yet, a combination of both. I also think they contribute to a club mentality that doesn't go very well with the inclusivity... but I told myself not to digress too much. The problem with this name isn't that it's "funny". It's that it tries to give meaning to a "colorless green ideas sleep furiously" type nonsense. This could only work reasonably well if everybody agreed on the same meaning, in which case the nonsense would suddenly turn into a clear thing, even if unusual. However, Python already tried to assign a meaning to this nonsense, and it is a source of confusion and criticism for Python as well. I don't think it requires wild imagination to foresee people trying to use it the way it works in Python. You may say that the points I raised are not very big problems. Sure, it's not like the world is gonna end. However, they seem good enough points for me to think it comes out as a net negative. An unintuitive structure that saves a couple of keystrokes in highly specific scenarios at the expense of more things to maintain and learn to read.
I covered this in the fourth point. There are loads of widely available generic structures to mitigate a situation like this, and it's very easy to imagine semi-generic-semi-specific situations where you want to avoid an extra assignment but the language provides no syntax for that case. I would rather not see a precedent for adding stuff like this without a solid reasoning and support from the community (preferably both, to be honest, because we all come with our biases). And I would rather not see precedents of syntax added in pull requests without even some sort of announcement or Github issue.
It would be okay if the Raku community had a culture of "designers and maintainers" as a definite group who have the authority and willingness for the responsibility that it implies. Since there is basically nobody taking up on Problem solving issues, nor is there a workflow for things like this, I don't think there is any visible intention to govern the language. It's not a figure of speech when I ask about the process, or how this design decision comes to be; I really don't know which "hat lizmat is wearing" when opening a PR like this. A mere contributor? A core developer? A RakuAST designer? Somebody who has a commit bit in the rakudo repository? A member of the Steering Council? The person who probably has the most access rights and connections around what one may call "official Raku platforms"? The answer to this question has implications about how this PR should be taken, and how it relates to other common-interest matters that seemingly nobody even feels responsible for. |
Please let's stay with implementing the already large enough Raku grammar before adding new features. |
Jeez. This is I guess one of those cases where the discussion is going to be mindblowingly protruded. Almost enough for me to just close this PR and go on indefinite holiday. Anyways. There's the blog post and the discussion. The fact that Slang::Otherwise has 5 stars on Github is some indication that the repo is appreciated by some people at least. Some comments:
I think the blog post shows quite a few use cases, and the reasoning why it would be a good feature to have.
That's why it's called
Who said anywhere that this would be a game changer? Not in the blog post, nor in the comments on Reddit, nor in the PR?
Could you give an example of that, that wouldn't affect the laziness of the
I think it could be argued that
Then please don't. Most users will never have to deal with "iffy-diffy-fiddly-gobbling", as these are mostly internal grammar concepts. And maybe some users may see references to them in error messages. And maybe the documentation in the glossary could use some improvements. Please make a doc issue / PR for them if you think the documentation is insufficient.
Please refrain from using words such as "nonsense" in these discussions. I've taken time to look into adapting the slang, writing the support for it in core, make a PR. The PR may not be accepted, but that is life. But it is NOT nonsense. So please refrain from calling it nonsense.
Indeed, and thus lose the laziness of the iteration. Please provide an example that would maintain the laziness that would NOT involve setting a flag in each iteration or a
Why? We have a discussion here, don't we? People can look at the code and its features. That's a lot less vague than making an issue.
The fact that I opened this as a PR, just like anybody can do with a Github account, means I did this as a contributor. Please treat it as such.
The reason for me to make this PR, was that I realized that to be able to make the |
FWIW, 9b29fdcab6 implements the hooks in the |
If I wanted to do stuff when a loop wasn't run, I would do the following:
My Raku-instinct is asking me to use a phaser when doing special stuff with a loop. Maybe that is the right thing to do here. Have a phaser that is run when the loop body isn't.
Very well possible that an EMPTY-phaser could be used elsewhere in the language. Also, phasers are copy-pasta-friendly. And I do like myself a good copy-pasta. |
That looks utterly confusing: you're in a loop body when the loop doesn't run. That also means binding(s) from This PR is a good solution to a very common code pattern that simplifies writing it, makes sure side effects aren't evaluated twice, it doesn't have python's weird |
I like the phaser suggestion... maybe I just don't like the suggested name of that. |
But maybe that would make someone expects to: if ... {
EMPTY {
say "just like an else"
}
} To behave like an |
Well, what can I say, I agree with none of it basically:
|
@2colours you already made your opinion clear. Why do you feel the need to re-iterate that if someone has a different opinion? It does not strengthen your argument. |
@lizmat there is a difference between making arguments and stating an opinion as a fact to be taken at face value. I don't want that someone takes the upper hand without arguments simply by asserting confidence. Anyway, I wanted to address "the article" so please wait. There are differences between "opinions". |
I was looking at what would need to be done to port the
Slang::Otherwise
module to work with RakuAST, and realized it was probably less work to just implement the functionality in the Raku grammar.This does:
This does NOT adapt .raku or .DEPARSE yet.
It also doesn't answer the question on whether "otherwise" should be a 6.e feature, or should also be available in 6.c and 6.d. It feels that it should also be available in 6.c and 6.d so that users of the Slang::Otherwise module can just remove it, and/or have the Slang::Otherwise module not do anything if it spots that it is being called with the Raku grammar.