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.