TomDLux has asked for the wisdom of the Perl Monks concerning the following question:
I'm reviewing the newest Modern Perl and it suggests adding to zero, concatenating to an empty string, and double negation as ways to force numeric, string and boolean context on a value.
Pretty standard stuff, but it made me wonder: Do these simply force a context, or do they carry out the superfluous operation. Would it make sense to detect the pointlessness of the operation beyond forcing context, or would that be more expensive than simply performing the operation?
Micro-optimizers around the world need to know!
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: forcing contexts and micro-efficiency
by BrowserUk (Patriarch) on Nov 01, 2011 at 17:15 UTC | |
|
Re: forcing contexts and micro-efficiency
by davido (Cardinal) on Nov 01, 2011 at 19:20 UTC | |
by BrowserUk (Patriarch) on Nov 01, 2011 at 20:00 UTC | |
|
Re: forcing contexts and micro-efficiency
by chromatic (Archbishop) on Nov 01, 2011 at 21:04 UTC | |
|
Re: forcing contexts and micro-efficiency
by zentara (Cardinal) on Nov 01, 2011 at 18:12 UTC |