develooper Front page | perl.perl5.porters | Postings from October 2005

[perl #37289] Erratic return of hashref from sub

From:
Steven Schubiger via RT
Date:
October 2, 2005 04:14
Subject:
[perl #37289] Erratic return of hashref from sub
Message ID:
rt-3.0.11-37289-121863.18.0586714928555@perl.org
> [ron@savage.net.au - Tue Sep 27 16:49:52 2005]:
> Using an explicit return, as suggested by MGS, instead of the + also works.
> 
> Thanx.
> 
> Would it be possible for Perl to output a warning in such cases?

Implicit return can work, although explicit ones should be preferrably used.
For an though programmer, these warnings would be superfluous and at 
best annoying.

Besides that, if agreed upon, it would almost inevitably lead to an addition 
of warnings to the extent of being unmanagable due to other functions that 
have such 'unexpected' side-cases.

I could imagine adding this functionality to the strict pragma along with
the keyword 'return' - so "no strict 'return'" would disable that behavior.
But I doubt that would break many existing scripts/modules out there; another,
slightly less harmful, approach would be to leave 'use strict' as it is and 
make the behaviour optional.




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