Re: [perl #42603] func Class->method should resolve to func( Class->method )

Tinkering with the rules for indirect object syntax would be foolish.

Any change to the ambiguity resolution in the absence of new pragmata
would break existing working code and make it more difficult to write
code that's portable across Perl versions.  Backcompat requirements
mean we really can't change the default rules at all, other than via a
deprecation cycle.

If we were to introduce a new pragma, that could invoke a different
set of rules for indirect object syntax without backcompat trouble.
However, if the alternate rules are merely different, that doesn't really
solve anything.  It would handle some cases in an arguably better way,
but it would still be a set of heuristics, still liable to surprise,
and probably still impossible for a human to learn.  It's not worth
introducing a pragma for such a weak effect.

The only pragma here that would be worth introducing would be one that
disables indirect object syntax entirely.  Abolish, don't tinker.  In the
scope of the pragma, things that look like they could be indirect object
syntax would be resolved as other syntax if possible, and would be syntax
errors if not.  I think this can be done without great difficulty, but
I wonder whether there are lurking ambiguities that this wouldn't resolve.

I think the new pragma should be a "feature" subpragma.  I'm in two
minds as to whether the positive form of the pragma should refer to
suppression or to presence of indirect object syntax.

I'm also not sure whether "print {$fh} $stuff" should count as indirect
object syntax for the purposes of the pragma.  Unlike the way indirect
object syntax applies to ordinary method calls, this is the only syntax
that will produce the optree that it produces.  I'm not sure how closely
related the two kinds of indirect object syntax are internally.

If there are no objections, I'd like to go ahead with implementing some
form of this feature.

11/14/2017 1:46:52 PM
perl.perl5.porters 47364 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 0