3 ms·
You kind of know what he means. Ruby uses methods for things that look like syntax in other languages (eg the plus sign for addition) and lets you define them h
by dmurray 5y ago
You kind of know what he means. Ruby uses methods for things that look like syntax in other languages (eg the plus sign for addition) and lets you define them however you want. AND Ruby has the method_missing magic method, which means anywhere the language was expecting a method call you can put pretty much any tokens of your choice, and use metaprogramming to interpret it at runtime.
Those are things that people leaned into a lot ten years ago, and relatively little now. It might still make sense to, say, define the addition operator for colour spaces in your graphics library, but not to change the look of the language to the extent that rspec does.
- AnimalMuppet 5y agoHmm. So C++ operator overloading is a DSL, at least in a sense. It lets you define things like + and * for vectors and matrices, so you can write your code using your usual notation for such things. But it's a fairly limited DSL, because you can't introduce new (non-C++) syntax. I hadn't thought of it that way, but I can kind of see it.