develooper Front page | perl.perl5.porters | Postings from January 2020

Re: no feature 'indirect';

Thread Previous | Thread Next
January 27, 2020 06:15
Re: no feature 'indirect';
Message ID:
On Mon, 27 Jan 2020, 10:26 Ricardo Signes, <>

> On Sun, Jan 26, 2020, at 9:02 PM, shmem wrote:
> Hi Porters,
> funny things doing you are. What's next? Are we seeing pragmas like
> - nowhitespace, to disable '$ { foo } = $ { bar }'
> - nostmtmod to disable '$foo = $bar unless $baz'
> - noautoload to disable AUTOLOAD
> - nomultiline to enforce a semicolon on the line of a statement
> All of the above seems unnecessarily snarky when you could have just asked:
> I don't get it. Could someone please enlighten me?
> Why is crippling the language been thought as a feature?
> indirect method syntax is fairly rarely used, especially outside a small
> set of methods.

Exactly. To the point where most programmers are taught to never use
indirect syntax except for print and print.

> On the other hand, it leads to a very common and (in my opinion) costly
> bug that converts would-be compile-time errors to runtime ones.  Consider:
> perl -e 'try { sleep 10 }'
> Oops, the user forgot to use Try::Tiny — but instead of a syntax error at
> the unknown "try", we get
> Can't locate object method "try" via package "10" (perhaps you forgot to load "10"?) at -e line 1.
Personally the inscruitability of this error is sufficient and your
following points just nail the coffin shut.

…and we get it after a ten second delay.  But imagine that this wasn't a
> contrived one-liner, but instead a large complex system in which that
> runtime error only occurs occasionally, or after a lot of other preparatory
> work is performed — possibly destructive work.  Instead of failing to
> compile when an error was detectable at compile time, a lot of time — human
> and computer — is wasted by going to runtime.
> So, that is why this is a feature: it permits the detection of programmer
> error at an earlier phase.


Finally, if you yourself would never make such an error, you do not need to
> disable this syntax, so this isn't crippling the language.  It's adding
> another mode of operation that has an explicable benefit.

I think my misunderstanding of the motivation of Karens request may have
made shmem think this was globally enabled. If so my apologies.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About