Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <2329900.uRMUlLskrn@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 05 Jan 2013 18:14:10 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <1512443.gQHv90F1im@PointedEars.de> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 36 NNTP-Posting-Date: 05 Jan 2013 18:14:11 CET NNTP-Posting-Host: dfe6a4cb.newsspool3.arcor-online.net X-Trace: DXC=YBYU3JEom=>H@K0hUI Thomas 'PointedEars' Lahn wrote: >> [You] should not simply return in the second branch in Version 2, because >> calls will fail then; you should return a reference to a Function >> instance with an empty function body. > > Disagree with that. Then the calling code would have no way of knowing > whether the function does anything useful. (For brevity, I am using “function” instead of “referred Function instance” from here.) That is not so. With an empty function body the returned function can be called *and* a called function returns “undefined” if it cannot do anything useful. That would be different from it returning “null”, *and* an advantage over returning a non-callable value from the function-constructor. My point is that the latter should return a function here as the rest of the code hinges on the callability of the returned value. And if I am not very much mistaken, this is the pattern that you are employing in My Library, too. > It's a variation of the "unbreakable chain" pattern seen in jQuery: > > A().B().C().D()... Which is why *chaining* *can be* error-prone. Non sequitur. PointedEars -- > If you get a bunch of authors […] that state the same "best practices" > in any programming language, then you can bet who is wrong or right... Not with javascript. Nonsense propagates like wildfire in this field. -- Richard Cornford, comp.lang.javascript, 2011-11-14