3 ms·
Also nothing in Ruby that's called a "DSL" is actually a "special syntax". It's necessarily all just method calls on objects, ruby has no actual mechanism to in
by jrochkind1 5y ago
Also nothing in Ruby that's called a "DSL" is actually a "special syntax". It's necessarily all just method calls on objects, ruby has no actual mechanism to introduce new syntax. So I'm not entirely sure what the OP is meaning to mean.
I don't know about Scala.
- dmurray 5y agoYou 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.