Steven Mascaro wrote:
> One last issue. I was going to leave it till later, but I realised it
> may affect ES4.
>
> The nicest syntax for named arguments would be to use ':', just like
> with object literals. e.g.:
>
> /// Define
> function foo(arg1 = 0, arg2 = 1) { ... }
>
> /// Call
> foo(arg2
One last issue. I was going to leave it till later, but I realised it
may affect ES4.
The nicest syntax for named arguments would be to use ':', just like
with object literals. e.g.:
/// Define
function foo(arg1 = 0, arg2 = 1) { ... }
/// Call
foo(arg2: 10, arg1: 5);
(I find this even more attr
On 29/02/2008, Lars Hansen <[EMAIL PROTECTED]> wrote:
> What I meant was an assignment operator so that I could write:
>
> { xProp: x, yProp: y } ?= { xProp: 10, yProp: 20 };
>
> and x and y would be overwritten only if their values were undefined.
> C# has a similar operator for conditional as
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Steven Mascaro
> Sent: 29. februar 2008 01:08
> To: Brendan Eich
> Cc: Lars Hansen; es4-discuss@mozilla.org
> Subject: Re: Default argument values
>
>
> Suppose we to
2008/2/29 Brendan Eich <[EMAIL PROTECTED]>:
> On Feb 28, 2008, at 7:29 AM, Lars Hansen wrote:
>
> > In fact the RI doesn't work as one would like it to, as the third test
> > below shows:
> >
> >>> function h({x:x, y:y} = { x:10, y:20 }) [x,y]
> >>> h({x:1,y:2})
> > 1,2
> >>> h()
> > 10,20
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Brendan Eich
> Sent: 28. februar 2008 03:47
> To: Steven Mascaro
> Cc: es4-discuss@mozilla.org
> Subject: Re: Default argument values
>
> On Feb 27, 2008, at 6:
On Feb 27, 2008, at 6:56 PM, Steven Mascaro wrote:
> 2008/2/28 Brendan Eich <[EMAIL PROTECTED]>:
function h({p:x,q:y} = {p:3,q:4}) [x,y]
h()
>> 3,4
>
> Unfortunately, it doesn't work when you want to specify a subset of
> the optional parameters. e.g.:
>
>>> h({p:1})
> 1,
True -- it's
On Feb 27, 2008, at 6:35 PM, Steven Mascaro wrote:
>> This is not to knock named parameters, just to explain why they
>> never
>> made it into a serious proposal in the modern ES4 era.
>
> That sounds fine. The only thing it misses is interchanging positional
> and named parameters, but that's
2008/2/28 Brendan Eich <[EMAIL PROTECTED]>:
> I search like so:
>
> http://www.google.com/search?hl=en&q=site%3Amail.mozilla.org+es4-
> discuss+%22named+parameters%22+brendan
Ah. I kept searching for variants of 'default parameters'.
> This is not to knock named parameters, just to explain wh
On Feb 27, 2008, at 5:22 PM, Steven Mascaro wrote:
> Anyway, I'm sure you know the advantages (and disadvantages?) to
> optional named arguments. I was just wondering whether they had been
> considered for ES4, or if considered and rejected, then why. I've
> searched the wiki and mailing list, but
> Functions can take optional arguments (they have default values) and
> rest arguments:
>
> function f(x, y=0) { ... } // y is optional
>
What is the opinion on Python-style named arguments? i.e.:
def f(x = 0, y = 0):
...
f(y = 2)
The calling syntax for ES4 would obviously have to b
11 matches
Mail list logo