Re: Opinions about conditional built-in names?

Woonsan Ko <[email protected]> Sun, 31 May 2015 13:50:20 -0400
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <[email protected]>
I personally prefer having the default value option inside the
parenthesis, without having to depend on the default value after '!'.
So, I like the idea the odd number of parameters for a default value.

Regarding the original question about 'switch' and 'choose', I like the
'switch' very much, but I'm not sure if 'choose' is a good name for
ternary operator. In XSL, 'choose' means just one choice of the
'switch'. 'choose' sounds like related to one of the 'multiple' choices
to me.
Another option to consider might be 'iif' [1], which seems a bit clearer
to me than 'either' and others.

    someBoolean?iif(whenTrue, whenFalse)

Just my two cents,

Woonsan

[1] http://en.wikipedia.org/wiki/IIf

On 5/30/15 6:02 AM, Daniel Dekany wrote:
> And regarding the semantics of ?switch... as it sands now, if there's
> no matching choice, that will be an exception that says:
> 
>   The value before ?switch(case1, value1, case2, value2, ...) didn't
>   match any of the case parameters, and there was no default value
>   parameter (an additional last parameter) either.
> 
> So, if you have an odd number of parameters, then the last one is like
> the default branch of switch in Java.
> 
> I have also considered just returning null if there's no match, and
> then one can write ?switch(...)!theDefault, but then if someone
> doesn't give a default, the error messages will just say that
> ?switch(...) has evaluated to null/missing, which many users won't
> understand why's happening. Also it has the same problems as
> ?then(this)!that had.
> 


-- 
[email protected]     www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

------------------------------------------------------------------------------