Revision history for JE

0.027   24 September, 2008
        Two bug fixes:
        • Array.prototype.splice now actually works. It used to mangle
          the array in strange ways.  It also used to die when  called
          on an object with no length property.
        • Constructors created by bind_class now pass all their argu-
          ments to the underlying Perl methods.  Thanks to Christian
          Forster for finding this bug. 
        Internals:
        • Various parts of JE were breaking  JE::String’s  encapsula-
          tion. Now they have been changed to use the value16 method,
          so that JE::String’s internals can be changed.

0.026   21 September, 2008
        One bug fix: Array.protoype.sort used to die with a custom
        sort routine.  Thanks to Christian Forster  for  reporting
        this (#39462).

0.025   15 September, 2008
        Incompatible change:
        • \cX escapes used always to match chr(ord(X) % 32),  so \c`,
          for instance, would match a null character. Non-alphabetic
          characters after the c  are actually syntax errors in ECMA-
          Script,  so there’s no reason we can’t follow Perl’s behav-
          iour here, which is what we do now.
        • Errors thrown in Perl and propagated through JavaScript now
          become plain Error objects, rather than TypeErrors.
        Bug fixes:
        • new Number no longer warns.
        • Function.prototype.apply no longer dies when the second
          argument is null.
        • Function.prototype.length is no longer enumerable.
        • String.prototype.slice now actually works.  It used to  die
          with more than one arg, and return an empty string and omit
          warnings otherwise.
        • String.prototype.substring no longer dies when both args are
          greater than the string’s length.
        • /)/ throws a SyntaxError instead of a nonsensical TypeError
          (when parsed by JS’s  eval  or  RegExp  functions;  a plain
          Perl string when parsed by JE’s  eval).  I  think  I  broke
          this in 0.022.
        • Embedded Perl code constructs  in  regular  expressions  now
          throw SyntaxErrors instead of TypeErrors or Perl strings, as
          in pre-0.022.
        • Back-references in regular expression that refer  to  cap-
          tures that did  not  participate  in  the  match,  as  in
          /(?:a|(x))\1/.exec("ab"), now match the null string (ECMA-
          Script-style),  instead of failing (the way Perl does it).
        • Back-references that are >= 10 and refer to captures that
          occur later in the pattern are now  null  string  matches
          (ECMAScript-style), instead of octal escapes (Perl-style).

0.024   29 July, 2008
        Changed the dependency on constant::private
        to constant::lexical, since that module has
        been renamed.
        Bug fixes:
        • String.length is now 1, not 0.
        • String.prototype.charAt and .charCodeAt no longer warn
          and behave incorrectly  when  passed  something  other
          than a number.
        • String.prototype.match and .search no longer die when passed
          null or undefined.
        • The index property of arrays returned by String.prototype
         .match and RegExp.prototype.exec  is now a number,  and no
          longer a string.
        • Fixed an obscure bug in the date module’s daylight saving
          adjustment which  would  sometimes  use  the  wrong  year.
        • str.indexOf('', num), where num > str.length,  no longer
          returns num in perl 5.10.0, but str.length, as it should.

0.023   25 July, 2008
        No functional changes. constant::private is now declared as a
        dependency in  Makefile.PL.  I forgot  to  add  this  to  the
        last release.

0.022   24 July, 2008
        New features:
        • RegExp.prototype.test and RegExp.prototype.toString have
          been added, so the RegExp class is complete.
        • Date.prototype’s setTime, setMilliseconds and
          setUTCMilliseconds methods has been added.
        • [] in a regular expression used to be an always-fail asser-
          tion.  This is no longer the case.  Now it follows  Perl’s
          behaviour  (the  ]  is interpreted as a literal  character
          within the class). I originally misread the spec.  This is
          actually a syntax error in ECMAScript.
        • Added an ‘unwrap’ option to bind_class, that makes it behave
          more sensibly in the author’s opinion.  This may become  the
          default in a future release.
        • Tainted code can now be run safely, and can no longer
          untaint its own data.
        Bug fixes:
        • String.prototype.replace
          • used to be a no-op when the second arg was a string (now
            it actually works); and
          • it used to die when either arg was null or undefined.
        • Quantified capturing parentheses in regular expressions now
          produce undefined if they do not participate in  the  match
          the last time the quantified subpattern matches.  This used
          to follow  perl’s  behaviour,  which is  inconsistent  (try
          matching "abb" against /((a)?b)+/  and  /((a+)?b)+/  to see
          what I mean). (Backreferences within a pattern still follow
          perl’s behaviour.)
        • Capturing parentheses within a negative lookahead assertion
          now produce undefined.  It used to be that a  pattern  like
          (?!(a)(?!))  would return  'a'  for the first capture  (the
          way perl does it).  (Back-references within a pattern still
          follow perl’s behaviour.)
        • String.prototype.split
          • used to return an array extended with undefined values
            when the limit was greater than the number of elements
            that the returned array should have had;
          • used to put an empty string at the  end  of  its  returned
            array if the separator was the empty string  or  a  regexp
            that could match the empty string (null matches at the end
            of the string are not supposed to count); and
          • used to die when passed undefined or null as its
            first argument.
        • Fixed a bug that caused a Function object that was  a  Perl
          subroutine underneath to die on returning if it happened to
          call ‘warn’ with no arguments. (Actually, I worked around a
          perl 5.8.8 bug.)
        • Quantified zero-width assertions in regular expressions
          with no maximum (i.e.,  quantified with * + {num,})  no
          longer warn.
        • String.fromCharCode now actually works,  instead of return-
          ing a string of null characters equal in length to the num-
          ber of args.
	• A String object’s length property (as opposed to that of a
          string) used to be a Perl scalar,  which caused JE’s inter-
          nals to hiccough on it.
        • Functions now stringify properly. Thanks to Alex Robinson
          for drawing my attention to it.

0.021   8 February, 2008
        Due to a silly mistake made at the last  minute,  the  newly-
        added Date class did not work at all in the previous release.
        Now this has been repaired,  the  Date  constructor can  now
        parse strings, Date.parse and Date.UTC have been added,  and
        all the methods have been added, except for the set* methods.

0.020   23 December, 2007
        Additions/changes:
        • The Date object has been added, though it is far from com-
          plete.  Only the Date object itself  (which does not  yet
          parse strings)  and the prototype’s getTime,  getYear and
          toGMTString methods have been added.
        • The escape and unescape functions have been added.
        • String.prototype.substr has been added.
        • JE::String now has a value16 method that returns the inter-
          nal UTF-16 version of the string.
        • JE::String also has now a ‘class’ method, that returns
         ‘String.’  This is intended primarily for internal  use.
        • If JE::Object::Function->new is called with no_proto => 1,
          the resulting function will now die when called as a  con-
          structor. This fixes an inconsistency with the spec.  for 
          all such built-in functions.
        • A string passed to  JE::Object’s  prop  method’s  autoload
          parameter is now evaluated in the package that called prop.
        Fixed bugs:
        • parseInt  has now been fixed to match the spec.  It used to
          return a string,  unless the return value was  0.  It  also
          used to behave unpredictably when  the  radix  was  out  of
          range,  instead of simply returning NaN.  It used always to
          return a positive number for radices other than  2,  8,  10
          and 16. And it used not to allow capital letters in numbers.
        • parseFloat used to produce 0 when fed a number  preceded  by
         \v or non-ASCII whitespace. It would emit warnings, too. This
          has been fixed.
        • isNaN and isFinite have now been fixed, so they return a boo-
          lean, rather than a string.
        • String.prototype.lastIndexOf now works.
        • The length property of functions is now a number,
          not a string.
        • parseInt, isNan, isFinite, decodeURI, decodeURIComponent,
          encodeURI and encodeURIComponent used to die when called
          with no args.
        • isFinite’s logic was flawed and probably would have failed
          on Windows and OpenBSD.  (I still don’t  know  whether  it
          works, or whether it even failed before; it just has a far
          greater chance of being portable now.)
        • decodeURI and decodeURIComponent used to die when passed an
          encoded UTF-8 sequence for a character outside the BMP.
        • decodeURI(Component) used to die when the input contained an
          unpaired surrogate.
        • decodeURI(Component) used not to die when fed encoded utf8
          characters > 0x10ffff.
        • decodeURI(Component)  used simply to  return  undefined
          (instead of throwing an error) if the URI contained mal-
          formed UTF-8 escape sequences.
        • decodeURI(Component) used to die if a UTF-8 escape sequence
          resulted in a surrogate, contrary to the spec.
        • encodeURI  used to encode any strings contained in  $,  and
          would produce “Use of uninitialized value” warnings if that
          var were undef, or return undefined if that variable caused
          a regexp syntax error when it was interpolated.
        • encodeURI used erroneously to encode $ and ,
        • encodeURI and encodeURIComponent used to throw TypeErrors,
          rather than URIErrors,  when  stumbling  across  unpaired
          surrogates.
        • encodeURI(Component) used to use lc hex digits
          instead of uc.
        • Many methods and functions throughout the code could  die
          when passed data containing a surrogate. This is fixed by
         ‘no warnings 'utf8'’, believe it or not.
        • isPrototypeOf used always to return false.
        • Object.length and  Function.length  used to be strings,  but
          are now numbers. They also used to be enumerable, but are no
          longer so.
        • hasOwnProperty and propertyIsEnumerable used to emit warn-
          ings and behave incorrectly when called with no arguments.
        • hasOwnProperty used to semi-autovivify the property, such
          that propertyIsEnumerable would find it,  as would for-in,
          but the ‘in’ op would not.
        • JE::LValue->can no longer dies instead of returning false
          when called as a class method.
        • The Function constructor now propagates syntax errors,
          instead of creating functions that do nothing.
        • JE’s parse and compile methods used to die when there was a
          regexp syntax error within a regexp literal or an invalid
          regexp modifier.

0.019  23 November, 2007
          One bug fix:  Methods and subroutines passed to  bind_class
          that are expected to return something were sometimes called
          in  list  context.  Now  they  are  always  called  in  sca-
          lar context.

0.018   5 November, 2007
        - bind_class now binds hash- or array-like classes.
        - For methods, properties, and primitivisation, bind_class
          supports type-casting/filters  (specify method names  as
         'foo:String', where 'String' is a JS function to feed the
          result of foo through).
        - Properties registered with bind_class can now be inherited
          by subclasses that are also registered with bind_class, as
          long as  'isa =>'  is given a  class  name  (not a   proto-
          type object).
        - If you don't specify  'to_primitive'  et al.  when you call
          bind_class, JE will now check to see whether the object has
          string/number/boolean overloading, and will use that. If it
          doesn't,  it continues to do the default JS thing  (use the
          valueOf and toString methods).

0.017   9 September, 2007
        Another alpha release, featuring just bug fixes:
        - Fixed a bug with the length property of strings being a Perl
          scalar instead of a JE::Number.
        - Fixed a bug that was causing line numbers in parse error
          messages to be counted from 1 even when another starting
          line number was given.
        -'continue' and 'break' statements now no longer clobber the
          return value of the previous statement, so
          eval('do{3; continue} while(0)') now returns 3, in accord-
          ance with the spec.
        - In a variable initialiser such as var a = b, the value is
          now correctly extracted from b and put inside a. Before, a
          reference to b would be put in a, such that
         'var a=non_existent_var; do_something_with(a)' would throw an
          error on the second statement, not the first.
        - Fixed a problem with 'continue OUTER' statements in nested
          loops calling the loop condition on the inner loop first.
          E.g., in the following snippet:
            var x = 0, y = 0
            OUTER: while(++x < 2) while(++y < 2) continue;
          The 'continue' would make '++y < 2' get evaluated, and then
         '++x < 2'; whereas only the latter should be evaluated. This
          problem was affecting do, while and for(;;) loops.
        - for(;;) loops now work when there is nothing before the
          first semicolon.
        - RegExp.prototype.exec now actually works (not fully tested)
          instead of always dying.
        - switch(non_existent_var) now dies as it should.
        - In a try-catch-finally statement, return, break and contin-
          ue statements and errors within the catch block no  longer
          prevent the final block from running.

0.016   22 July, 2007
        New feature:
        - Added support for filenames and line numbers in
          error messages.
        Bug fix:
        - Added a workaround for a perl 5.8.x bug (#24254) that was
          causing errors thrown from  expressions  within  argument
          lists to trigger an  "Attempt to  free  unreferenced  sca-
          lar" warning.

0.015   10 June, 2007
        - JS properties can now be bound to Perl subroutines that
          store/fetch the value (see JE::Types).
        - Class bindings now support binding of properties, as well
          as methods.
        - The constructor_name argument to bind_class is gone, since
          it was confusing.
        - bind_class now will understand 'package' to be the same as
         'name' if only the latter is provided.
        - bind_class now creates a constructor  whether  or  not  the
         'constructor' argument is passed. If it is not, the construc-
          tor that it makes will throw an error when invoked.
        - JE::Scope's get_var method has been renamed to find_var,
          since the name 'get_var' has the wrong implications.

0.014   30 May, 2007
        Features and API changes:
        - Binding of Perl classes to JE with the new bind_class method
        - JE::Parser's delete_statement method now takes mul-
          tiple args.
        Bug fixes:
        - JS's eval function now uses the same parser if called from
          code that was parsed with a custom parser.
        - JE::Object's prop({...}) method used to infer  'dontenum =>
          0' even if the property already existed.  Now it leaves the
          enumerability of existing properties alone if 'dontenum' is
          not specified explicitly.
        - Fixed a problem with bus errors resulting from  'autoload'
          handlers executing JS code when called from a tie handler
        - The & ^ | operators now work correctly when the second oper-
          and is outside the signed 32-bit range.

0.013   20 May, 2007
        Features and API changes:
        - JavaScript properties can now be autoloaded.
        - &JE::Scope::var has been renamed to &JE::Scope::get_var,
          since it was too easily confused with JavaScript's 'var'
          keyword, which does something different.
        - Started work on parser customisation
        Bug fixes:
        - '==' and '!=' were not correctly determining which type of
           comparison to do  when  the  two  operands  were  of  dif-
           ferent types.
        -  throw now requires an expression, as it always should
           have done.

0.012   13 May, 2007
        Yes, another alpha release.
        - JE::Object::Array's array dereference handler now returns a
          tied array.
        - JE::Object::Array's 'value' method now returns a copy of the
          object's internal array, instead of the array itself.
        - Functions created with new_function are now enumerable, just
          like 'alert', et al. in web browsers.
        Bug fixes:
        - Fixed the JE::Object's tie handlers so that  autovivification
          now works, and delete behaves the way it usually does in Perl.
        - When $obj->prop({ ... }) creates a new property and dontenum
          is not given, the property is now enumerable.
        - Corrected Array.prototype.unshift so that it resets the
          array's length.
        - JE::Object::Function's 'apply' method now upgrades the argu-
          ments to the function if the function is  written  in  Perl
          (version 0.011 only half-fixed the problem)

0.011   10 May, 2007
        Oh no! Another alpha release!
        - JE::Object::Function's 'apply' method now upgrades the argu-
          ments to the function
        - JE::Object's %{} overloading now returns a tied hash that
          can be used to modify the object  (untested and  still  a
          bit buggy).

0.010   9 May, 2007
        Added three features:
        - &{} overloading for JE::Object::Function
        - numeric overloading for JE::Object
        - 'exists' method for JE::Object and JE::Object::Array
        One bug fix:
        - JE::Object::Array's is_enum now correctly returns false for
          the length property

0.009   8 May, 2007
        Yet another alpha release. Here are the usual lists:
        New features/API changes:
        - Added numeric overloading to JE::Null.
        - Added compile as an alias for parse.
        - Added the 'exists' and 'class' methods to JE::Number
        Fixes:
        - JE::LValue's overloading was very buggy with anything other
          than  simple  conversion.  I've  fixed  it  and  written  a
          test script.
        - Corrected the bitshift operators such that numbers > 31 for
          the right operand now have % 32 applied, and are no  longer
          simply treated as 31.
        - Corrected JE::Null->to_boolean so it returns a JE::Boolean,
          not a JE::String.
        - Stopped surrogate escape sequences in string literals from
          producing warnings.
        - Corrected JE::Number's stringification overloading to match
          the stringification in JavaScript  (for NaN  and  Infinity)
        - A JE::Number that has a value of NaN now boolifies in  Perl
          as false, as in JavaScript.
        - Fixed the constructors for the various subclasses of Error,
          so that they no longer throw TypeErrors when called  ('new
          TypeError'  would actually cause the whole script to  die)
        - Corrected 'instanceof'  so it throws an error if its right
          operand is an object but not a function
        - Corrected the  'prototype'  properties of the various sub-
          classes of Error such that they now actually inherit from
          Error.prototype instead of directly from Object.prototype.
        - Fixed the << operator so it now works correctly on
          64-bit machines

0.008   22 April, 2007
        New features and API changes in this release:
        - Added JE::LValue's can method
        - new_function has been moved from JE to JE::Object, to make
          it more versatile
        - new_method has been written as a method of JE::Object
        - Changed the interface of JE::Code's 'execute' method, so that
          the third arg has three possible values  for  indicating  the
          type of code, and is no longer a boolean
        - Changed the delete method of JS values to support a second
          arg (see JE::Types)
        - Renamed the 'props' method to 'keys'
        - Renamed JE::compile to JE::parse
        - Added the 'exists' and 'class' methods to JE::Boolean
        - Added numification overloading to JE::Boolean
        Bug fixes:
        - Fixed the ~ operator so it works on 64-bit platforms
        - Changed most calls to 'UNIVERSAL::isa($thing, UNIVERSAL)' to
         'defined Scalar::Util::blessed $thing', since the former also 
          works with strings containing package names  (and  does  not
          necessarily tell whether something is blessed). This bug was
          causing strange errors.
        - Fixed a bug that was making errors thrown by JS  functions
          called from within JavaScript cause lots of warnings and a
          nonsensical ReferenceError.
        - String.prototype.substring now works instead of
          always dying.
        - function and var declarations now work in else blocks and
          labelled statements
        - continue <label> now works within a labelled switch or iter-
          ation statement
        - JS functions now return undefined when there is no  explicit
         'return'  statement.  Before,  the return value of  the  last
          statement that returned one was being  used,  as  with  JS's
         'eval' function (oops!). This required changing the interface
          of JE::Code slightly.
        - function declarations now clobber attributes of
          existing vars
        - Code run by JS's eval now inherits the scope chain from the
          caller (before, it was getting its own,  just like the body
          of a JS function)
        - var declarations no longer make existing vars undeletable
        - JE::Scope::new_var now looks for the first  object  in  the
          scope chain that is a call object (it used to use the first
          object, whatever it was)
        - Calling an lvalue that has a call (activation) object as its
          base object now works instead of just dying.
        - arguments.length is now a number, not a string
        - arguments objects are no longer given extra properties  cor-
          responding to the function's parameters if there aren't that
          many args.
        - Functions written in Perl that return  an  empty  list  now
          return 'undefined' to JS, instead of producing lots of warn-
          ings and dying.  In fact, they are called in scalar context
          now, rather than list context.
        - Fixed array literals so that elided elements do not exist.
          (Before, they would exist, but still be undefined.)
        - Fixed the bug that was causing isNaN to fail on OpenBSD.
        - Corrected the comma, assignment, conditional (? :), || and
          && operators so they no longer return lvalues.
        - Function.prototype.apply now puts its error in $@ when it
          dies. It used to leave $@ empty. It no longer dies when
          called with just one argument.
        - Fixed Array.prototype.toString and Array.prototype.
          toLocaleString such that they produce a sensible error mes-
          sage when invoked upon an object other than an array, rather
          than the nonsensical 'Can't locate object method "prop" via
          package "Object is not an Array"'
        - String.prototype.split now actually works.
        - JE::Code::parse now  stringifies  its  input,  avoiding  the
          potential problem of pos() being unreliable on a stringified
          object,  and solving the problem with  $obj =~ /(...)/  man-
          gling $1 in perl 5.8.5.

0.007   April Fool's Day, 2007
	Alpha release. New features/fixes:
        - Added the RegExp constructor and RegExp.prototype.exec
        - Added the rest of the string methods
        - Added the Boolean, Number and ReferenceError classes
        - Added the Math object
        - Fixed 'return' without an argument, so it returns undefined,
          rather than a null Perl string  (which  was  causing  weird
          errors elsewhere).
        - 'break' called from within a labelled statement was produc-
          ing warnings (fixed)
        - 'throw' without an argument now throws undefined, rather
          than 'Died at /usr/local/lib/perl5/5.8.8/JE/Code.pm
          line 387'
        - 'continue' now works with a do-while loop
        - instanceof now works instead of just dying
        - Assigning to a writeable property used  to  overwrite  the 
          dontenum attribute and make the property enumerable (fixed)
        - Fixed lvalues such that 'null.var = val' no longer creates a
          global property.  'null.var'  in void context now  throws  a
          TypeError.
        - Fixed the null and undefined classes, so they don't try to
          rebless the same scalar as each other.
        - Fixed the boolean class's to_string method, so it no longer
          gives 'true' for false and 'false' for true (!).

0.006   29 March, 2007
        Alpha release.
        - Added TypeError and RangeError classes
        - Finished the Function and Array classes (except for
          Function.prototype.toString)
        - JE::String now has an exportable 'surrogify' function
        - Added some methods (toString, valueOf, charAt, charCodeAt,
          concat, indexOf, lastIndexOf,  localeCompare)  to  String
          objects, and added the String constructor to the
          global object
        - Found and fixed quite a few bugs in the parser:
          o || && were parsing as | |  and & &
          o Hexadecimal literals would cause syntax errors
          o The parser would create a garbage tree when certain infix
            ops were followed by compound expressions that could  con-
            tain the same op (i.e., [], {}, () and function literals).
            (I fell into the 'sub foo { /regex(.*)/; foo(); print $1}'
            trap.)
          o Bracketed subscripts did not allow whitespace before the
            closing bracket
          o "a++\nb++"  without a semicolon between the two statements
            was causing a syntax error because -- and ++ were gobbling
            up trailing whitespace.
          o <<= and >>= and >>>= were causing syntax errors
          o for loops with variable declarations in the header
            weren't parsing
          o continue/throw/break/return were not parsing correctly
            when followed by a line break
          o 'with' was parsing as 'while' (!)
          o switch and try blocks weren't parsing correctly

0.005   5 March, 2007
        Alpha release. Changes and additions:
        - The parser has been rewritten completely with recursive sub-
          routines.  It is now faster than before,  and doesn't cause
          bus errors.
        - The Error and SyntaxError classes now actually work. Before
          I just threw them together without even testing them.
        - The Object constructor is now according to spec.
	- URI-handling functions and the URIError class
        - Added the rest of Object.prototype's properties

0.004   19 February, 2007
        Alpha release. New features and bug fixes in this
        release include:
        - Support for all JavaScript statements, not just expression
          statements
        - JE::String now provides a desurrogify function.
        - JE::upgrade now supports coderefs and makes '0' into a num-
          ber, as the docs say it does.
        - The JE::new_function method has been added.
        - Overloading for JE::LValue objects
        - JE::Object::props now returns the names of the object's pro-
          totype's properties as well as the object's own
        - Error and SyntaxError classes
        - Function literals and declarations
        - '==' in JS now does string comparison if at least one oper-
          and is a string  (it used to determine that it  should  do
          string  comparison  and  then  do  numeric  equals  anyway,
          because I typed '==' by mistake instead of 'eq'!)

0.003   14 February, 2007
        Alpha release. All JavaScript operators are now supported. JS
        numbers now use Perl's nan and inf.  A few bugs in the object
        classes have been fixed.  A bug preventing the  expansion  of
        backslash escapes in string literals has been fixed.

0.002   7 February, 2007
        Still a pre-alpha version with almost no features and lots of
        bugs. A lot of work has been done on the object classes.  The
        parser is half-written,  but the code that actually  executes
        the parse tree is far from complete.  The only really noticea-
        ble new features are that array and object literals and  iden-
        tifiers are now parsed and interpreted.

0.001   24 January, 2007
        Pre-alpha version,  with almost no features and lots of  bugs.
        The man pages describe many features that have not been imple-
        mented, so it's all just talk.

