Query
Tuesday 02 October 2012
2012-10-02 12:07:44 (1 decade ago) by Per Hedbor <ph@opera.com>
- pike/src/language.yacc (+160/-60)(220 lines)
- pike/src/lexer.h (+27/-1)(28 lines)
branch: 7.9
Added a two new operators: "?->" and "?:"
?-> can be used to index something that is either indexable or null.
?: is an alias for ||
Very useful for things like:
C c = a && a->b && a->b->c;
which can now be rewritten as
C c = a?->b?->c;
The code in language.yacc also supports ?. and ?[], but there are
syntax conflicts with ?: for those:
?. conflicts with expr?.Module:...
?[] conflicts wtih expr?[softcast]:...
?: was added mostly to be compatible with other 'modern' C-like
languages.