Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Modules / Traits #36

Open
gosukiwi opened this issue Jan 10, 2015 · 4 comments
Open

Modules / Traits #36

gosukiwi opened this issue Jan 10, 2015 · 4 comments

Comments

@gosukiwi
Copy link
Owner

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.

@hikari-no-yume
Copy link
Contributor

Maybe import? Since you sort of import the methods. Or copy, since it's essentially compiler-assisted copy and paste.

@gosukiwi
Copy link
Owner Author

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 😄

@hikari-no-yume
Copy link
Contributor

I don't think it's sufficiently obvious what it does

@gosukiwi
Copy link
Owner Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants