On Wed, May 6, 2009 at 1:24 PM, Edward Lee <[email protected]> wrote: > On Tue, May 5, 2009 at 1:37 PM, Peter Michaux <[email protected]> wrote: >> I think optional parameters are the nuisance use case that is fueling >> any discussion about a ||= or ??= operator. > There are other uses that are similar, but wouldn't be covered by > default args. Here's one simple example: > > let (hash = {}) function get(key) hash[key] ??= 123 > > Similarly, if APIs use a single object to take optional args instead > of using function args: > > // args is a hash with optional keys "str" and "val" > function foo(args) { > args.str ??= "bar"; > args.val ??= 10; > typeof_check(args, { str: "string", val: "number" }) > } > > So even if there's a better solution for default args than ||= or ??=, > there's still use for the operators.
I was trying to mention these cases but the examples make it more clear. I think that there are still use cases for ||= and ??= but the default args is the most common use case. If the main use case is taken care of with default args then is it necessary to add ||= and ??= for less common use cases? Peter _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

