Closed hikari-no-yume closed 9 years ago
Uhm I think static
might be easier to see. @@
can get messy pretty quickly. Maybe something like this:
class Foo
def instance_method
end
static def static_method
end
end
a = new Foo
a.instance_method
Foo::static_method
Yeah, I'm really not sure on the syntax
It's hard to decide! I think I'll implement closures for now. Give this some thought. Same with modules.
Well, now that the compiler is smarter, whenever there's a method call and there's a variable in scope we can assume it's an instance, otherwise it's a class. So:
a = new MyClass()
a.method_a()
MyClass.method_b()
Would compile to
$a = new MyClass();
$a->method_a();
MyClass::method_b();
That might work, though it seems error-prone
Uhm, can you give an example? I still haven't decided on the syntax but if we could get the last I showed to work it would certainly be awesome.
Actually, I can't think of a case where it'd break... that should work.
Though maybe you should only assume things in CamelCase are classes (much like how Haskell requires Types To Look Like This but variables look like this)
Implemented in 72e7528c177ea13f1123eb6bc1840e17ea5ad39e, closing for now.
Static properties are accessed in PHP like this:
FooBar::$bar
, while constants work likeFooBar::FOO_BAR
and methods likeFooBar::foo()
.One solution for this is uppercase constants and adding
::
:But making references implicitly static would cause problems, and the
static
keyword isn't so nice. How about@@
forself::
?@@
is a bit weird, though.We could also choose not to support static members. Or we could take this approach:
What to do?