Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2016-02-01 Thread Yusuke SUZUKI
I've just prototyped bytecode intrinsic constants; enhancing bytecode
intrinsic mechanism to accept the form `@xxx`. (not `@xxx(...)`, it is
already introduced).
And implement @undefined with this.

https://bugs.webkit.org/show_bug.cgi?id=153737

On Tue, Dec 1, 2015 at 7:00 AM, Geoffrey Garen  wrote:

> > Seems like we should not have to wait long for the “long term”. It seems
> that the built-in compiler could start magically transforming “@undefined”
> instead of magically transforming “undefined” any time we like; likely a
> simple find and replace job. Or it could do both during a transition
> period. It could even treat a bare “undefined” as an error if we are
> worried that we will make that error.
>
> Yup.
>
> Geoff
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Geoffrey Garen
> Seems like we should not have to wait long for the “long term”. It seems that 
> the built-in compiler could start magically transforming “@undefined” instead 
> of magically transforming “undefined” any time we like; likely a simple find 
> and replace job. Or it could do both during a transition period. It could 
> even treat a bare “undefined” as an error if we are worried that we will make 
> that error.

Yup.

Geoff
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Darin Adler
> On Nov 30, 2015, at 11:57 AM, Geoffrey Garen  wrote:
> 
> For the time being, I like “x === undefined”.
> 
> Long term, I’d like us to switch to “x === @undefined”.
> 
> We use @ to indicate reserved words in built-ins. Currently, “@undefined" 
> does not exist, but the built-in compiler magically transforms “undefined” a 
> safe reserved word.
> 
> The typeof and void 0 code should be fast, but I find it obtuse.

Thanks for all the answers, everyone.

I like Geoff’s proposal.

Seems like we should not have to wait long for the “long term”. It seems that 
the built-in compiler could start magically transforming “@undefined” instead 
of magically transforming “undefined” any time we like; likely a simple find 
and replace job. Or it could do both during a transition period. It could even 
treat a bare “undefined” as an error if we are worried that we will make that 
error.

Then perhaps later we could relieve the built-in compiler of those 
responsibilities if we think that’s important.

— Darin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Ryosuke Niwa
On Mon, Nov 30, 2015 at 11:37 AM, Darin Adler  wrote:
> I see the following in some code:
>
> if (xxx === undefined)

FWIW, I always use this style.

- R. Niwa
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Brian Burg
Web Inspector’s frontend code tends to use “x === undefined”, as we’ve found it 
the easiest to read.

> On Nov 30, 2015, at 11:57 AM, Geoffrey Garen  wrote:
> 
> For the time being, I like “x === undefined”.
> 
> Long term, I’d like us to switch to “x === @undefined”.
> 
> We use @ to indicate reserved words in built-ins. Currently, “@undefined" 
> does not exist, but the built-in compiler magically transforms “undefined” a 
> safe reserved word.
> 
> The typeof and void 0 code should be fast, but I find it obtuse.
> 
> Geoff
> 
>> On Nov 30, 2015, at 11:39 AM, Filip Pizlo  wrote:
>> 
>> I’ve also been guilty of:
>> 
>>  if (xxx === void 0)
>> 
>> This is slightly better than saying “undefined”, since that’s not actually a 
>> reserved word.
>> 
>> I believe that all of these should perform the same.  We should pick one 
>> based on what looks nicest and what has the most clear semantics.
>> 
>> -Filip
>> 
>> 
>> 
>>> On Nov 30, 2015, at 11:37 AM, Darin Adler  wrote:
>>> 
>>> I see the following in some code:
>>> 
>>>  if (xxx === undefined)
>>> 
>>> And I see the following in some other code:
>>> 
>>>  if (typeof xxx == “undefined”)
>>> 
>>>  or
>>> 
>>>  if (typeof xxx === “undefined”)
>>> 
>>> Is one preferred over the other, style-wise? Is one more efficient than the 
>>> other?
>>> 
>>> — Darin
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>> 
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Chris Aljoudi
FWIW, performance seems to be equivalent:
http://jsperf.com/typeof-vs-undefined-check/39

Chris
https://chrismatic.io/

> On Nov 30, 2015, at 1:01 PM, Geoffrey Garen  wrote:
>
> For the time being, I like “x === undefined”.
>
> Long term, I’d like us to switch to “x === @undefined”.
>
> We use @ to indicate reserved words in built-ins. Currently, “@undefined" 
> does not exist, but the built-in compiler magically transforms “undefined” a 
> safe reserved word.
>
> The typeof and void 0 code should be fast, but I find it obtuse.
>
> Geoff
>
>> On Nov 30, 2015, at 11:39 AM, Filip Pizlo  wrote:
>>
>> I’ve also been guilty of:
>>
>>if (xxx === void 0)
>>
>> This is slightly better than saying “undefined”, since that’s not actually a 
>> reserved word.
>>
>> I believe that all of these should perform the same.  We should pick one 
>> based on what looks nicest and what has the most clear semantics.
>>
>> -Filip
>>
>>
>>
>>> On Nov 30, 2015, at 11:37 AM, Darin Adler  wrote:
>>>
>>> I see the following in some code:
>>>
>>>  if (xxx === undefined)
>>>
>>> And I see the following in some other code:
>>>
>>>  if (typeof xxx == “undefined”)
>>>
>>>  or
>>>
>>>  if (typeof xxx === “undefined”)
>>>
>>> Is one preferred over the other, style-wise? Is one more efficient than the 
>>> other?
>>>
>>> — Darin
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Geoffrey Garen
For the time being, I like “x === undefined”.

Long term, I’d like us to switch to “x === @undefined”.

We use @ to indicate reserved words in built-ins. Currently, “@undefined" does 
not exist, but the built-in compiler magically transforms “undefined” a safe 
reserved word.

The typeof and void 0 code should be fast, but I find it obtuse.

Geoff

> On Nov 30, 2015, at 11:39 AM, Filip Pizlo  wrote:
> 
> I’ve also been guilty of:
> 
>   if (xxx === void 0)
> 
> This is slightly better than saying “undefined”, since that’s not actually a 
> reserved word.
> 
> I believe that all of these should perform the same.  We should pick one 
> based on what looks nicest and what has the most clear semantics.
> 
> -Filip
> 
> 
> 
>> On Nov 30, 2015, at 11:37 AM, Darin Adler  wrote:
>> 
>> I see the following in some code:
>> 
>>   if (xxx === undefined)
>> 
>> And I see the following in some other code:
>> 
>>   if (typeof xxx == “undefined”)
>> 
>>   or
>> 
>>   if (typeof xxx === “undefined”)
>> 
>> Is one preferred over the other, style-wise? Is one more efficient than the 
>> other?
>> 
>> — Darin
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Preferred style for checking for undefined in our built-in JavaScript code?

2015-11-30 Thread Filip Pizlo
I’ve also been guilty of:

if (xxx === void 0)

This is slightly better than saying “undefined”, since that’s not actually a 
reserved word.

I believe that all of these should perform the same.  We should pick one based 
on what looks nicest and what has the most clear semantics.

-Filip



> On Nov 30, 2015, at 11:37 AM, Darin Adler  wrote:
> 
> I see the following in some code:
> 
>if (xxx === undefined)
> 
> And I see the following in some other code:
> 
>if (typeof xxx == “undefined”)
> 
>or
> 
>if (typeof xxx === “undefined”)
> 
> Is one preferred over the other, style-wise? Is one more efficient than the 
> other?
> 
> — Darin
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev