Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Thaddee Tyl
On Tue, Jun 12, 2012 at 10:17 PM, David Herman wrote: > On Jun 12, 2012, at 6:33 PM, Thaddee Tyl wrote: > >> My point still stands. Being "undefined"-specific is arbitrary. >> CoffeeScript could have been "undefined"-specific; they were >> "undefined" + "null"-specific, which I believe makes more

Re: ||= is much needed?

2012-06-12 Thread Axel Rauschmayer
I think it’d be handy when you are taking apart objects (e.g. JSON data). However, you do have the option of merging in default values (e.g. via http://documentcloud.github.com/underscore/#defaults ). On Jun 13, 2012, at 7:52 , Brendan Eich wrote: > People don't default on the caller side (at t

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
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); whereas we all see function foo(a, b, c) { a = a || default_a; b.x =

Re: ||= is much needed?

2012-06-12 Thread Ryan Florence
Sorry, I misunderstood. CoffeeScript has ? (no ternary, so its doable there) but I haven't seen it used much. On Jun 12, 2012, at 11:14 PM, David Herman wrote: > On Jun 12, 2012, at 7:41 PM, Ryan Florence wrote: > >>> I'm skeptical. You don't foresee >>> >>>f(obj.x ?? defVal) >>> >>> hap

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread David Herman
On Jun 12, 2012, at 6:33 PM, Thaddee Tyl wrote: > My point still stands. Being "undefined"-specific is arbitrary. > CoffeeScript could have been "undefined"-specific; they were > "undefined" + "null"-specific, which I believe makes more sense. Can you make the full argument? I'm genuinely undecid

Re: ||= is much needed?

2012-06-12 Thread David Herman
On Jun 12, 2012, at 7:41 PM, Ryan Florence wrote: >> I'm skeptical. You don't foresee >> >>f(obj.x ?? defVal) >> >> happening a lot? I do. > > I can't speak for the world but I've never seen anybody do f(val ||= defVal) > in Ruby or CoffeeScript. But I'm not talking about ||=. I'm talking

Re: ||= is much needed?

2012-06-12 Thread Ryan Florence
> I'm skeptical. You don't foresee > >f(obj.x ?? defVal) > > happening a lot? I do. I can't speak for the world but I've never seen anybody do f(val ||= defVal) in Ruby or CoffeeScript. ___ es-discuss mailing list es-discuss@mozilla.org https://

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Ryan Florence wrote: But if we're adding ?= because we're adding ?: maybe its okay to add ||= while we're at it? That said, I would hate to see ?= get derailed because ||= is "dumb". "Dumb" is too strong. How about YAGNI? Every use-case of || I've seen in JS (almost all with the result of ||

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
On Jun 12, 2012, at 5:57 PM, David Herman wrote: > On Jun 12, 2012, at 11:02 AM, Brendan Eich wrote: > >> It's possible ?? or however we spell it isn't worth adding, while ?= is. The >> conditional assignment to default or normalize is the prime use-case. > > I'm skeptical. You don't foresee >

Fwd: ||= is much needed?

2012-06-12 Thread Rick Waldron
This message seems to have disappeared from the archive and since I referred to it in http://wiki.ecmascript.org/doku.php?id=strawman:default_operator I wanted to make sure a record existed. Rick -- Forwarded message -- From: Ryan Florence Date: Tue, Jun 12, 2012 at 11:45 AM Subj

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Thaddee Tyl
On Tue, Jun 12, 2012 at 6:11 PM, Tab Atkins Jr. wrote: > On Tue, Jun 12, 2012 at 2:52 PM, Thaddee Tyl wrote: >> On the other hand, non-existent properties are a use-case. >> CoffeeScript provides a similar feature, but for null properties. >> >> For example, the following: >> >>    o = >>     a:

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Tab Atkins Jr.
On Tue, Jun 12, 2012 at 2:52 PM, Thaddee Tyl wrote: > On the other hand, non-existent properties are a use-case. > CoffeeScript provides a similar feature, but for null properties. > > For example, the following: > >    o = >     a: 1 >     b: 2 > >    alert o.c?.d > > compiles to: > >    var o, _

Re: ||= is much needed?

2012-06-12 Thread David Herman
On Jun 12, 2012, at 11:02 AM, Brendan Eich wrote: > It's possible ?? or however we spell it isn't worth adding, while ?= is. The > conditional assignment to default or normalize is the prime use-case. I'm skeptical. You don't foresee f(obj.x ?? defVal) happening a lot? I do. Dave ___

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Ok, that (cited below) was wrong too. This should be right: http://wiki.ecmascript.org/doku.php?id=strawman:default_operator#semantics Comments welcome. Thanks again, I needed some caffeine! /be Brendan Eich wrote: Heh, I did write *roughly* :-P. Let lref = evaluate LeftHandSideExpression.

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Heh, I did write *roughly* :-P. Let lref = evaluate LeftHandSideExpression. Let lval = GetValue(lref). Throw a SyntaxError exception if the following conditions are all true: • Type(lref) is Reference is true • IsStrictReference(lref) is true • Type(GetBase(lref)) is Environment Record •

Re: ||= is much needed?

2012-06-12 Thread Allen Wirfs-Brock
On Jun 12, 2012, at 3:26 PM, John Tamplin wrote: > On Tue, Jun 12, 2012 at 3:09 PM, Brendan Eich wrote: > And (to be clear) the semantics for > > LeftHandSideExpression ?= AssignmentExpression > > are roughly > > Let lref = evaluate A. > Let lval = GetValue(lref). > Let rref = evaluate B. > L

Re: ||= is much needed?

2012-06-12 Thread John Tamplin
On Tue, Jun 12, 2012 at 3:09 PM, Brendan Eich wrote: > And (to be clear) the semantics for > > LeftHandSideExpression ?= AssignmentExpression > > are roughly > > Let lref = evaluate A. > Let lval = GetValue(lref). > Let rref = evaluate B. > Let rval = GetValue(rref). > Throw a SyntaxError excepti

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Updated. Sorry, no ||| instead of ??. Instead, inspired by Wes's GCC reminder, I kept the ?? operator but re-spelled it as ?: and made ??= be spelled ?=. http://wiki.ecmascript.org/doku.php?id=strawman:default_operator The semantics match only undefined. APIs use null as no-object and do not

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Thaddee Tyl
On Tue, Jun 12, 2012 at 1:56 PM, Tab Atkins Jr. wrote: > On Tue, Jun 12, 2012 at 1:37 PM, Peter van der Zee wrote: >> On Tue, Jun 12, 2012 at 5:29 PM, T.J. Crowder >> wrote: >>> In the current default operator strawman[1], the operator is ??, e.g.: >>> >>> a = b ?? 5; >>> >>> is shorthand for >

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Peter van der Zee
On Tue, Jun 12, 2012 at 10:56 PM, Tab Atkins Jr. wrote: > "undefined" is special-cased here because it's an extremely common > value to check against.  It's used when an argument isn't supplied, or > when you try to pull a non-existent property off of an object. I believe the most common case for

Re: Function length

2012-06-12 Thread Russell Leggett
On Tue, Jun 12, 2012 at 1:06 PM, Brendan Eich wrote: > Russell Leggett wrote: > >> It does bring up something else, though, that I've avoided mentioning so >> far, which is pattern matching. I haven't mentioned it because there is >> clearly a strawman > doku.php?i

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Tab Atkins Jr.
On Tue, Jun 12, 2012 at 1:37 PM, Peter van der Zee wrote: > On Tue, Jun 12, 2012 at 5:29 PM, T.J. Crowder > wrote: >> In the current default operator strawman[1], the operator is ??, e.g.: >> >> a = b ?? 5; >> >> is shorthand for >> >> a = b !== undefined ? b : 5; > > I missed this discussion. W

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Peter van der Zee
> If the above is "this, absolutely" and such a feature, I favor this as Wow, something messed up big time. "If the above answer is "this, absolute" and such a feature is seriously considered ..." ___ es-discuss mailing list es-discuss@mozilla.org https

Re: Default operator strawman - ||| rather than ??

2012-06-12 Thread Peter van der Zee
On Tue, Jun 12, 2012 at 5:29 PM, T.J. Crowder wrote: > In the current default operator strawman[1], the operator is ??, e.g.: > > a = b ?? 5; > > is shorthand for > > a = b !== undefined ? b : 5; I missed this discussion. What validates the introduction of this syntax over the equally simple and

Re: Rest parameter syntax

2012-06-12 Thread Brendan Eich
Rick Waldron wrote: The context of my question assumed there was a desire to avoid the complexity and that the discussion had already reached consensus on only allowing rest params at the end of a formal parameter list. That's the safe play for ES6, which must be prototyped and drafted this y

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Brendan Eich wrote: LeftHandSideExpression ?= AssignmentExpression are roughly Let lref = evaluate A. Let lval = GetValue(lref). Let rref = evaluate B. Of course, A should be LeftHandSideExpression and B should be AssignmentExpression. This is pretty simple. We could even grant an excepti

Re: Rest parameter syntax

2012-06-12 Thread Rick Waldron
On Tue, Jun 12, 2012 at 2:56 PM, Felix Böhm wrote: > Another nice place for this syntax would be destructuring: If you want to > get the last elements of an array, you might want to simply use > > [...arr, foo, bar] = arr; > > > I really like that syntax. And in the end, that's what > > function(

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Russell Leggett wrote: On Tue, Jun 12, 2012 at 2:31 PM, Tom Ellis > wrote: I like the sound of ?= too. var a; //later on a ?= 15; It goes with all the other operators that are out there too (!=, =, ==, === etc). +1, useful and intuitive.

Re: Rest parameter syntax

2012-06-12 Thread Felix Böhm
Another nice place for this syntax would be destructuring: If you want to get the last elements of an array, you might want to simply use [...arr, foo, bar] = arr; I really like that syntax. And in the end, that's what function(...arr, foo, bar){…} is doing. The difference to bar = arr.pop();

Re: ||= is much needed?

2012-06-12 Thread Russell Leggett
On Tue, Jun 12, 2012 at 2:31 PM, Tom Ellis wrote: > I like the sound of ?= too. > > var a; > > //later on > > a ?= 15; > > It goes with all the other operators that are out there too (!=, =, ==, > === etc). > +1, useful and intuitive. - Russ > > Tom > > On 12 Jun 2012, at 19:04, Brendan Eich

Re: ||= is much needed?

2012-06-12 Thread Tom Ellis
I like the sound of ?= too. var a; //later on a ?= 15; It goes with all the other operators that are out there too (!=, =, ==, === etc). Tom On 12 Jun 2012, at 19:04, Brendan Eich wrote: > Brendan Eich wrote: >> Is this (A ? B) ? C : D or A ? (B ? C) : D. We can disambiguate in the >> for

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Brendan Eich wrote: Is this (A ? B) ? C : D or A ? (B ? C) : D. We can disambiguate in the formal grammar but readers may rebel. Or A ? (B ? C : D), of course. Just say no to lone ? as new operator. I'm warming up to ?= though! /be ___ es-discuss m

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Wes Garland wrote: > This breaks from JS's C-inspired assignment operators, but perhaps we can live with it. FWIW -- I was confused when I first read ||=, I thought it was supposed to be some kind of Boolean-coercing variant on |=. Now I see that it is more like ?= from GNU make. We could u

Re: ||= is much needed?

2012-06-12 Thread Wes Garland
> This breaks from JS's C-inspired assignment operators, but perhaps we can live with it. FWIW -- I was confused when I first read ||=, I thought it was supposed to be some kind of Boolean-coercing variant on |=. Now I see that it is more like ?= from GNU make. What do you think of GCC's ?: opera

Re: ||= is much needed?

2012-06-12 Thread Brendan Eich
Rick Waldron wrote: On Tue, Jun 12, 2012 at 11:45 AM, Ryan Florence > wrote: I use ||= very regularly in ruby and coffeescript, both of which have default arguments. I don't see Ryan's mail. First, as we've discussed in the past, ||= in Ruby is not what w

Re: ||= is much needed?

2012-06-12 Thread AJ ONeal
+1 I desperately want this in the language. AJ ONeal On Tue, Jun 12, 2012 at 11:14 AM, Rick Waldron wrote: > > > On Tue, Jun 12, 2012 at 11:45 AM, Ryan Florence wrote: > >> I use ||= very regularly in ruby and coffeescript, both of which have >> default arguments. >> >> I definitely agree that

Re: Map#get needs a default value param?

2012-06-12 Thread Brendan Eich
Tab Atkins Jr. wrote: This isn't too bad, and we can always wait for the language to expand with subtypes of Map that handle this behavior better (or use a library), like the aforementioned Counter and DefaultDict of Python. Previously: https://mail.mozilla.org/pipermail/es-discuss/2012-Januar

Re: Rest parameter syntax

2012-06-12 Thread T.J. Crowder
On 12 June 2012 18:14, Brendan Eich wrote: > Red guy still on your shoulder :-P. I think you're seeing things. ;-) But seriously, I don't really have a horse in this race (at all, I was just exploring the concept -- seems that's already been done), happy to leave it at that. -- T.J. __

Re: ||= is much needed?

2012-06-12 Thread Rick Waldron
On Tue, Jun 12, 2012 at 11:45 AM, Ryan Florence wrote: > I use ||= very regularly in ruby and coffeescript, both of which have > default arguments. > > I definitely agree that default arguments are a decent alternative. I >> can't recall examples where it wouldn't be enough. Do you have use cases

Re: Rest parameter syntax

2012-06-12 Thread Brendan Eich
T.J. Crowder wrote: On 12 June 2012 18:00, Brendan Eich > wrote: T.J. Crowder wrote: And yet, if not yet implemented in its current form (I have no idea what the extent of implementation is), the complexity increment does not seem large.

Re: Rest parameter syntax

2012-06-12 Thread T.J. Crowder
On 12 June 2012 18:00, Brendan Eich wrote: > T.J. Crowder wrote: > >> And yet, if not yet implemented in its current form (I have no idea what >> the extent of implementation is), the complexity increment does not seem >> large. > > > Here you went down the bad path. > > It was not the last cooki

Re: Error stack

2012-06-12 Thread Charles Kendrick
On Tue, Jun 12, 2012 at 5:19 AM, Mark S. Miller wrote: > On Tue, Jun 12, 2012 at 10:14 AM, Charles Kendrick > wrote: >> The only way I can see this working is if there is a way for a given >> piece of code to trap an error and ask some kind of (elevated >> privilege) logging system to provide dia

Re: Map#get needs a default value param?

2012-06-12 Thread Tab Atkins Jr.
On Tue, Jun 12, 2012 at 9:07 AM, David Bruant wrote: > Le 12/06/2012 18:02, Tab Atkins Jr. a écrit : >> On Tue, Jun 12, 2012 at 7:36 AM, David Bruant  wrote: >>> Le 12/06/2012 16:19, Hemanth H.M a écrit : >>> >>> Would it be useful to have something like sum[value] = sum.get(value, 0) >>> + 1 >>>

Re: Function length

2012-06-12 Thread Brendan Eich
Russell Leggett wrote: It does bring up something else, though, that I've avoided mentioning so far, which is pattern matching. I haven't mentioned it because there is clearly a strawman for it, and that never made it to harmon

Re: Rest parameter syntax

2012-06-12 Thread Rick Waldron
> > snip > > > But I understand there are problems. First, what with optional params > after ...rest. And the second, how to parse it when foo(1, 2) called? > There was a lengthy thread about this, here: https://mail.mozilla.org/pipermail/es-discuss/2012-April/022256.html Rick ps. This is an

Re: Rest parameter syntax

2012-06-12 Thread Brendan Eich
T.J. Crowder wrote: Very true, no reason it couldn't be loosened up in ES7 or whatever. Right, this is a virtue. And yet, if not yet implemented in its current form (I have no idea what the extent of implementation is), the complexity increment does not seem large. Here you went down the b

Re: Error stack

2012-06-12 Thread Brendan Eich
Mark S. Miller wrote: I'm not yet arguing that or the opposite, rather, I'm confused about what "non-strict-only" means in this context. Actual stacks consist of a mixture of strict and non-strict activations. This isn't so in personal projects or even all-homegrown products or shared projects

Re: Rest parameter syntax

2012-06-12 Thread T.J. Crowder
On 12 June 2012 17:21, Felix Böhm wrote: > As written before: > > function foo(a, b, ...others, c){ … } > > behaves the same as > > function foo(a, b, ...others){ > var c = others.pop(); > } > Sadly, it's not as simple to emulate function foo(a, b, ...others, c, d) { } ...using pop. But obvi

Re: Function length

2012-06-12 Thread Russell Leggett
On Mon, Jun 11, 2012 at 3:50 PM, Brendan Eich wrote: > Irakli Gozalishvili wrote: > >> Sorry for not being clear about this. Here is a simplified example of the >> implementation: >> https://gist.github.com/**2911817 >> >> Also this is just a single particular ex

Re: Rest parameter syntax

2012-06-12 Thread Felix Böhm
As written before: function foo(a, b, ...others, c){ … } behaves the same as function foo(a, b, ...others){ var c = others.pop(); } When the number of parameters following the rest parameter is greater or equal the number of passed arguments, the rest parameter is an empty array and the param

Re: Rest parameter syntax

2012-06-12 Thread Allen Wirfs-Brock
We have had several previous discussions about such possibilities on this list. Bottom line, is that destructuring (including formal parameters) could be moved towards something that is more like generalized pattern matching. However, it isn't clear that the additional specification, implementa

Re: Map#get needs a default value param?

2012-06-12 Thread Hemanth H.M
True! It will be confusing; || is uber kool :) On Tue, Jun 12, 2012 at 9:37 PM, David Bruant wrote: > Le 12/06/2012 18:02, Tab Atkins Jr. a écrit : > > On Tue, Jun 12, 2012 at 7:36 AM, David Bruant wrote: >> >>> Le 12/06/2012 16:19, Hemanth H.M a écrit : >>> >>> Would it be useful to have some

Re: Rest parameter syntax

2012-06-12 Thread Allen Wirfs-Brock
On Jun 12, 2012, at 8:49 AM, Herby Vojčík wrote: > > ... > > BTW, isn't this possible with comprehensions in parameter list: > > db.run = function (query, ...[...params, cb]) { /* body */ } > > If yes, problem solved. Current draft requires an identifier after ... in a rest position Allen _

Re: ||= is much needed?

2012-06-12 Thread Hemanth H.M
Kool, well was looking into use caseswell my first frustration was [1] I'm new to this, how does one write proposals? Is it a wiki? [1] https://twitter.com/GNUmanth/status/208555914733682690 On Tue, Jun 12, 2012 at 8:36 PM, Rick Waldron wrote: > http://wiki.ecmascript.org/doku.php?id=strawm

Re: [[Get]] and GetValue can return Reference Type

2012-06-12 Thread Allen Wirfs-Brock
On Jun 11, 2012, at 11:03 PM, Yusuke Suzuki wrote: > This issue is derived from Esprima issue 81 > http://code.google.com/p/esprima/issues/detail?id=81 > > Hello everyone, > > According to the ECMA262 5.1th, [[Call]] of host object may return Reference > Type. > So, all values using raw [[Call

Re: Rest parameter syntax

2012-06-12 Thread T.J. Crowder
On 12 June 2012 17:03, Herby Vojčík wrote: > function foo (a, b, ...rest, c, d) { ... } > foo(1, 2, 3) > > What here? > > Yes, [1, 2, [], 3, undefined] is probably the most logical one. But then d > is not the last one (yes, it is only last one when there is at least four > of them). > Yeah, I w

Re: Map#get needs a default value param?

2012-06-12 Thread David Bruant
Le 12/06/2012 18:02, Tab Atkins Jr. a écrit : On Tue, Jun 12, 2012 at 7:36 AM, David Bruant wrote: Le 12/06/2012 16:19, Hemanth H.M a écrit : Would it be useful to have something like sum[value] = sum.get(value, 0) + 1 You can always do sum[value] = (sum.get(value) || 0) + 1; I think i

Re: Rest parameter syntax

2012-06-12 Thread Herby Vojčík
T.J. Crowder wrote: On 12 June 2012 16:42, Herby Vojčík mailto:he...@mailbox.sk>> wrote: But I understand there are problems. First, what with optional params after ...rest. And the second, how to parse it when foo(1, 2) called? I would think with function foo(a, b, ...others,

Re: Map#get needs a default value param?

2012-06-12 Thread Tab Atkins Jr.
On Tue, Jun 12, 2012 at 7:36 AM, David Bruant wrote: > Le 12/06/2012 16:19, Hemanth H.M a écrit : > > Would it be useful to have something like sum[value] = sum.get(value, 0) + 1 > > You can always do > >     sum[value] = (sum.get(value) || 0) + 1; > > I think it's simple enough to justify not hav

Re: Rest parameter syntax

2012-06-12 Thread T.J. Crowder
On 12 June 2012 16:42, Herby Vojčík wrote: > >> But I understand there are problems. First, what with optional params > after ...rest. And the second, how to parse it when foo(1, 2) called? > > I would think with function foo(a, b, ...others, c) { } then given foo(1, 2); ...within foo a is 1,

Re: Rest parameter syntax

2012-06-12 Thread Herby Vojčík
Felix Böhm wrote: Per definition, rest parameters always need to be at the end of a FormalParameterList. I was wondering if this limitation could be liftet. Use-case: Most SQL libraries for node support passing query arguments to the query function (so SQL injections are avoided). The usual sy

Re: Rest parameter syntax

2012-06-12 Thread Herby Vojčík
Rick Waldron wrote: On Tue, Jun 12, 2012 at 10:38 AM, Felix Böhm mailto:esdisc...@feedic.com>> wrote: Per definition, rest parameters always need to be at the end of a FormalParameterList. I was wondering if this limitation could be liftet. Consider: function foo( a, b, ...others

Re: Rest parameter syntax

2012-06-12 Thread Russell Leggett
On Tue, Jun 12, 2012 at 11:26 AM, Rick Waldron wrote: > > > On Tue, Jun 12, 2012 at 10:38 AM, Felix Böhm wrote: > >> Per definition, rest parameters always need to be at the end of a >> FormalParameterList. I was wondering if this limitation could be liftet. >> > > Consider: > > > function foo(

Default operator strawman - ||| rather than ??

2012-06-12 Thread T.J. Crowder
In the current default operator strawman[1], the operator is ??, e.g.: a = b ?? 5; is shorthand for a = b !== undefined ? b : 5; Would it be possible to use ||| instead? E.g.: a = b ||| 5; I ask because I was planning (prior to knowing about this strawman!) to suggest that, along with a diffe

Re: Rest parameter syntax

2012-06-12 Thread Rick Waldron
On Tue, Jun 12, 2012 at 10:38 AM, Felix Böhm wrote: > Per definition, rest parameters always need to be at the end of a > FormalParameterList. I was wondering if this limitation could be liftet. > Consider: function foo( a, b, ...others, c ) { return [ a, b, others, c ]; } foo( 1, 2, 3, 4,

Re: ||= is much needed?

2012-06-12 Thread Rick Waldron
On Tue, Jun 12, 2012 at 10:33 AM, David Bruant wrote: > Le 12/06/2012 15:27, Hemanth H.M a écrit : > > Would something like : > > obj["prop"] ||= "NewProp" > be useful? > > There is currently a strawman proposal for the "Default Operator", which can be found here: http://wiki.ecmascript.org/do

Rest parameter syntax

2012-06-12 Thread Felix Böhm
Per definition, rest parameters always need to be at the end of a FormalParameterList. I was wondering if this limitation could be liftet. Use-case: Most SQL libraries for node support passing query arguments to the query function (so SQL injections are avoided). The usual syntax is db.run("SELECT

Re: Function length

2012-06-12 Thread Felix Böhm
The big question is whether Function#length should represent minimum or the maximum amount of arguments. That means that a rest parameter could have zero elements, and optional parameters could fall back to their default value. The minimum approach wouldn't count them, the maximum would expect the

Re: Map#get needs a default value param?

2012-06-12 Thread David Bruant
Le 12/06/2012 16:19, Hemanth H.M a écrit : Would it be useful to have something like sum[value] = sum.get(value, 0) + 1 You can always do sum[value] = (sum.get(value) || 0) + 1; I think it's simple enough to justify not having an additional (and potentially confusing) argument, but I'm op

Re: ||= is much needed?

2012-06-12 Thread David Bruant
Le 12/06/2012 15:27, Hemanth H.M a écrit : Would something like : |obj["prop"] ||= "NewProp"| be useful? ahah, I asked the same question very recently [1]. Answer by Brendan Eich [2]. I definitely agree that default arguments are a decent alternative. I can't recall examples where it wouldn't

Map#get needs a default value param?

2012-06-12 Thread Hemanth H.M
Would it be useful to have something like sum[value] = sum.get(value, 0) + 1 -- *'I am what I am because of who we all are'* h3manth.com *-- Hemanth HM * ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.or

Re: Error stack

2012-06-12 Thread Andreas Rossberg
On 12 June 2012 01:36, Charles Kendrick wrote: >> Your point about not violating "use strict" or elaborating too much is good, >> but I want to push back on one thing: local vars may be a bridge too far, >> especially with optimizing JITs, block-scoped let bindings, etc. Making >> arguments availa

||= is much needed?

2012-06-12 Thread Hemanth H.M
Would something like : obj["prop"] ||= "NewProp" be useful? -- *'I am what I am because of who we all are'* h3manth.com *-- Hemanth HM * ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-di

Re: Error stack

2012-06-12 Thread Mark S. Miller
On Tue, Jun 12, 2012 at 10:14 AM, Charles Kendrick wrote: > On Mon, Jun 11, 2012 at 5:55 PM, Mark S. Miller wrote: >> On Tue, Jun 12, 2012 at 7:59 AM, Charles Kendrick >> wrote: >>> I'm reading this as saying that stack traces in general should not be >>> available unless the code is privileged

Re: Add basic arithmetic to Math

2012-06-12 Thread Nadav Shesek
On Jun 11, 2012 6:18 PM, "Allen Wirfs-Brock" wrote: > > > On Jun 10, 2012, at 11:48 AM, Angus Croll wrote: > >> Rationale: >> >> Some functional JavaScript idioms are hamstrung by the lack of native basic arithmetic functions. >> Would be handy/elegant/instructive to be able to write >> >> arr.red

Re: Error stack

2012-06-12 Thread Mark S. Miller
On Tue, Jun 12, 2012 at 9:17 AM, Brendan Eich wrote: > Mark S. Miller wrote: >> >> On Tue, Jun 12, 2012 at 7:38 AM, Brendan Eich  wrote: >>> >>> Also, as you pointed out, even error.stack leaks information. Where do >>> you >>> draw the line? >> >> >> Conservatively. I suggest that there be no err