Intrinsic namespace proposal

(Also see the discussion page for this proposal)

For builtin classes/which prototype, catchalls, hashcodes, operators, and probably other places, we would like an intrinsic namespace that can be used to access a built-in or default function or operator, no matter the user-defined override. The intrinsic properties should in general be immutable ({DontDelete, ReadOnly}) for early binding. For example,

  this.intrinsic::get(ident)

would always return the value of ident in the scoped this.

Or for a Complex number class, the + operator static method might look like this:

  class Complex {
    . . .
    public static function +(a:*, b:*):* {
      if (b === null) {
        // Handle unary + here
        return a
      }
      if (a is Complex && b is Complex) {
        // Perform complex addition on a and b and return the result
        return result
      }
      return intrinsic::+(a, b)
    }
  }

This namespace constant should be the one globally polluting identifier added for ES4, if we can help it. We need to test that no or few web pages assign to intrinsic.

Brendan Eich 2006/05/04 16:32

List of intrinsic names and their meanings:

  • Unary operators +, -, ~
    • Standard meaning but unaffected by the use <number type> pragma; these always operate as if no pragma is in effect. See operators.
  • Binary operators +, -, *, /, %, <<, >>, >>>, &, |, ^, <, <=, >, >=, ==, !=, ===, !==
    • Standard meaning but unaffected by the use <number type> pragma; these always operate as if no pragma is in effect. See operators.
  • get, set, call
    • Non-overridable property lookup and mutation, and universal nonoverridable call handler. See catchalls.
  • Null, Undefined, int, double, uint, decimal, Number, Date, RegExp, Boolean, String, Function, Array, Object
    • These names denote type values always. See type system.
  • hashcode
    • Computes a hash code for an object. See hashcodes
  • global
    • Returns a reference to the global object. See minutes_jul_27_2006, there is no separate proposal for this.
  • wrap
  • (please add more + references as you find them)

Lars T Hansen 2006/09/21 09:07

 
proposals/intrinsic_namespace.txt · Last modified: 2008/07/14 18:31 by jodyer
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki