Better HN
topnewbestaskshowjobs
Log inSign up

stevenhilder

1 karma · joined Jun 28, 2019 (7y ago) · 2 submissions

Submissions

comment 7y ago · link · parent

I believe you're correct; I'm not aware of any other language with a left-associative ternary.

This will be deprecated as of PHP 7.4[0], and will cause a compile error in PHP 8.0.

However, instead of switching straight to right-associativity, PHP will require explicit parentheses to disambiguate nested ternaries.

[0] https://wiki.php.net/rfc/ternary_associativity

comment 7y ago · link · parent

Your logic is sound, although I can't really imagine anyone adopting this scheme.

Actually, I would take it much further:

Instead of code being stored as a plain text file, store an abstract syntax tree in some binary form. Then all indentation, whitespace, keywords -- in fact, practically the entire syntax -- could be defined according to your preferences, while maintaining full interoperability with fellow developers.

Of course this would require an editor/IDE specially designed to work this way, and a VCS that can diff the binary AST in a syntax-agnostic manner.

This is what I'm currently working towards, as part of a programming language that is defined only by its semantics (the syntax itself is dynamic/extensible).

Check back on me in about 10 years :)