From: "alexeymuranov (Alexey Muranov)" Date: 2012-11-13T15:36:20+09:00 Subject: [ruby-core:49283] [ruby-trunk - Feature #7336] Flexiable OPerator Precedence Issue #7336 has been updated by alexeymuranov (Alexey Muranov). I have similar opinion with Matz: i think it is nice to have in language something about the syntax that never changes. In this case, it is to be able to look at a line of code and to know in which order it will be executed, without having to go through the entire program. The operator precedence in my opinion is such a basic thing as parentheses parsing. I think it has to be defined in a reasonable way, but i do not think it is necessary to be able to redefine it, as you can always use parentheses if needed. I think this is similar to natural languages. ---------------------------------------- Feature #7336: Flexiable OPerator Precedence https://bugs.ruby-lang.org/issues/7336#change-32840 Author: trans (Thomas Sawyer) Status: Rejected Priority: Normal Assignee: Category: core Target version: next minor =begin If Ruby classes could provide some means for redefining operator precedence, it would provide the flexibility useful to some DSL use-cases. My particular application, for instance, is in an SI units system gem that could use `^` to mean power of the unit (e.g. 1.meter^3 would mean cubic meters). But to do that right the operator needs a higher precedence. I don't expect it to be something commonly used, obviously, but it certain use cases like mine it is practically essential. I first suggested that (({#^})) be given a higher precedence and XOR get another operator in #6678. I was not surprised that it was rejected, but I figured it was the proper first step, before proposing this much broader feature request. As for notation, I suppose the simplest means if to create class method that can move the precedence to a position relative to another, e.g. class Unit precedence :^, :** Which is to say, move (({#^})) operator to a precedence above (({#**})). =end -- http://bugs.ruby-lang.org/