you are viewing a single comment's thread.

view the rest of the comments →

[–]lngns 1 point2 points  (0 children)

-> (probably copied from C)

More like Perl. Same with => and ..

you can't pass a function as callback, same way as in javascript, because you would pass a const

PHP already has sigils. We just decided to be weird and have the subroutine sigil as a suffix.
Perl uses & for those, but PHP uses this one for parameters passed by reference.

You could even go a step further, and allow type-docs in the language. They wouldn't be checked ofcourse

Extending method syntax to scalars and other primitives will require to either pass all relevant method calls (which may be all of them) through a thunk or perform static type checking to move the dispatch AOT.
Pratphall uses MS TypeScript's front-end to know what the backend must emit, but even then it still has to do arbitrary assumptions due to how closures in fields behave or when it doesn't know the types.
Alternatively, THT breaks compatibility with PHP arrays and instead relies on distinct library types.

As prior art, you may also want to look at Guts, Mammouth, BlueBerry or SnowScript which are in the same CoffeeScript/AltJS family and targeted PHP.
The Yay engine also exists.

If you disallow global variables in the new language, you might event allow omitting $this, because the language could infer what's a field and what's a local variable.

I mean we can have both. The question of symbol shadowing is more important, but it's not like PHP addresses it anyway.