[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntax sugar for default arguments
- From: Steve Litt <slitt@...>
- Date: Sun, 21 Apr 2013 12:39:22 -0400
On Sun, 21 Apr 2013 08:41:31 +0200
Dirk Laurie <dirk.laurie@gmail.com> wrote:
> function f(x,y=0)
> function f(x,y or 0)
>
> to mean
>
> function f(x,y) y=y or 0
>
> Neither would break existing code.
>
> Which of the above should I choose to implement as a patch?
I prefer the first one. It's shorter, which is good for keystrokes and
great for line real estate, and it's familiar from other languages.
By the way, are you going to let the other shoe drop and do the same
thing in the subroutine *call*?
function f(x=3, y=4)
whatever()
end
f(y=7) -- no need to articulate x
Thanks,
SteveT
Steve Litt * http://www.troubleshooters.com/
Troubleshooting Training * Human Performance