Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20335

Re: Identifying a regex

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> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <usenet@PointedEars.de>
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+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: Identifying a regex
Newsgroups comp.lang.javascript
References <kplir9$pj9$1@news.albasani.net> <3c26ff4d-3b91-4784-bea9-20740208b338@x4g2000yqk.googlegroups.com> <kpmu20$5q5$1@news.albasani.net> <f623b8ea-0bf3-429d-b04b-903627edfa1e@a8g2000yqp.googlegroups.com> <2138020.VnviE1jULI@PointedEars.de> <kpq833$o40$1@news.albasani.net>
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<Cl32<A4Fo<]lROoRA8kF<OcfhCOKEUNnbbFTL3BDZm8W4\YJNLb@mF9jNikdEBoKGPB=12AGR9m[:OLEV:@
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:20335

Show key headers only | View raw


Stefan Weiss wrote:

> 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.

<http://PointedEars.de/es-matrix/?filter=Function.prototype.name#features-table>

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.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-17 01:47 +0200
  Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-16 19:30 -0700
    Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-17 14:05 +0200
      Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-17 16:16 -0700
        Re: Identifying a regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-18 02:13 +0200
          Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-18 20:14 +0200
            Re: Identifying a regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-18 21:39 +0200
              Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-18 23:58 +0200
                Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-25 22:05 +0200
                Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-25 16:59 -0700
                Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-26 23:47 +0200
              Re: Identifying a regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-23 20:01 +0200
        Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-18 00:40 -0700
          Re: Identifying a regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-18 10:39 +0200
            Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-18 19:32 -0700
              Re: Identifying a regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-19 14:05 +0200
                Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-19 20:24 -0700
                Re: Identifying a regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-20 12:27 +0200
                Re: Identifying a regex "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-20 18:08 -0700
  Re: Identifying a regex JJ <duh@nah.meh> - 2013-06-17 13:58 +0700
    Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-17 14:11 +0200
      Re: Identifying a regex JJ <duh@nah.meh> - 2013-06-18 12:46 +0700
        Re: Identifying a regex Stefan Weiss <krewecherl@gmail.com> - 2013-06-18 20:17 +0200
  Re: Identifying a regex Andreas Bergmaier <andber93@web.de> - 2013-06-18 21:14 +0200

csiph-web