4 ms·
I haven't seen this specifically, but I have seen other languages move common top level behaviors within functions into parameter lists. Ruby, dart, coffescrip
by adrusi 11y ago
I haven't seen this specifically, but I have seen other languages move common top level behaviors within functions into parameter lists.
Ruby, dart, coffescript allow setting of instance variables from the parameter list:
class Example
constructor: (@name) ->
# do stuff
class Example
constructor: (name) ->
@name = name
# do stuff
Jonathan Blow's language allows the `using` keyword in parameter list, which desugars in much the same way.
I'm personally not a big fan of using this technique for pattern matching, but its better than requiring explicit match blocks everywhere (like Scala and rust).