On Fri, Oct 12, 2018 at 6:08 AM Todd Chester via perl6-users <
perl6-users@perl.org> wrote:

> > If nothing is being returned, it should really be indicated with --> Nil
> > since that can enable certain optimizations.  Similarly, if a routine
> always
> > returns true upon success, that can be indicated with --> True.
>
> Am I interpreting Larry correctly?  Should every definition line
> always have a --> at the end?
>

Adding it gives more information to the consumers of that routine, the
people reading it,
the compiler optimizing use of the routine, and the runtime execution which
will validate the
return and throw an exception for you if it is wrong.  (There is a tiny,
tiny bit of runtime overtime
to do that check.  Optimization could easily offset or overwhelm that
overhead.)

Like many things in Perl, you are free to add the extra stuff if you want
to take advantage of that,
but also free to leave it out if you don't feel like it.  The language
supports many different levels
of formality you get to choose from.  For "quick and dirty" programming, go
ahead and leave
them out if  you want.

Curt

Reply via email to