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


Groups > comp.lang.javascript > #20328

Re: Identifying a regex

Message-ID <2138020.VnviE1jULI@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-06-18 02:13 +0200
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>

Show all headers | View raw


Michael Haufe (TNO) wrote:

> With the language being as fast and loose as it is, (plus proxies now
> and interactions between differing versions of the language in the
> same document), you're just about shit out of luck I think for a 100%
> guarantee on identity and capability for objects you don't control.
> Any test (or combination thereof) will be little more than
> probabilistic test. Using the constructor property can also be
> considered a duck-typing check.

I do not see a reason why the “constructor” property value should be mutable 
in the first place.  If it were not, it could at least provide for efficient 
tests where neither inheritance nor frame safety were issues.

> In the past I've espoused instanceof strongly over other methods if you
> might recall. You could simply follow the Self/SmallTalk tradition and
> simply act as if it WAS a RegExp until it explodes...

My thoughts exactly.  In languages as dynamic as ECMAScript implementations 
it is a mistake _not_ to delegate at least a part of the responsibility for 
proper input to the caller (do I need to cite evidence for the bloat created 
by following the opposite approach?).  Not only would that be more likely to 
produce false negatives, it would also miss the opportunity to make use of 
language power and elegance.

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.

It is unfortunate that almost everything in ECMAScript hinges on the Global 
Object of an execution context, that there are several global execution 
contexts, and that thereby the Specification forces its conforming 
implementations to be in such a way that methods like Array.isArray() are 
needed for the classification of objects in the first place.  It should not 
be necessary to have several RegExp objects just because there are several 
views (frames, windows, tabs).

A quick solution would be if there was a superglobal object that all native 
objects had in their prototype chain, or all global execution contexts had 
in their scope chain, so that “foo instanceof RegExp” would work regardless 
of callee and caller views as long as they were of the Same Origin.  The 
global object of execution contexts would then only have properties specific 
to that execution context and would delegate everything else to the 
superglobal object.

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