I'll bring this up during next weeks conferance, but this is a chance for everyone to chime in.
Safe indexing is not documented. Possibly partially because it's not consistently implemented. The lexer says this:
if(GOBBLE('-') ) /* safe index: ?-> or ?[] */ { if( GOBBLE( '>' ) ) /* ?-> */ return TOK_SAFE_INDEX; SKIPN(-1); /* Undo GOBBLE('-') above */ }
/* Probably wanted: ?. for safe constant index ?[] for safe [] index They however conflict with valid ?: syntaxes. */ /* if( GOBBLE('.' ) ) */ /* return TOK_SAFE_INDEX; */
The question is, could we take the hit that "?." and "?[]" would trigger safe indexing and thus break those as valid if syntax? I'm having a hard time conjureing up even semi-good theoretical examples for their uses. There are no uses in Pike's own source.
Having "?->" without "?[]" is awkward and so either we should probably take that hit, or we change the syntax for safe index completely and depricate "?->". "?." should be there for symmerty, but it will probably not be used.
As an aside: the "?" if syntax is nor documented in the refdoc for control structures, so hopefully there isn't a lot of casual users of it.
pike-devel@lists.lysator.liu.se