On Wed, Feb 16, 2011 at 10:02 AM, Dmitry A. Soshnikov < [email protected]> wrote:
> By the way, CoffeeScript provides a convenient sugar for that: > > obj.foo?.bar? and stuff?() > > which desugars into (notice, how elegantly the last "stuff" is checked to > be a functon): > On Wed, Feb 16, 2011 at 1:40 PM, Angus Croll <[email protected]> wrote: > What worries me is the unwanted side effects. > > console.log(d.foo.bar.bam) and maybe you just created 3 new objects > > The CoffeeScript syntax is very nice, but I'm still not seeing the necessity of the extra syntax. Don't get me wrong, I'm fairly certain there's something I'm missing (and I keep thinking it may have to do with function references... but can't come up with an example). The way I imagined this happening: - If this is a LeftHandSideExpression, generate objects as necessary (which is what you'd want, right?). - Otherwise, as soon as a property is "undefined", the entire expression is "undefined"... and no new objects are created. On Wed, Feb 16, 2011 at 2:21 PM, Jason Mulligan < [email protected]> wrote: > That's really why it shouldn't behave that way. > > Btw, I just added that define() to abaaso(.com); my jslib .. it's > pretty useful when you need to work with something pre-existing, not > ideal for constructing (json is). I'll likely be stealing this... but only for my personal stuff. It's hard enough getting my team to follow best practices anyway :) -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
