Re: [vote] Opinions about conditional built-in names?

Raymond Auge <[email protected]> Tue, 2 Jun 2015 07:54:24 -0400
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <CAMm6HcA1d-WozzX0TyWBLQxYEg+-mind=C+6cJwkxwjHuBR8JQ@mail.gmail.com>
--===============2513426109010343358==
Content-Type: multipart/alternative; boundary=001a1146d6488bbff30517879ace

--001a1146d6488bbff30517879ace
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Having reviewed those and due to my preferring readability over anything
else, I would still lean toward:

someBoolean?then(whenTrue, whenFalse)

But would actually prefer the more expressive:

someBoolean?ifelse(whenTrue, whenFalse)

I'd learn to deal with the first of course.

- Ray

On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[email protected]>
wrote:

> I lean to "then".
>
> But before deciding maybe a quick look over these:
> http://en.wikipedia.org/wiki/%3F:
>
> - Ray
>
> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <[email protected]> wrote=
:
>
>> OK, so that's like a vote for "then". Anyone else has an opinion? Or
>> even just a vote on the name you prefer?
>>
>> someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFals=
e)
>> or
>> someBoolean?choose(whenTrue, whenFalse)
>> or
>> something else?
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>>
>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:
>>
>> > On 6/1/15 3:26 PM, Daniel Dekany wrote:
>> >> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:
>> >>
>> >>> 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'.
>> >>
>> >> Actually, in XSLT "choose" stands for "switch" (and "when" stands for
>> >> "case"). But that just proves how confusing this word is... :)
>> >
>> > Oh you're right. Long time passed after I wrote XSL files last. :-D
>> >
>> >>
>> >>> 'choose' sounds like related to one of the 'multiple' choices
>> >>> to me.
>> >>
>> >> Well, I'm also unhappy with "choose", I just couldn't find better
>> >> yet... What do you think about "then". Apart from the lack of "else"
>> >> in it, it reads quite fluently: loggedIn?then(user.name, "unknown").
>> >
>> > Yeah, "then" sounds better to me than anything else.
>> >
>> >>
>> >>> 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,
>> >>
>> >> I have played that idea back then, but I'm afraid very few knows what
>> >> does "iif" stands for. Also loggedIn?iif(user.name, "unknown") can be
>> >> easily misread like: we are logged in IF user.name is "unknown".
>> >
>> > Agreed. Not sound fluent.
>> >
>> > Kind regards,
>> >
>> > Woonsan
>> >
>> >>
>> >>> 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.
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>> >
>>
>>
>>
>> ------------------------------------------------------------------------=
------
>> _______________________________________________
>> FreeMarker-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>>
>
>
>
> --
> *Raymond Aug=C3=A9* <http://www.liferay.com/web/raymond.auge/profile>
>  (@rotty3000)
> Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
>  (@Liferay)
> Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org>
> (@OSGiAlliance)
>



--=20
*Raymond Aug=C3=A9* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance=
)

--001a1146d6488bbff30517879ace
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div>Having reviewed those and due to my pr=
eferring readability over anything else, I would still lean toward:<br><br>=
someBoolean?then(whenTrue, whenFalse)<br><br></div>But would actually prefe=
r the more expressive:<br><br>someBoolean?ifelse(whenTrue, whenFalse)<br></=
div><br></div>I&#39;d learn to deal with the first of course.<br><br></div>=
- Ray<br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On=
 Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <span dir=3D"ltr">&lt;<a href=3D=
"mailto:[email protected]" target=3D"_blank">[email protected]=
m</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
<div>I lean to &quot;then&quot;.<br><br></div><div>But before deciding mayb=
e a quick look over these: <a href=3D"http://en.wikipedia.org/wiki/%3F" tar=
get=3D"_blank">http://en.wikipedia.org/wiki/%3F</a>:<br></div><div><br></di=
v>- Ray<br></div><div class=3D"gmail_extra"><div><div class=3D"h5"><br><div=
 class=3D"gmail_quote">On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <span =
dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">dd=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">O=
K, so that&#39;s like a vote for &quot;then&quot;. Anyone else has an opini=
on? Or<br>
even just a vote on the name you prefer?<br>
<br>
someBoolean?then(whenTrue, whenFalse)someBoolean?then(whenTrue, whenFalse)<=
br>
or<br>
someBoolean?choose(whenTrue, whenFalse)<br>
or<br>
something else?<br>
<span><font color=3D"#888888"><br>
--<br>
Thanks,<br>
=C2=A0Daniel Dekany<br>
</font></span><div><div><br>
<br>
Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:<br>
<br>
&gt; On 6/1/15 3:26 PM, Daniel Dekany wrote:<br>
&gt;&gt; Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; I personally prefer having the default value option inside the=
<br>
&gt;&gt;&gt; parenthesis, without having to depend on the default value aft=
er &#39;!&#39;.<br>
&gt;&gt;&gt; So, I like the idea the odd number of parameters for a default=
 value.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regarding the original question about &#39;switch&#39; and &#3=
9;choose&#39;, I like the<br>
&gt;&gt;&gt; &#39;switch&#39; very much, but I&#39;m not sure if &#39;choos=
e&#39; is a good name for<br>
&gt;&gt;&gt; ternary operator. In XSL, &#39;choose&#39; means just one choi=
ce of the<br>
&gt;&gt;&gt; &#39;switch&#39;.<br>
&gt;&gt;<br>
&gt;&gt; Actually, in XSLT &quot;choose&quot; stands for &quot;switch&quot;=
 (and &quot;when&quot; stands for<br>
&gt;&gt; &quot;case&quot;). But that just proves how confusing this word is=
... :)<br>
&gt;<br>
&gt; Oh you&#39;re right. Long time passed after I wrote XSL files last. :-=
D<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; &#39;choose&#39; sounds like related to one of the &#39;multip=
le&#39; choices<br>
&gt;&gt;&gt; to me.<br>
&gt;&gt;<br>
&gt;&gt; Well, I&#39;m also unhappy with &quot;choose&quot;, I just couldn&=
#39;t find better<br>
&gt;&gt; yet... What do you think about &quot;then&quot;. Apart from the la=
ck of &quot;else&quot;<br>
&gt;&gt; in it, it reads quite fluently: loggedIn?then(<a href=3D"http://us=
er.name" target=3D"_blank">user.name</a>, &quot;unknown&quot;).<br>
&gt;<br>
&gt; Yeah, &quot;then&quot; sounds better to me than anything else.<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; Another option to consider might be &#39;iif&#39; [1], which s=
eems a bit clearer<br>
&gt;&gt;&gt; to me than &#39;either&#39; and others.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;=C2=A0 =C2=A0 =C2=A0someBoolean?iif(whenTrue, whenFalse)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Just my two cents,<br>
&gt;&gt;<br>
&gt;&gt; I have played that idea back then, but I&#39;m afraid very few kno=
ws what<br>
&gt;&gt; does &quot;iif&quot; stands for. Also loggedIn?iif(<a href=3D"http=
://user.name" target=3D"_blank">user.name</a>, &quot;unknown&quot;) can be<=
br>
&gt;&gt; easily misread like: we are logged in IF <a href=3D"http://user.na=
me" target=3D"_blank">user.name</a> is &quot;unknown&quot;.<br>
&gt;<br>
&gt; Agreed. Not sound fluent.<br>
&gt;<br>
&gt; Kind regards,<br>
&gt;<br>
&gt; Woonsan<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; Woonsan<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; [1] <a href=3D"http://en.wikipedia.org/wiki/IIf" target=3D"_bl=
ank">http://en.wikipedia.org/wiki/IIf</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 5/30/15 6:02 AM, Daniel Dekany wrote:<br>
&gt;&gt;&gt;&gt; And regarding the semantics of ?switch... as it sands now,=
 if there&#39;s<br>
&gt;&gt;&gt;&gt; no matching choice, that will be an exception that says:<b=
r>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;=C2=A0 =C2=A0The value before ?switch(case1, value1, case2,=
 value2, ...) didn&#39;t<br>
&gt;&gt;&gt;&gt;=C2=A0 =C2=A0match any of the case parameters, and there wa=
s no default value<br>
&gt;&gt;&gt;&gt;=C2=A0 =C2=A0parameter (an additional last parameter) eithe=
r.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; So, if you have an odd number of parameters, then the last=
 one is like<br>
&gt;&gt;&gt;&gt; the default branch of switch in Java.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I have also considered just returning null if there&#39;s =
no match, and<br>
&gt;&gt;&gt;&gt; then one can write ?switch(...)!theDefault, but then if so=
meone<br>
&gt;&gt;&gt;&gt; doesn&#39;t give a default, the error messages will just s=
ay that<br>
&gt;&gt;&gt;&gt; ?switch(...) has evaluated to null/missing, which many use=
rs won&#39;t<br>
&gt;&gt;&gt;&gt; understand why&#39;s happening. Also it has the same probl=
ems as<br>
&gt;&gt;&gt;&gt; ?then(this)!that had.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
</div></div><div><div>-----------------------------------------------------=
-------------------------<br>
_______________________________________________<br>
FreeMarker-devel mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank"=
>[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/freemarker-devel" t=
arget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/freemarker-de=
vel</a><br>
</div></div></blockquote></div><br><br clear=3D"all"><br></div></div><span =
class=3D"HOEnZb"><font color=3D"#888888">-- <br><div><div dir=3D"ltr"><div>=
<div dir=3D"ltr"><span style=3D"font-family:Helvetica"><a href=3D"http://ww=
w.liferay.com/web/raymond.auge/profile" target=3D"_blank"><font color=3D"#9=
99900"><b>Raymond Aug=C3=A9</b></font></a>=C2=A0(@rotty3000)</span><div><sp=
an style=3D"font-family:Helvetica">Senior Software Architect=C2=A0</span><a=
 href=3D"http://www.liferay.com" style=3D"font-size:12.8000001907349px;font=
-family:Helvetica" target=3D"_blank"><font color=3D"#999900"><b>Liferay, In=
c.</b></font></a><span style=3D"font-size:12.8000001907349px;font-family:He=
lvetica">=C2=A0(@Liferay)</span></div>Board Member &amp; EEG Co-Chair, <a h=
ref=3D"http://osgi.org" target=3D"_blank">OSGi Alliance</a> (@OSGiAlliance)=
</div></div></div></div>
</font></span></div>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature"><div dir=3D"ltr"><div><div dir=3D"ltr"><span style=3D"font-family:H=
elvetica"><a href=3D"http://www.liferay.com/web/raymond.auge/profile" targe=
t=3D"_blank"><font color=3D"#999900"><b>Raymond Aug=C3=A9</b></font></a>=C2=
=A0(@rotty3000)</span><div><span style=3D"font-family:Helvetica">Senior Sof=
tware Architect=C2=A0</span><a href=3D"http://www.liferay.com" style=3D"fon=
t-size:12.8000001907349px;font-family:Helvetica" target=3D"_blank"><font co=
lor=3D"#999900"><b>Liferay, Inc.</b></font></a><span style=3D"font-size:12.=
8000001907349px;font-family:Helvetica">=C2=A0(@Liferay)</span></div>Board M=
ember &amp; EEG Co-Chair, <a href=3D"http://osgi.org" target=3D"_blank">OSG=
i Alliance</a> (@OSGiAlliance)</div></div></div></div>
</div>

--001a1146d6488bbff30517879ace--


--===============2513426109010343358==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============2513426109010343358==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
FreeMarker-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel

--===============2513426109010343358==--