News for hackers. Stuff that matters.
Re:Gem adds support for creating state machines for attribut... by dymk on Monday January 22, 2024 @07:03PM (#39097394)
It's generally good practice to read a library's documentation to understand how to use it - there's not really a short cut to that, regardless of the language.

As for the syntax, you know that `event` is a method, passed the param `:ignite` and a block, and in that block, you call the method `transition` with kwargs `{stalled: same, parked: :idling}`, and `same` is another method call.

Re:Gem adds support for creating state machines for attribut... by heleninboodler on Tuesday January 23, 2024 @02:09PM (#39108080)
Indeed I know all of this. But in terms of "what this code does," the information that a method is passed a block that calls another method is not particularly interesting. The major problem I have with this sort of DSL is it encourages people to infer what it does based on what the ad hoc method names make it sound like this is intended to do. So many of these custom DSLs are documented by example rather than by any decent specification. The attitude that these clever little grammars make it so you can "just read it and it's obvious" is, in my opinion, sloppiness in code comprehension taken to an extreme.