Ruby adds experimental support for rightward assignments
101–110 of 172 posts
Re: Ruby adds experimental support for rightward assignments
#102>R language also has a similar way of doing this 42 -> age. Ah yes, the R language, a model of clarity, beauty and lightness in the world of programming languages. Truly an example to follow. (And it's not like anyone ever uses that "feature" in the R world either.)
I don't understand what point you are trying to make here. Do you not like the feature simply because R has a similar feature? Why not look at examples given here and by others and decide/comment on whether it adds clarity or expressiveness or not?
-Arguing that adding a feature is ok because "R does it" is comically wrong when one is acquainted with all of R's warts and superfluous stuff
-Not even the R world uses that feature either, so we have actual empirical evidence that it's not that helpful to developers.
Re: Ruby adds experimental support for rightward assignments
#103Ruby, it should be noted, already has experimental support for rightward assignments by way of pattern matching, so this is really TMTOWTDI.
Re: Ruby adds experimental support for rightward assignments
#104Ruby's parser is notoriously complex; if I remember correctly, only a few members of the core team even know how to maintain it without introducing regressions. The craziest part of this is that Ruby does not provide a full featured Ruby parser, so its entire static and dynamic analysis ecosystem depends on a (actually very high quality) 3rd party parser, begrudgingly maintained by someone who (AFAIK) doesn't even wr…
Re: Ruby adds experimental support for rightward assignments
#105> While the above pattern has become standardized, it feels somewhat unnatural as we read most of the spoken languages from left to right. Is this true (the 'unnatural' part)? Reading left to right, `age = 42` can be read as "age is 42" which feels perfectly natural in English. `42 => age` would be read as "assign 42 to age"? This feels more awkward to me. I'm not sure I understand why anyone would want Rightward ass…
Below is an _incredibly_ contrived example. Take note how the `=> final_value` syntax is useful. The alternative is to place a `final_value = ` at the _top_ of the statement. I'll admit: placing the assignment at the top of the method chain helps point out to the reader of the code that an assignment is happening. However, more useful I think is quickly recognizing the flow of data.
"hello"
.chars
.size
.*(10980643.4)
.to_i
.to_s(36)
.upcase
=> final_value
puts(final_value)
# => WORLDRe: Ruby adds experimental support for rightward assignments
#106Earlier quoted context omitted.
I don't understand what point you are trying to make here. Do you not like the feature simply because R has a similar feature? Why not look at examples given here and by others and decide/comment on whether it adds clarity or expressiveness or not?
I am making two points: -Arguing that adding a feature is ok because "R does it" is comically wrong when one is acquainted with all of R's warts and superfluous stuff -Not even the R world uses that feature either, so we have actual empirical evidence that it's not that helpful to developers.
It's fine to not like the feature–I don't know enough about its usecase to feel one way of another–but your comment felt unnecessarily negative without adding much to the discussion.
Knowing that R users have access to these syntax and choose not to use it is interesting to consider, but that was overshadowed by your first statement.
Re: Ruby adds experimental support for rightward assignments
#107Earlier quoted context omitted.
> how does Nim know that `=>` is infix? I expect it's the ` Haskell works the same way.
Ah, and templates are a rewrite engine on the AST! That completely slipped my mind. So the compiler itself just sees the `a = b`, the `b => a` is never visible, therefore precedence isn't germane to the template itself. Neat.
Not quite. Imagine you have:
3 + b => a
Is that 3 + a = b, or a = 3 + b? Precedence still comes into it. (I don't know nim's solution.)Re: Ruby adds experimental support for rightward assignments
#108>R language also has a similar way of doing this 42 -> age. Ah yes, the R language, a model of clarity, beauty and lightness in the world of programming languages. Truly an example to follow. (And it's not like anyone ever uses that "feature" in the R world either.)
I don't understand what point you are trying to make here. Do you not like the feature simply because R has a similar feature? Why not look at examples given here and by others and decide/comment on whether it adds clarity or expressiveness or not?
Re: Ruby adds experimental support for rightward assignments
#109Ruby's parser is notoriously complex; if I remember correctly, only a few members of the core team even know how to maintain it without introducing regressions. The craziest part of this is that Ruby does not provide a full featured Ruby parser, so its entire static and dynamic analysis ecosystem depends on a (actually very high quality) 3rd party parser, begrudgingly maintained by someone who (AFAIK) doesn't even wr…
Re: Ruby adds experimental support for rightward assignments
#110This is true to Ruby's Perl heritage. There is more than one way to do everything, even the most basic of operations. Quiz: what does the following Ruby code do? a = b => c = d
Makes me reject the PR for lack of clarifying parentheses.