Re: Existential operator (was: ||= is much needed?)

2012-06-22 Thread Jeremy Ashkenas
On Thu, Jun 21, 2012 at 5:55 PM, Aymeric Vitte vitteayme...@gmail.comwrote: According to my previous posts I am quite convinced it has an interest, I remain perplex regarding the use of ?( , then, I am really curious to see CS's uses, could you please highlight some projects ? Certainly.

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Herby Vojčík
Brendan Eich wrote: Herby Vojčík wrote: I feel there is objection to introduce magical [[NullPatternObject]] into language, but all of CS-style soft-accesses could be solved very cleanly and consistently. No, because (a) the overhead of a new object is too high; (b) with any kind of

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Herby Vojčík
Brendan Eich wrote: Herby Vojčík wrote: I feel there is objection to introduce magical [[NullPatternObject]] into language, but all of CS-style soft-accesses could be solved very cleanly and consistently. No, because (a) the overhead of a new object is too high; (b) with any Spec / impl

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Domenic Denicola
On Jun 21, 2012, at 3:22, Herby Vojčík he...@mailbox.sk wrote: Brendan Eich wrote: Herby Vojčík wrote: I feel there is objection to introduce magical [[NullPatternObject]] into language, but all of CS-style soft-accesses could be solved very cleanly and consistently. No, because (a)

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread John Tamplin
So do you have to do it by treating the ?. operator as a standalone? Instead, could you do the indefinte soak part during parsing, treating the rest of the expression differently after having seen a ?. operator? -- John A. Tamplin Software Engineer (GWT), Google

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Brendan Eich
John Tamplin wrote: So do you have to do it by treating the ?. operator as a standalone? Not sure what you mean here -- standalone ? (with an English-langauge ? implied after in your sentence? ;-)? Or something else that amounts to a concealed Reference or Nil-value-proxy expression? Just

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Brendan Eich
Brendan Eich wrote: Thus foo?.bar.baz.quux is really (((foo?.bar).baz).quux). So (as many have noted) parenthesization does not call GetValue in ECMA-262: 11.1.6 The Grouping Operator The production PrimaryExpression : ( Expression ) is evaluated as follows: 1. Return the result of

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread John Tamplin
On Thu, Jun 21, 2012 at 11:23 AM, Brendan Eich bren...@mozilla.org wrote: John Tamplin wrote: So do you have to do it by treating the ?. operator as a standalone? Not sure what you mean here -- standalone ? (with an English-langauge ? implied after in your sentence? ;-)? Or something else

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Brendan Eich
John Tamplin wrote: On Thu, Jun 21, 2012 at 11:23 AM, Brendan Eich bren...@mozilla.org mailto:bren...@mozilla.org wrote: John Tamplin wrote: So do you have to do it by treating the ?. operator as a standalone? Not sure what you mean here -- standalone ? (with an

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Herby Vojčík
Brendan Eich wrote: Replying to both Herby and Domenic here. Domenic Denicola wrote: On Jun 21, 2012, at 3:22, Herby Vojčíkhe...@mailbox.sk wrote: Brendan Eich wrote: Herby Vojčík wrote: I feel there is objection to introduce magical [[NullPatternObject]] into language, but all of

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Brendan Eich
Herby Vojčík wrote: Adn that is precisely what I proposed under name [[NullPatternObject]]. So all of (1), (3), (4) and (5) are void. Apologies, I missed that and saw only someone (perhaps it was Domenic) write ({}) as the default value, which is not the same. Such a Nil proxy still cannot

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Herby Vojčík
Brendan Eich wrote: Herby Vojčík wrote: Adn that is precisely what I proposed under name [[NullPatternObject]]. So all of (1), (3), (4) and (5) are void. Apologies, I missed that and saw only someone (perhaps it was Domenic) write ({}) as the default value, which is not the same. Such a

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Brendan Eich
Herby Vojčík wrote: That I cannot envision... but Null Pattern object that produces itself for all operations ([[Get]], [[Call]], ...) should not be problematic. You might be surprised (I am) by how seemingly innocent things can become problematic. Just on aesthetic grounds, I bet TC39ers

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Herby Vojčík
Brendan Eich wrote: Herby Vojčík wrote: That I cannot envision... but Null Pattern object that produces itself for all operations ([[Get]], [[Call]], ...) should not be problematic. You might be surprised (I am) by how seemingly innocent things can become problematic. Just on aesthetic

Re: Existential operator (was: ||= is much needed?)

2012-06-21 Thread Aymeric Vitte
I guess the grep work is not easy to do, but I have tried (manually) to find ?. or ?( in coffee script projects, trying to seek into projects of main contributors. Maybe not lucky or not really aware of the most popular projects, but I did not find any up to now. According to my previous

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Allen Wirfs-Brock
On Jun 20, 2012, at 7:18 AM, John Tamplin wrote: On Tue, Jun 19, 2012 at 1:34 PM, Jeremy Ashkenas jashke...@gmail.com wrote: Allen asks about when you would want to write `foo?.bar()` ... the only use case I can think of is when `foo` may or may not be defined, and you know that if it

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Brendan Eich
Allen Wirfs-Brock wrote: I was hypothesizing that Brendan's semantics would seldom be the programer's intent for person?.getName() . If an exception was acceptable, why wouldn't you just say: Because it's rare to have a maybe-method called on a maybe-object, based on CoffeeScript experience

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Allen Wirfs-Brock
On Jun 20, 2012, at 10:45 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: I was hypothesizing that Brendan's semantics would seldom be the programer's intent for person?.getName() . If an exception was acceptable, why wouldn't you just say: Because it's rare to have a maybe-method

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Brendan Eich
Brendan Eich wrote: Let's look at what CoffeeScript requires to avoid this exception: $ cat /tmp/z.coffee person = {} person?.getName?() $ ./bin/coffee -p /tmp/z.coffee (function() { var person; person = {}; if (person != null) { if (typeof person.getName === function) {

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Brendan Eich
Allen Wirfs-Brock wrote: yes, that's what I was proposing. I think calls need to be part of the overall discussion for this feature area. Jeremy is kindly grepping more codebases, but just from CoffeeScript (self-hosted) source itself, ?. is 42, ?[ is 7, and ?( is 3 -- so 12:2:1. Supports

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread John Tamplin
On Wed, Jun 20, 2012 at 12:47 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: yes, but in a static Java-like language such as for you example above, the existence of person implies the existence of the getName method. The JS equivalent would likely be something like: Is it really rare to

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Brendan Eich
Brendan Eich wrote: This is infelicitous compared to putting ? first because it separates the ? from the maybe-nully left operand too much, and looks ugly (to Spanish readers it looks even more wrong). It's also a loss to deviate from CS, but we can't do ?( so we're half (or 1/14th by the

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Herby Vojčík
Brendan Eich wrote: Allen Wirfs-Brock wrote: yes, that's what I was proposing. I think calls need to be part of the overall discussion for this feature area. Jeremy is kindly grepping more codebases, but just from CoffeeScript (self-hosted) source itself, ?. is 42, ?[ is 7, and ?( is 3 --

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Brendan Eich
Herby Vojčík wrote: Let's allow foo.? to denote soft foo, so you get: foo.?.bar// foo == null ? undefined : foo.bar foo.?(bar)// foo == null ? undefined : foo(bar) foo.?[bar]// foo == null ? undefined : foo[bar] ?. works as well for these and the main (by use-frequency, so far)

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Herby Vojčík
Brendan Eich wrote: Herby Vojčík wrote: Let's allow foo.? to denote soft foo, so you get: foo.?.bar // foo == null ? undefined : foo.bar foo.?(bar) // foo == null ? undefined : foo(bar) foo.?[bar] // foo == null ? undefined : foo[bar] ?. works as well for these and the main (by

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Brendan Eich
Herby Vojčík wrote: I feel there is objection to introduce magical [[NullPatternObject]] into language, but all of CS-style soft-accesses could be solved very cleanly and consistently. No, because (a) the overhead of a new object is too high; (b) with any kind of suffix-? or suffix-.? as you

Re: Existential operator (was: ||= is much needed?)

2012-06-20 Thread Jeremy Ashkenas
As requested, running those rough greps again on the top ten most popular CoffeeScript repos on Github yields: 188 uses of object?.property 32 uses of object?[key] 50 uses of function?(args) 46 uses of variable ?= value ... and the other ones are a bit tricker to grep for. There are at least

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: This proposal augments the default operator http://wiki.ecmascript.org/doku.php?id=strawman:default_operator by adding syntax to avoid accessing a missing property, specifically |?.| for getting and setting a property from a reference base that might be |undefined| or

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread David Bruant
What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would become: let greedy = silent obj.hints.greedy; The semantic would be exactly the same. The syntax is up to debate. Specifically, it would be nice to be able to

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Hemanth H.M
As there is no keyword as 'or' so far, does something like *x = x.value or 5 *sound better? On Tue, Jun 19, 2012 at 3:00 PM, David Bruant bruan...@gmail.com wrote: What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 12:44 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: This proposal augments the default operator http://wiki.ecmascript.org/doku.php?id=strawman:default_operator by adding syntax to avoid accessing a missing property, specifically |?.| for getting and setting a

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Herby Vojčík
Allen Wirfs-Brock wrote: On Jun 19, 2012, at 12:44 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: This proposal augments the default operatorhttp://wiki.ecmascript.org/doku.php?id=strawman:default_operator by adding syntax to avoid accessing a missing property, specifically |?.| for

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 2:30 AM, David Bruant wrote: What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would become: let greedy = silent obj.hints.greedy; A hazard with this approach is that it could silence a

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
David Bruant wrote: What about a more generic operator that would be able to silently absorb any error? let greedy = obj.hints?.greedy; would become: let greedy = silent obj.hints.greedy; Ignoring exact syntax, I don't think we want more general throwing suppression. The goal with

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: I still stand by my alternative semantics as being a way to address the more important use case without have ?() No, the basis cases differ and that is a bug in your alternative. foo?.bar means take bar from foo or undefined if foo == null. foo?.bar() means take bar

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Brendan Eich wrote: Allen Wirfs-Brock wrote: I still stand by my alternative semantics as being a way to address the more important use case without have ?() No, the basis cases differ and that is a bug in your alternative. foo?.bar means take bar from foo or undefined if foo == null.

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
Sorry -- an old inbox filter caused me to miss this... There were a couple of questions asked in the thread, but I think it might be helpful to summarize the overall rationale first. The existential operator in CoffeeScript (?) is intended to make it easier to ask questions about whether values

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Another problem with your alternative: either it breaks a refactoring equivalence. Let == be equivalence for a program fragment, and != be inequivalence. Then we have in JS today extended with do expressions (and gensym via $tmp): foo.bar() == do {let $tmp = foo.bar; $tmp.call(foo)} Now

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Brendan Eich wrote: Another problem with your alternative: either it breaks a refactoring equivalence. ... or it leaks maybe-Reference type values into the language. /be ___ es-discuss mailing list es-discuss@mozilla.org

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Jeremy Ashkenas wrote: Everywhere else in the language, `?` means existence (not null or undefined) -- but when used to call a function, the check ensures that the value is callable as well. In a DWIM sense, this makes sense, because the only things you'd ever want to try to call in

RE: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Domenic Denicola
Ashkenas Cc: es-discuss Subject: Re: Existential operator (was: ||= is much needed?) Jeremy Ashkenas wrote: Everywhere else in the language, `?` means existence (not null or undefined) -- but when used to call a function, the check ensures that the value is callable as well. In a DWIM sense

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Herby Vojčík
Brendan Eich wrote: Jeremy Ashkenas wrote: Everywhere else in the language, `?` means existence (not null or undefined) -- but when used to call a function, the check ensures that the value is callable as well. In a DWIM sense, this makes sense, because the only things you'd ever want to try

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
That's possible but it is a bit ugly, isn't it? Also, as dherman observed, ?. and variations are different from defaulting, in one point of view. That is, avoiding dereferencing a value that does not coerce to object is the purpose of ?. but not necessarily of ??= (or || as used for

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Herby Vojčík wrote: Will you include options.success?.[index] then, too? I wasn't planning on it. CoffeeScript does not have any such thing (spelling it ?[ would be hard in CS too, due to array literals). Could add it in the future, trying not to overdo the strawman at this point. YAGNI and

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
On Tue, Jun 19, 2012 at 2:59 PM, Brendan Eich bren...@mozilla.org wrote: Herby Vojčík wrote: Will you include options.success?.[index] then, too? I wasn't planning on it. CoffeeScript does not have any such thing (spelling it ?[ would be hard in CS too, due to array literals). Could add

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 10:31 AM, Brendan Eich wrote: Brendan Eich wrote: Allen Wirfs-Brock wrote: I still stand by my alternative semantics as being a way to address the more important use case without have ?() No, the basis cases differ and that is a bug in your alternative. foo?.bar

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Jeremy Ashkenas wrote: On Tue, Jun 19, 2012 at 2:59 PM, Brendan Eich bren...@mozilla.org mailto:bren...@mozilla.org wrote: Herby Vojčík wrote: Will you include options.success?.[index] then, too? I wasn't planning on it. CoffeeScript does not have any such thing

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: I don't agree, probably because I'm look at ?. as an operator that evaluates to a special kind of Reference. That your alternative off-by-one in its basis case is bad enough -- it creates two error suppression points from one syntactic extension-point, it will hide

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 10:50 AM, Brendan Eich wrote: Another problem with your alternative: either it breaks a refactoring equivalence. Let == be equivalence for a program fragment, and != be inequivalence. Then we have in JS today extended with do expressions (and gensym via $tmp):

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Brendan Eich wrote: Worse, instead of leaking an observable ConditionalReference (whew!), you've opted to break the equivalence between foo.bar() and %tmp = foo.bar; %tmp.call(foo) for the case where . is replaced by ?. -- in this case your proposal does not throw while the expansion does.

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 12:26 PM, Brendan Eich wrote: Brendan Eich wrote: Worse, instead of leaking an observable ConditionalReference (whew!), you've opted to break the equivalence between foo.bar() and %tmp = foo.bar; %tmp.call(foo) for the case where . is replaced by ?. -- in this case your

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brandon Benvie
Is it possible to do something like foo.bar?:(foo, args) Basically a ternary that allows an empty component, and can tell the future (whether the other result is callable) ___ es-discuss mailing list es-discuss@mozilla.org

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
On Tue, Jun 19, 2012 at 3:33 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: foo.bar?(args) == foo.bar?.call(foo, args) fun?(args) == fun?.call(undefined, args) How are these equivalent? Won't fun?.call evaluate to undefined if fun is undefined and undefined(undefined,args) will

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 12:37 PM, Jeremy Ashkenas wrote: On Tue, Jun 19, 2012 at 3:33 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: foo.bar?(args) == foo.bar?.call(foo, args) fun?(args) == fun?.call(undefined, args) How are these equivalent? Won't fun?.call evaluate to

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Jeremy Ashkenas
On Tue, Jun 19, 2012 at 4:35 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: Ah, interesting...so this is actually close to what I was advocating for this particular case. However, if I now understand correctly you are saying that fun?.call() produces undefined if fun is

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Allen Wirfs-Brock
On Jun 19, 2012, at 2:15 PM, Jeremy Ashkenas wrote: On Tue, Jun 19, 2012 at 4:35 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: ... Ha ha, loose equality strikes again! It's actually guarding for both null and undefined. It's the only place that CoffeeScript purposefully uses the

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Allen Wirfs-Brock wrote: On Jun 19, 2012, at 10:50 AM, Brendan Eich wrote: Another problem with your alternative: either it breaks a refactoring equivalence. Let== be equivalence for a program fragment, and!= be inequivalence. Then we have in JS today extended with do expressions (and

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Brendan Eich
Indeed I did not spec this in http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator#semantics -- one step at a time. Also I'm not sure how the indefinite soak will fly with others on TC39. Allen, I agree if we do make a soak and don't spec it as CoffeeScript realizes it (by

Re: Existential operator (was: ||= is much needed?)

2012-06-19 Thread Aymeric Vitte
Complement for my last sentence : if you are using ?. it means that you don't know if the thing does exist, then you are probably waiting for it to exist (asynchronous environments for example), then once you get it, it is very unlikely that you call it right away, I would like to see some

Re: ||= is much needed?

2012-06-18 Thread Wes Garland
Yes, we could make ?? and ??= do the same for null as for undefined. I'm not sure that's the right choice, but it's a choice. Introducing yet another way to think about values in ES is not going to help most programmers. We already have to think about thinks like undefined and falsey -- what's

Re: Existential operator (was: ||= is much needed?)

2012-06-18 Thread Aymeric Vitte
This is related to what I was trying to figure out in the more fun with undefined thread, maybe it is wrong or have too many impact but I was about to suggest : 8.9.1 GetValue (V) ... 5. If IsUnresolvableReference(V), return undefined 11.2.1 Property Accessors Runtime Semantics: Evaluation

Re: Existential operator (was: ||= is much needed?)

2012-06-18 Thread Brendan Eich
Aymeric Vitte wrote: Why not, instead of adding ? operator ? You mean ?. here, I assume. The answer is because what you propose is an incompatible change to ECMA-262 (all editions) and JS back to its birth, which lets programs that throw currently continue to run, with possibly disastrous

Re: Existential operator (was: ||= is much needed?)

2012-06-18 Thread Aymeric Vitte
OK, ?. is enough and good Le 18/06/2012 16:48, Brendan Eich a écrit : Aymeric Vitte wrote: Why not, instead of adding ? operator ? You mean ?. here, I assume. The answer is because what you propose is an incompatible change to ECMA-262 (all editions) and JS back to its birth, which lets

Re: Existential operator (was: ||= is much needed?)

2012-06-18 Thread Allen Wirfs-Brock
This proposal augments the default operator by adding syntax to avoid accessing a missing property, specifically ?. for getting and setting a property from a reference base that might be undefined or null: [1] The specified semantics of proposal actually does more than avoid accessing a

Re: ||= is much needed?

2012-06-17 Thread David Herman
On Jun 15, 2012, at 5:57 PM, satyr wrote: On Sat, Jun 16, 2012 at 4:33 AM, David Herman dher...@mozilla.com wrote: As for null, I can see how there's confusion about whether to use null vs undefined, and so I can see why CoffeeScript would just try to blur the distinction between them.

Re: ||= is much needed?

2012-06-17 Thread Brendan Eich
David Herman wrote: On Jun 15, 2012, at 5:57 PM, satyr wrote: On Sat, Jun 16, 2012 at 4:33 AM, David Herman dher...@mozilla.com mailto:dher...@mozilla.com wrote: As for null, I can see how there's confusion about whether to use null vs undefined, and so I can see why CoffeeScript

Existential operator (was: ||= is much needed?)

2012-06-17 Thread Brendan Eich
Sorry, meant to start a new thread for: http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator As the Syntax section hints, we can't also adopt CoffeeScript's ?( variant, which enables foo.bar?(args, go, here).baz and the like. The C syntax heritage prevails. /be Brendan Eich

Re: ||= is much needed?

2012-06-15 Thread Aymeric Vitte
Yes, what I mean is that I did not see since a long time something like a===null?b:c or if (a===null)||b, and except for specific use like Object.create(null) I don't see a lot of null being used, then making the distinction for ??, ?: and others looks too subtle Le 15/06/2012 04:20, Brendan

Re: ||= is much needed?

2012-06-15 Thread David Herman
On Jun 14, 2012, at 1:45 PM, Brendan Eich wrote: I can see adding ?? and ??= (undefined-only, not undefined-or-null). I think ?? is the highest priority. Is ||= really worth it? It would not assign if the left side is truthy, but perhaps no one will mind. Given ||= is there any oxygen

Re: ||= is much needed?

2012-06-15 Thread Brendan Eich
David Herman wrote: So I favor ?? as well as both ||= and ??=. As for null, I can see how there's confusion about whether to use null vs undefined, and so I can see why CoffeeScript would just try to blur the distinction between them. But I think by sticking to the simpler semantics it will

Re: ||= is much needed?

2012-06-15 Thread Gavin Barraclough
On Jun 15, 2012, at 12:33 PM, David Herman wrote: So I favor ?? as well as both ||= and ??=. Adding ||= and ??= without = will cause my symmetry-reflex to twitch, despite not seeing a purpose for it I may find it hard to resist supporting that too. ;-) G.

Re: ||= is much needed?

2012-06-15 Thread Brendan Eich
satyr wrote: On Sat, Jun 16, 2012 at 4:33 AM, David Herman dher...@mozilla.com mailto:dher...@mozilla.com wrote: As for null, I can see how there's confusion about whether to use null vs undefined, and so I can see why CoffeeScript would just try to blur the distinction between

Re: ||= is much needed?

2012-06-15 Thread John Tamplin
On Fri, Jun 15, 2012 at 6:00 PM, Brendan Eich bren...@mozilla.com wrote: Can you give a real-world example where null rather than undefined is soaked up? I'm guessing DOM but guessing is bad (cf. Sherlock Holmes). Wouldn't any case where you return null to mean explicitly no object be such a

Re: ||= is much needed?

2012-06-15 Thread Brendan Eich
Maybe, probably, of course ;-). I'm still looking for real-world use-cases, code that actually exists (in CoffeeScript or JS) that needs to soak up null-or-undefined, not just undefined. /be John Tamplin wrote: On Fri, Jun 15, 2012 at 6:00 PM, Brendan Eich bren...@mozilla.com

Re: ||= is much needed?

2012-06-14 Thread Brendan Eich
Confusion: at no point has the http://wiki.ecmascript.org/doku.php?id=strawman:default_operator strawman removed the infix operator originally proposed as ?? and currently spelled ?: -- everyone agrees on having both OP and OP=, whatever the spelling of OP. I agree on reflection with Wes

Re: ||= is much needed?

2012-06-14 Thread Allen Wirfs-Brock
On Jun 14, 2012, at 10:10 AM, Brendan Eich wrote: On semantics: CoffeeScript's use of != null to equate null and undefined matches some users' habits, and helps to conceal the awkward fact of two bottom-types in JS (@jashkenas just averred that was the goal). But such concealment can

Re: ||= is much needed?

2012-06-14 Thread Brendan Eich
T.J. Crowder wrote: On 14 June 2012 18:10, Brendan Eich bren...@mozilla.com mailto:bren...@mozilla.com wrote: I agree on reflection with Wes and others who've objected that A ?: B has the simplest interpretation as A ? A : B and therefore should not be used for anything like (A !==

Re: ||= is much needed?

2012-06-14 Thread Brendan Eich
Allen Wirfs-Brock wrote: While I'm less than enthusiastic about explicitly provided undefined values triggering default value usages, I don't think it is particularly harmful. I think treating null equivalently would be. Noted, but you have not responded to the argument, made by Sam

Re: ||= is much needed?

2012-06-14 Thread Herby Vojčík
Brendan Eich wrote: Allen Wirfs-Brock wrote: While I'm less than enthusiastic about explicitly provided undefined values triggering default value usages, I don't think it is particularly harmful. I think treating null equivalently would be. Noted, but you have not responded to the argument,

Re: ||= is much needed?

2012-06-14 Thread Herby Vojčík
Herby Vojčík wrote: Brendan Eich wrote: Allen Wirfs-Brock wrote: While I'm less than enthusiastic about explicitly provided undefined values triggering default value usages, I don't think it is particularly harmful. I think treating null equivalently would be. Noted, but you have not

Re: ||= is much needed?

2012-06-14 Thread T.J. Crowder
On 14 June 2012 19:01, Brendan Eich bren...@mozilla.com wrote: The users who want null to be distinct from undefined are neither CoffeeScript users, nor || users (in their defaulting code). They must be doing === undefined test. Not quite. I use || whenever I can in my defaulting code, and I

Re: ||= is much needed?

2012-06-14 Thread Tab Atkins Jr.
On Thu, Jun 14, 2012 at 11:01 AM, Brendan Eich bren...@mozilla.com wrote: We have a problem with || indeed. The question is whether the solution should equate null and undefined. CoffeeScript chose the conceal-the-difference path and it has users. The users who want null to be distinct from

Re: ||= is much needed?

2012-06-14 Thread Herby Vojčík
Tab Atkins Jr. wrote: On Thu, Jun 14, 2012 at 11:01 AM, Brendan Eichbren...@mozilla.com wrote: We have a problem with || indeed. The question is whether the solution should equate null and undefined. CoffeeScript chose the conceal-the-difference path and it has users. The users who want null

Re: ||= is much needed?

2012-06-14 Thread Brendan Eich
T.J. Crowder wrote: On 14 June 2012 19:01, Brendan Eich bren...@mozilla.com mailto:bren...@mozilla.com wrote: The users who want null to be distinct from undefined are neither CoffeeScript users, nor || users (in their defaulting code). They must be doing === undefined test. Not

Re: ||= is much needed?

2012-06-14 Thread Allen Wirfs-Brock
On Jun 14, 2012, at 11:01 AM, Brendan Eich wrote: ... We have a problem with || indeed. The question is whether the solution should equate null and undefined. CoffeeScript chose the conceal-the-difference path and it has users. The users who want null to be distinct from undefined are

Re: ||= is much needed?

2012-06-14 Thread Rick Waldron
On Thu, Jun 14, 2012 at 2:39 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: snip I guess my concern is that there are significant existing subsystems where null is distinguished from undefined or where null has a specifically defined meaning that does not apply to undefined. For

Re: ||= is much needed?

2012-06-14 Thread John Tamplin
On Thu, Jun 14, 2012 at 4:04 PM, Rick Waldron waldron.r...@gmail.comwrote: I realize that the strawman currently spells it ?:, consider this message an opposition to that. This has been an extension to C for quite some time, and it means specifically to use the condition value if it is truthy

Re: ||= is much needed?

2012-06-14 Thread Brendan Eich
Rick Waldron wrote: One way to have it both ways is to have multiple syntactic forms for default value initializers. EG: function f(a = 1, b ??= 2, c ||= 3) { } //assuming ??= is undefined or null defaulting guard and ||= is falsy I'm not particularly convinced that the

Re: ||= is much needed?

2012-06-14 Thread John Tamplin
On Thu, Jun 14, 2012 at 5:32 PM, T.J. Crowder t...@crowdersoftware.comwrote: Is ||= really worth it? It would not assign if the left side is truthy, but perhaps no one will mind. Nice-to-have. The fact it doesn't assign if the left side is truthy is the only reason for having it, surely?

Re: ||= is much needed?

2012-06-14 Thread Rick Waldron
On Thu, Jun 14, 2012 at 6:06 PM, Aymeric Vitte vitteayme...@gmail.comwrote: This discussion I think is going into a useless complexity. Nobody (except w3c) is using null, or when someone is using it, it is the same way as undefined, and it is not explicit (ie a||b or a==b, not a===null), I

Re: ||= is much needed?

2012-06-14 Thread Tab Atkins Jr.
On Thu, Jun 14, 2012 at 4:06 PM, Aymeric Vitte vitteayme...@gmail.com wrote: Nobody (except w3c) is using null, or when someone is using it, it is the same way as undefined, and it is not explicit (ie a||b or a==b, not a===null), I remind some old code where we could see the use of null but can

Re: ||= is much needed?

2012-06-14 Thread Mark S. Miller
Just clarifying -- we all agree that any such thing is too late for ES6, right? On this assumption, I'm postponing engaging in this thread until I have time. On Fri, Jun 15, 2012 at 4:43 AM, Brendan Eich bren...@mozilla.com wrote: Yes, I'm about to bail back to ??. --     Cheers,     --MarkM

Re: ||= is much needed?

2012-06-14 Thread Aymeric Vitte
Before... I put Rick's answer below too, in strict/correct code it can be used but what examples (except yours) ? Maybe I missed it, never saw the use of null since a long time, but I can be wrong Do you think it does worth the complexity for the operators we are talking about ? w3c is

Re: ||= is much needed?

2012-06-14 Thread Aymeric Vitte
Just to be clear I am talking about the use of null in the scope of the current discussion (ie operators/default) only Le 15/06/2012 01:37, Aymeric Vitte a écrit : Before... I put Rick's answer below too, in strict/correct code it can be used but what examples (except yours) ? Maybe I

Re: ||= is much needed?

2012-06-14 Thread Brendan Eich
I don't think it matters yet, this is fair game for es-discuss as a harmony strawman. But it does connect to parameter default values, where we have open issues that come up here too. Worth skimming IMHO. /be On Jun 14, 2012, at 6:35 PM, Mark S. Miller erig...@google.com wrote: Just

Re: ||= is much needed?

2012-06-13 Thread T.J. Crowder
On 13 June 2012 06:52, Brendan Eich bren...@mozilla.org wrote: People don't default on the caller side (at the callsite) much, in my experience. Dave may be seeing other sources, but it's extremely rare in my experience to see I'm with Dave on this, I do it fairly regularly, usually when a

Re: ||= is much needed?

2012-06-13 Thread Aymeric Vitte
Indeed, maybe both should be included. What about this case : if (typeof(api)==undefined) {try later} else if (!api.a) {try later} else if (!api.a.b)) {try later} else if (etc...) which can be written : if (!(((typeof(api)!=undefined?api.a:undefined)?api.a.b:undefined)?api.a.b.c:undefined))

Re: ||= is much needed?

2012-06-13 Thread Wes Garland
On 13 June 2012 03:45, T.J. Crowder t...@crowdersoftware.com wrote: Is the reason for using ?: rather than ?? because we may want it for my desired second ternary? E.g., from my other message: Something else to consider; if we use (a ?: b), it would have to be equivalent to (a ? a : b) with

Re: ||= is much needed?

2012-06-13 Thread Aymeric Vitte
Typo below, I meant which can be written : if (!(((typeof(api)!=undefined??api.a:undefined)??api.a.b:undefined)??api.a.b.c:undefined)) {try later} Le 13/06/2012 12:12, Aymeric Vitte a écrit : Indeed, maybe both should be included. What about this case : if (typeof(api)==undefined) {try

Re: ||= is much needed?

2012-06-13 Thread David Herman
On Jun 12, 2012, at 10:52 PM, Brendan Eich wrote: People don't default on the caller side (at the callsite) much, in my experience. Dave may be seeing other sources, but it's extremely rare in my experience to see foo(arg1 || callers_idea_of_default_arg1_value); I'm sure it's more rare

  1   2   >