develooper Front page | perl.perl5.porters | Postings from May 2016

Re: Indirect object syntax

Thread Previous | Thread Next
From:
Ed Avis
Date:
May 25, 2016 21:25
Subject:
Re: Indirect object syntax
Message ID:
loom.20160525T231819-26@post.gmane.org
Abigail <abigail <at> abigail.be> writes:

>People who want to use indirect
>object syntax certainly won't start their programs with 'no indirect'.
>It's only useful for people who don't want indirect object syntax in
>their programs, but somehow use it anyway.

One advantage is that currently you get a completely weird-sounding
diagnostic when you call without () a subroutine that doesn't exist:

    % perl -E '$x = 55; bar $x'
    Can't locate object method "bar" via package "55"
      (perhaps you forgot to load "55"?)

If the parser ambiguity between method and subroutine call were resolved,
this obscure message (for an entirely not-obscure and everyday mistake)
could be fixed.  Heck, at some future point it would become possible to
check subroutine names at compile time under 'use strict' or its equivalent.

If indirect object syntax is discouraged and considered a bit of a mistake -
and I reiterate that I am not advocating this point of view, but *if* it is -
then rather than have it sitting around as a language wart that serves mostly
to ambiguate programs and trip up the unwary, better to start cleaning it up.

-- 
Ed Avis <eda@waniasset.com>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About