Blueberry
Blueberry copied to clipboard
Modules / Traits
I think traits / modules are awesome as they help you get the best out of dynamic typing. I'm not sure on the syntax though, PHP uses include
and require
keywords already, so using Include
like in Ruby might be confusing. PHP uses the use
keyword for this, which in my opinion might be better for our use case.
Beeing verbose is good sometimes, but maybe something like this would be nicer?
class MyClass
+SomeModule, SomeOtherModule
def some_method
# ... etc
end
end
Alternatively, we can just use the use
keyword:
class MyClass
use SomeModule, SomeOtherModule
def some_method
# ... etc
end
end
I'm open to suggestions on the syntax and modules in general. I'd like to keep them simple for now. Also, this would only work on PHP 5.4+ unless we generate some ugly hacky PHP.
Maybe import
? Since you sort of import the methods. Or copy
, since it's essentially compiler-assisted copy and paste.
Yeah import
is a good keyword. What do you think about the +
though? Is is hard to read? It kind of reminds me of SASS :smile:
I don't think it's sufficiently obvious what it does
Yeah I don't want to end up like Perl. With variables such as $_
and @_
. It's not like I cannot do both syntaxes though.