undefined being treated as a missing optional argument

Allen Wirfs-Brock allen at wirfs-brock.com
Fri Apr 13 11:51:18 PDT 2012


On Apr 13, 2012, at 11:26 AM, David Herman wrote:

> On Apr 13, 2012, at 9:38 AM, Russell Leggett wrote:
> 
>> Yes, but as I said, and Erik pointed out is in the wiki, it is a lot more likely that someone would pass f(foo) or f(obj.foo) where foo might be undefined.
> 
> Bingo.

how does that equate to expecting the parameter to default?  If foo or object.foo being uninitialized is unintentional it is better propagate the undefined rather than treating it as f().  The later will tend to hide latent logic errors.

> 
>> Expecting undefined as a possible valid argument (as opposed to a missing argument) seems like a very rare case, and probably a code smell.
> 
> Amen.


both sides of this debate seem a little smelly. But, Pretending that undefined isn't a real value seems more smelly to me.




More information about the es-discuss mailing list