Assuming you have a DSL like below, I want to add ...
# dsl
i
Assuming you have a DSL like below, I want to add a condition to add +Person("Emily", 31) to the list, what would be the most suitable syntax?
Copy code
val v = village {
        house {
            +Person("Emily", 31)
            +Person("Hannah", 27)
            +Person("Alex", 21)
            +Person("Daniel", 17)
        }
        house {
            +Person("Joe", 48)
        }
        house()
        house {
            -Person("Sarah", 40)
            -Person("Tom", 26)
            -Person("Holly", 52)
        }
    }
Slack Conversation
w
I would just make a person function on the house object that constructs the Person and adds it, and not use an operator. I think the + operator makes sense if you are mutating a scalar value, like a number or appending to a string, but I think for collections a function is better, ESP if you are using a DSL marker to restrict scope, which makes discoverablity way better
👍 1
i
Members on my team dont like the + operator too