Re: vote on assignments as expressions
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
"Laurent Dube" <[email protected]> wrote in message > > So we need an alternative syntax like "a <- b", but I don't want to use that > > for all assignments because "a = b" is so common. Once again familiarity > > beats logic. > > The desired sequence of actions being > > a = b > foo( a ) > > you propose to add a binary operator to the language > > foo( a operator b) > > that would allow to combine the two actions while respecting their > sequence. > An easy way out would be to use a function instead of an operator: > > foo( a.assign!(b) ) > > where assign in place is the functional equivalent of the familiar > operator version of the same action. I proposed the exact same thing a week ago. I had to retract the proposal when I realized that a method can only change the value of an existing attribute. It cannot create a new attribute or rebind an attribute like an assignment statement does.