Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <4497153.IWULeidUyA@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 18 Jun 2013 21:39:49 +0200 User-Agent: KNode/4.10.2 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+&. <3c26ff4d-3b91-4784-bea9-20740208b338@x4g2000yqk.googlegroups.com> <2138020.VnviE1jULI@PointedEars.de> MIME-Version: 1.0 Lines: 69 NNTP-Posting-Date: 18 Jun 2013 21:39:53 CEST NNTP-Posting-Host: 8920edfa.newsspool4.arcor-online.net X-Trace: DXC=>WFZ0V2`hQHE4ZB2flKORA4IUK On 2013-06-18 02:13, Thomas 'PointedEars' Lahn wrote: >> In the case of references to RegExp instances, though, where inheriting >> from their prototype does not make sense and so all pertinent objects >> have [[Class]] "RegExp", in JSX:regexp.js I have switched from comparison >> [[against the “constructor” property value to jsx.object.getClass() for >> the next revision, for cross-view referencing. > > For reference: > > var _getClass = (function () { > var _toString = ({}).toString; > > return function (obj) { > return (_toString.call(obj) > .match(/^\s*\[object\s+(\S+)\s*\]\s*$/) || [, ])[1]; > }; > }()); > > http://pointedears.de/websvn/filedetails.php?repname=JSX&path=%2Ftrunk%2Fobject.js > > That would correspond to option (C) in my original question. Yes. > The old comparison method in your regexp.js (rev 361) is not the same as > option (B), however: comparing the constructor property directly with > RegExp does not work across frames, but comparing constructor.name with > "RegExp" does (as long as nobody messed with the constructor directly). I am not convinced that constructor.name is interoperable in the first place. The ECMAScript Support Matrix, Version 2, contains a testcase for Function.prototype.name that has been recently run (by someone else – thank you) to fail in JavaScript 1.8.6 and JScript 10.0.16578. But that might be due to “name” being a property of Function instances only in those implementations. I shall modify that testcase accordingly. That said, neither Function.prototype.name nor functionInstance.name are specified in the ECMAScript Language Specification, 5.1 Edition, §15.3, so they are very likely not interoperable. Which is why there is /** * Returns the name of a function * * @param {Function|String} aFunction * @return {string} * The name of a function if it has one; the empty string otherwise. */ jsx.object.getFunctionName = function (aFunction) { /* Return the empty string for null or undefined */ return (aFunction != null && typeof aFunction.name != "undefined" && aFunction.name) || (String(aFunction).match(/\s*function\s+([A-Za-z_]\w*)/) || [, ""]) [1]; }; > In my specific case, I can see both methods working equally well. […] I don't. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.