in reply to Memory efficiency, anonymous vs named's vs local subroutines

The memory efficiency you should be concerned about is "how can I best remember or figure out how this code works". When computers, even the one in your pocket that you call a phone, have multiple gigabytes of memory, shaving a few bytes here and there is almost always a waste of time.

Consider instead how easy it is to understand the intent of the code, how robust the code is against programming errors, and how easy it will be to maintain the code in the future. In all of those cases a named function is a big win because the name can (and should) convey intent.

I'm unsure what you mean by a "local subroutine" as all named subroutines in Perl are scoped within the current package. Nesting subroutines makes no difference to their availability to other code.

Premature optimization is the root of all job security
  • Comment on Re: Memory efficiency, anonymous vs named's vs local subroutines

Replies are listed 'Best First'.
Re^2: Memory efficiency, anonymous vs named's vs local subroutines
by thanos1983 (Parson) on Jul 18, 2015 at 18:52 UTC

    Hello GrandFather,

    First of all thank you for your time and effort reading and replying to my question. You are right, always I am getting into these stupid details. I guess I was more curious to found what function to use when. Who care for a few bytes. The important part as you said first of all, is to be able to understand what it does and then all the rest.

    Thanks I guess I will go with named routines, simple as that.

    Local subroutine, I call it because the author of the tutorial Creating Nested Functions was calling it like this.

    Seeking for Perl wisdom...on the process of learning...not there...yet!