So how about implementing toBoolean as an overridable method, which is
called whenever !, || or are used. This way an objec has three method
for converting it into a primitive; toString, toValue and toBoolean.
Marius Gundersen
On Sun, Sep 8, 2013 at 2:19 AM, Till Schneidereit
Did you read my reply on this point?
https://mail.mozilla.org/pipermail/es-discuss/2013-September/033234.html
Anything unclear?
/be
Marius Gundersen mailto:gunder...@gmail.com
September 8, 2013 3:47 AM
So how about implementing toBoolean as an overridable method, which is
called whenever !,
Never having a toBoolean hook would be quite constraining. The example from
that e-mail involved:
var huh = (obj || foo) bar;
And the problem is that a valueOf or toBoolean hook on 'obj' could result in it
being called multiple times, and since the hook is written in JS it could be
Thanks for this reply.
Filip Pizlo
September 8, 2013
1:56 PM
We
have two choices:A) Reject the notion that
'obj' appearing once in the original source results in multiple calls to
some hook on 'obj' (valueOf, toBoolean, whatever).B) Allow
multiple calls along with
The only thing that is unclear is the reason memoizatation isn't used. It
would seem to be the way most of the js engines would implement this
anyways. I'm not familiar with the inner workings of JavaScript JIT
engines, but in a situation like this, would that code not be compiled into
something
Marius Gundersen mailto:gunder...@gmail.com
September 8, 2013 3:20 PM
The only thing that is unclear is the reason memoizatation isn't used.
It would seem to be the way most of the js engines would implement
this anyways.
This isn't an implementation question -- first we have to agree on
While playing around with valueOf, I discovered that three operators (!,
||, ) don' seem to use valueOf when you use them. You can test this in
your preferred browser here: http://lab.mariusgundersen.net/valueOf
Is there a reason for this? Shouldn't these operators work the same way as
the other
On Sep 7, 2013, at 9:10 AM, Marius Gundersen wrote:
While playing around with valueOf, I discovered that three operators (!, ||,
) don' seem to use valueOf when you use them. You can test this in your
preferred browser here: http://lab.mariusgundersen.net/valueOf
Is there a reason for
Marius Gundersen mailto:gunder...@gmail.com
September 7, 2013 9:10 AM
While playing around with valueOf, I discovered that three operators
(!, ||, ) don' seem to use valueOf when you use them. You can test
this in your preferred browser here:
http://lab.mariusgundersen.net/valueOf
Is there a
That's the way ToBoolean has always been defined
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.1.2 . All
objects are considered to be Boolean true values.
So does this mean I can override toBoolean to change the way ! behaves on
an object?
Marius Gundersen
On Sun, Sep 8, 2013 at 2:15 AM, Marius Gundersen gunder...@gmail.comwrote:
That's the way ToBoolean has always been defined
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.1.2 . All
objects are considered to be Boolean true values.
So does this mean I can override toBoolean to
11 matches
Mail list logo