Re: [vote] Opinions about conditional built-in names?
Raymond Auge <[email protected]> Fri, 5 Jun 2015 09:49:15 -0400
| Newsgroups | gmane.comp.web.freemarker.devel |
|---|---|
| Message-ID | <CAMm6HcB-9jyGfbxu_ZLUHjg6aHdpUzQdpk7jbavOBdhdLKPpnw@mail.gmail.com> |
--===============6655947730458220700== Content-Type: multipart/alternative; boundary=001a11423062d67f4d0517c58e0c --001a11423062d67f4d0517c58e0c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable +1 for: ?thenElse / ?then_else On Fri, Jun 5, 2015 at 2:31 AM, Daniel Dekany <[email protected]> wrote: > For now I have renamed > > exp?choose(whenTrue, whenFalse) > > to > > exp?then(whenTrue, whenFalse) > > because this time that was the most popular option (last year it was > ?choose for some reason). I still wonder if we should sacrifice some > terseness for being more understandable with: > > exp?then_else(whenTrue, whenFalse). > > If you hate to type "_", take into account that in 2.3.23 you can > already write templates in camel case, which will be probably the > recommended convention sooner or later. Then you have: > exp?thenElse(whenTrue, whenFalse) > > Opinions? > > -- > Thanks, > Daniel Dekany > > > Wednesday, June 3, 2015, 12:58:56 AM, Daniel Dekany wrote: > > > Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote: > > > >> thenElse is not in the style of other composite words for > >> built-ins, like cap_first, right? The style dictates ?then_else > > > > Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel > > case as well, but then you need to use camel case for everything > > that's defined by Freemarker.) > > > >> Personally I like boolean?if(true-expr, false-expr) > > > > So my concern with ?if is this that loggedIn?if(user.name, "unknown") > > can be easily misread like this, as you read it left-to-right: (We > > are) logged in IF user.name is "unknown". At last the "logged in IF > > user.name" part is especially easy to read into it, and is already the > > opposite of what the expression means (IF logged in then user.name). > > > >> Very concise. > >> > >> Jaime Garza > >> > >> -----Original Message----- > >> From: Daniel Dekany [mailto:[email protected]] > >> Sent: Tuesday, June 02, 2015 2:20 PM > >> To: FreeMarker-devel > >> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional > built-in names? > >> > >> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote: > >> > >>> 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) > >> > >> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't it? > >> Though that even longer... > >> > >> What should I notice in that Wikipedia article? > >> > >> -- > >> Thanks, > >> Daniel Dekany > >> > >> > >>> I'd learn to deal with the first of course. > >>> > >>> - Ray > >>> > >>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <[email protected]= m> > 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, > whenFalse) > >>> 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 lik= e > the > >>>>>> 'switch' very much, but I'm not sure if 'choose' is a good name fo= r > >>>>>> ternary operator. In XSL, 'choose' means just one choice of the > >>>>>> 'switch'. > >>>>> > >>>>> Actually, in XSLT "choose" stands for "switch" (and "when" stands f= or > >>>>> "case"). But that just proves how confusing this word is... > >>>> > >>>> Oh you're right. Long time passed after I wrote XSL files last. > >>>> > >>>>> > >>>>>> '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 wh= at > >>>>> 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 valu= e > >>>>>>> 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, a= nd > >>>>>>> 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 > --=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= ) --001a11423062d67f4d0517c58e0c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">+1 for: ?thenElse / ?then_else<br><br><br></div><div class= =3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, Jun 5, 2015 at 2:31= AM, Daniel Dekany <span dir=3D"ltr"><<a href=3D"mailto:ddekany@freemail= .hu" target=3D"_blank">[email protected]</a>></span> wrote:<br><blockq= uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc = solid;padding-left:1ex">For now I have renamed<br> <br> =C2=A0 exp?choose(whenTrue, whenFalse)<br> <br> to<br> <br> =C2=A0 exp?then(whenTrue, whenFalse)<br> <br> because this time that was the most popular option (last year it was<br> ?choose for some reason). I still wonder if we should sacrifice some<br> terseness for being more understandable with:<br> <br> =C2=A0 exp?then_else(whenTrue, whenFalse).<br> <br> If you hate to type "_", take into account that in 2.3.23 you can= <br> already write templates in camel case, which will be probably the<br> recommended convention sooner or later. Then you have:<br> exp?thenElse(whenTrue, whenFalse)<br> <br> Opinions?<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> --<br> Thanks,<br> =C2=A0Daniel Dekany<br> </font></span><div class=3D"HOEnZb"><div class=3D"h5"><br> <br> Wednesday, June 3, 2015, 12:58:56 AM, Daniel Dekany wrote:<br> <br> > Wednesday, June 3, 2015, 12:00:09 AM, Jaime Garza wrote:<br> ><br> >> thenElse is not in the style of other composite words for<br> >> built-ins, like cap_first, right? The style dictates ?then_else<br= > ><br> > Yes, I meant then_else. (Or... in fact, in 2.3.23 you can use camel<br= > > case as well, but then you need to use camel case for everything<br> > that's defined by Freemarker.)<br> ><br> >> Personally I like boolean?if(true-expr, false-expr)<br> ><br> > So my concern with ?if is this that loggedIn?if(<a href=3D"http://user= .name" target=3D"_blank">user.name</a>, "unknown")<br> > can be easily misread like this, as you read it left-to-right: (We<br> > are) logged in IF <a href=3D"http://user.name" target=3D"_blank">user.= name</a> is "unknown". At last the "logged in IF<br> > <a href=3D"http://user.name" target=3D"_blank">user.name</a>" par= t is especially easy to read into it, and is already the<br> > opposite of what the expression means (IF logged in then <a href=3D"ht= tp://user.name" target=3D"_blank">user.name</a>).<br> ><br> >> Very concise.<br> >><br> >> Jaime Garza<br> >><br> >> -----Original Message-----<br> >> From: Daniel Dekany [mailto:<a href=3D"mailto:[email protected]"= >[email protected]</a>]<br> >> Sent: Tuesday, June 02, 2015 2:20 PM<br> >> To: FreeMarker-devel<br> >> Subject: Re: [Freemarker-devel] [vote] Opinions about conditional = built-in names?<br> >><br> >> Tuesday, June 2, 2015, 1:54:24 PM, Raymond Auge wrote:<br> >><br> >>> Having reviewed those and due to my preferring readability ove= r<br> >>> anything else, I would still lean toward:<br> >>><br> >>> someBoolean?then(whenTrue, whenFalse)<br> >>><br> >>> But would actually prefer the more expressive:<br> >>><br> >>> someBoolean?ifelse(whenTrue, whenFalse)<br> >><br> >> Then rather someBoolean?thenElse(whenTrue, whenFalse), isn't i= t?<br> >> Though that even longer...<br> >><br> >> What should I notice in that Wikipedia article?<br> >><br> >> --<br> >> Thanks,<br> >>=C2=A0 Daniel Dekany<br> >><br> >><br> >>> I'd learn to deal with the first of course.<br> >>><br> >>> - Ray<br> >>><br> >>> On Tue, Jun 2, 2015 at 7:47 AM, Raymond Auge <<a href=3D"ma= ilto:[email protected]">[email protected]</a>> wrote:<br> >>> I lean to "then".<br> >>><br> >>> But before deciding maybe a quick look over these: <a href=3D"= http://en.wikipedia.org/wiki/%3F" target=3D"_blank">http://en.wikipedia.org= /wiki/%3F</a>:<br> >>><br> >>> - Ray<br> >>><br> >>> On Tue, Jun 2, 2015 at 3:01 AM, Daniel Dekany <<a href=3D"m= ailto:[email protected]">[email protected]</a>> wrote:<br> >>> OK, so that's like a vote for "then". Anyone els= e has an opinion? 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> >>><br> >>> --<br> >>> Thanks,<br> >>>=C2=A0 Daniel Dekany<br> >>><br> >>><br> >>> Monday, June 1, 2015, 9:41:49 PM, Woonsan Ko wrote:<br> >>><br> >>>> On 6/1/15 3:26 PM, Daniel Dekany wrote:<br> >>>>> Sunday, May 31, 2015, 7:50:20 PM, Woonsan Ko wrote:<br= > >>>>><br> >>>>>> I personally prefer having the default value optio= n inside the<br> >>>>>> parenthesis, without having to depend on the defau= lt value after '!'.<br> >>>>>> So, I like the idea the odd number of parameters f= or a default value.<br> >>>>>><br> >>>>>> Regarding the original question about 'switch&= #39; and 'choose', I like the<br> >>>>>> 'switch' very much, but I'm not sure i= f 'choose' is a good name for<br> >>>>>> ternary operator. In XSL, 'choose' means j= ust one choice of the<br> >>>>>> 'switch'.<br> >>>>><br> >>>>> Actually, in XSLT "choose" stands for "= switch" (and "when" stands for<br> >>>>> "case"). But that just proves how confusing = this word is...<br> >>>><br> >>>> Oh you're right. Long time passed after I wrote XSL fi= les last.<br> >>>><br> >>>>><br> >>>>>> 'choose' sounds like related to one of the= 'multiple' choices<br> >>>>>> to me.<br> >>>>><br> >>>>> Well, I'm also unhappy with "choose", I = just couldn't find better<br> >>>>> yet... What do you think about "then". Apart= from the lack of "else"<br> >>>>> in it, it reads quite fluently: loggedIn?then(<a href= =3D"http://user.name" target=3D"_blank">user.name</a>, "unknown")= .<br> >>>><br> >>>> Yeah, "then" sounds better to me than anything e= lse.<br> >>>><br> >>>>><br> >>>>>> Another option to consider might be 'iif' = [1], which seems a bit clearer<br> >>>>>> to me than 'either' and others.<br> >>>>>><br> >>>>>>=C2=A0 =C2=A0 =C2=A0someBoolean?iif(whenTrue, whenF= alse)<br> >>>>>><br> >>>>>> Just my two cents,<br> >>>>><br> >>>>> I have played that idea back then, but I'm afraid = very few knows what<br> >>>>> does "iif" stands for. Also loggedIn?iif(<a = href=3D"http://user.name" target=3D"_blank">user.name</a>, "unknown&qu= ot;) can be<br> >>>>> easily misread like: we are logged in IF <a href=3D"ht= tp://user.name" target=3D"_blank">user.name</a> is "unknown".<br> >>>><br> >>>> Agreed. Not sound fluent.<br> >>>><br> >>>> Kind regards,<br> >>>><br> >>>> Woonsan<br> >>>><br> >>>>><br> >>>>>> Woonsan<br> >>>>>><br> >>>>>> [1] <a href=3D"http://en.wikipedia.org/wiki/IIf" t= arget=3D"_blank">http://en.wikipedia.org/wiki/IIf</a><br> >>>>>><br> >>>>>> On 5/30/15 6:02 AM, Daniel Dekany wrote:<br> >>>>>>> And regarding the semantics of ?switch... as i= t sands now, if there's<br> >>>>>>> no matching choice, that will be an exception = that says:<br> >>>>>>><br> >>>>>>>=C2=A0 =C2=A0The value before ?switch(case1, va= lue1, case2, value2, ...) didn't<br> >>>>>>>=C2=A0 =C2=A0match any of the case parameters, = and there was no default value<br> >>>>>>>=C2=A0 =C2=A0parameter (an additional last para= meter) either.<br> >>>>>>><br> >>>>>>> So, if you have an odd number of parameters, t= hen the last one is like<br> >>>>>>> the default branch of switch in Java.<br> >>>>>>><br> >>>>>>> I have also considered just returning null if = there's no match, and<br> >>>>>>> then one can write ?switch(...)!theDefault, bu= t then if someone<br> >>>>>>> doesn't give a default, the error messages= will just say that<br> >>>>>>> ?switch(...) has evaluated to null/missing, wh= ich many users won't<br> >>>>>>> understand why's happening. Also it has th= e same problems as<br> >>>>>>> ?then(this)!that had.<br> <br> <br> ---------------------------------------------------------------------------= ---<br> _______________________________________________<br> FreeMarker-devel mailing list<br> <a href=3D"mailto:[email protected]">FreeMarker-devel@= lists.sourceforge.net</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>-- <br><div class= =3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><span style=3D"= font-family:Helvetica"><a href=3D"http://www.liferay.com/web/raymond.auge/p= rofile" target=3D"_blank"><font color=3D"#999900"><b>Raymond Aug=C3=A9</b><= /font></a>=C2=A0(@rotty3000)</span><div><span style=3D"font-family:Helvetic= a">Senior Software Architect=C2=A0</span><a href=3D"http://www.liferay.com"= style=3D"font-size:12.8000001907349px;font-family:Helvetica" target=3D"_bl= ank"><font color=3D"#999900"><b>Liferay, Inc.</b></font></a><span style=3D"= font-size:12.8000001907349px;font-family:Helvetica">=C2=A0(@Liferay)</span>= </div>Board Member & EEG Co-Chair, <a href=3D"http://osgi.org" target= =3D"_blank">OSGi Alliance</a> (@OSGiAlliance)</div></div></div></div> </div> --001a11423062d67f4d0517c58e0c-- --===============6655947730458220700== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ --===============6655947730458220700== 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 --===============6655947730458220700==--