How Are Methods Defined?

Should methods always be declared inside some class or extend block, or just be declared individually using def? There are two basic syntaxes for adding a method to a class. The conventional OOP style is:

class SomeClass
    def someMethod(arg Int ->)
        // ...
    end
end

To add a method to an existing class, just replace class with extend. The other option is Go style, where methods are just declared freestanding, like:

def SomeClass someMethod(arg Int ->)
    // ...
end

Advantages for class style:

Advantages for Go style:

Answer: There are advantages both ways. If you're adding a lot of methods to one class, then being able to do that in one block saves a lot of redundant typing, especially with long class names or generic classes:

def AbstractDictionary[Key, Value] blah...
def AbstractDictionary[Key, Value] blah...
def AbstractDictionary[Key, Value] blah...
def AbstractDictionary[Key, Value] blah...

On the other hand, if you're adding a bunch of methods to different classes (i.e. avoiding the visitor pattern), the blocks are tedious:

extend AddExpr
    evaluate(-> Int) left + right
end
extend IntExpr
    evaluate(-> Int) value
end
...

The best solution may be to just support both.