Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id r693Xa68019837 for ; Tue, 9 Jul 2013 05:33:37 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx007) with ESMTP (Nemesis) id 0LpwlL-1UIx8G0sqd-00fiXa for ; Tue, 09 Jul 2013 05:33:31 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id r693RS7i018497 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Jul 2013 05:27:28 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r68M13nG008282; Tue, 9 Jul 2013 05:27:27 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10258426 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 9 Jul 2013 05:27:27 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r693RR17024958 for ; Tue, 9 Jul 2013 05:27:27 +0200 Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id r693RHQQ018478 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 9 Jul 2013 05:27:19 +0200 Received: by mail-we0-f176.google.com with SMTP id t56so4208694wes.21 for ; Mon, 08 Jul 2013 20:27:17 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.178.138 with SMTP id cy10mr13835126wjc.61.1373340437307; Mon, 08 Jul 2013 20:27:17 -0700 (PDT) Received: by 10.194.241.165 with HTTP; Mon, 8 Jul 2013 20:27:16 -0700 (PDT) Received: by 10.194.241.165 with HTTP; Mon, 8 Jul 2013 20:27:16 -0700 (PDT) References: Content-Type: multipart/alternative; boundary=089e013d1dc6ebe7a904e10bbc6f Message-ID: Date: Mon, 8 Jul 2013 23:27:16 -0400 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: "Joel C. Salomon" Subject: Re: Named options/enumerations (Was re: Defining \bool_case:nn) To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:HKsRPZa1o3Y=:/0l8Q8XsD1y+NdbXzvobxy CaZPr6VXDMmBxScfABLV395Gizb27ib44bNNBJbqKRV2lWxuKbWfq8EuQ8o/RqnSwVYqGhz /1VfPKqchKeLHBReLRWsEHs+d5vHht16RzjCquvcuK5o80wY3uleHmzBtSCW3/Hl1feCtCm gkQDMFb2pT2jw9XKto9B4tq4gMo812yUqa7SXnkRMdZrE2IMNUH6964Uy4MpwZDKKZYviXN aylFpRIEHny7RPDvUtIiYthe2JpGQBQqSH+x/FjyUijmWg/qwU9eVJMcxjb3OZHThzHVWnT NGzx/SiM4dyGwJojDl3/tAhE3r6U23rh0ljZil1xQrcKGbScL3OWc65jZLvrISbvt8IRTcB +BF/pHElgjCm1YNj8mQvm3BAldAyTdSzEewFrqg8zw65OkMOnC3PVSfmI19aJSKA3we+qHA AwRgn27jzRvPxAGaWvN0I9j/fhMR+fCmIYF3ov12nsnew7TSoE8/N18BuHQTFuqDa0Jg7dm rAOV6lCbNaCLXVWkghCGuRTTJapTFbSpBol845UsY2jxEF5UVsDX/rM9EYP2FGyru9iHj3e Mbb1JTRRElcO8j6HZXEryM9D5BlKDL2Uv4co7C4lx4dxxH33dye/ap9kQ4qT6d9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: X-Keywords: X-UID: 7221 --089e013d1dc6ebe7a904e10bbc6f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Jul 8, 2013 10:33 PM, "Bruno Le Floch" wrote: > > Hello Joel, > > Surely Joseph will have something to say about the topic (he is > currently doing some changes to l3keys), but let me try. I've seen some of the changes already on GitHub, and they look like they'll make life simpler. > > This use of named options feels like it should be reasonably common in > > user-facing code, but Expl3 doesn=E2=80=99t have an obvious way of mana= ging this. > > > > \keys_define:nn { jcsfonts } > > { font .choice_code:n =3D \tl_gset:NV \g_jcsfonts_option_tl > > \l_keys_choice_tl } > > > > \str_case:Vnn \g_jcsfonts_option_tl > > { { cmodern } {} % Computer Modern is LaTeX default > > { kpfonts } { \RequirePackage{kpfonts} } > > } { \msg_error=E2=80=A6 } > > What about > > \keys_define:nn { jcsfonts } > { > font .choice: , > font / cmodern .code:n =3D { } , > font / kpfonts .code:n =3D { \RequirePackage{kpfonts} } , > } > > This will trigger a "key-choice-unknown" error upon encountering an > unknown choice (well, right now the message is not defined... that'll > be fixed). Maybe we could add a feature to allow arbitrary code for > unknown choices. The code in the various options is more than a single line =E2=80=94 about = ten lines per option, actually, and it seems messy to intertwine option processing with option execution like that. > > I recently asked =E2=80=9CCan I refer to key value in general code?=E2= =80=9D ( > > http://tex.stackexchange.com/q/120258/2966). My initial thought (somewhat > > bizarre, I=E2=80=99ll admit) was to save the option is a quark, set equ= al to one of > > a group of quarks. > > I think that code was missing at least one "_". Does my answer there help you? I didn't get a chance to look at it closely, but the basic idea of combining property lists and key options feels =E2=80=9Cright", and would p= rovide the decoupling I'm looking for. > I don't really get the issue with \str_case:Vnn, to be honest, and I > don't see the advantage of an enum type. Given that it makes the > syntax much more verbose, I am so far not convinced. > An enum type seems to only be useful if it is significantly more > efficient than a property list ("associative array"/"dictionary") with > empty values. I'm not fixated on enumerations, but I don't see how a property list is at all the same thing. A enum object is one that can only take one of a restricted list of values; in C it's basically a thinly-disguised integer, combined with a list of integer constants. In expl3 it could be integers or quarks (as in my bizarre idea above), whichever works better. (Or neither, if the need for such a type is not there.) Could you please explain what you meant? =E2=80=94Joel --089e013d1dc6ebe7a904e10bbc6f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Jul 8, 2013 10:33 PM, "Bruno Le Floch" <blflatex@gmail.com> wrote:
>
> Hello Joel,
>
> Surely Joseph will have something to say about the topic (he is
> currently doing some changes to l3keys), but let me try.

I've seen some of the changes already on GitHub, and they look like = they'll make life simpler.

> > This use of named options feels like it should be reasonably c= ommon in
> > user-facing code, but Expl3 doesn=E2=80=99t have an obvious way o= f managing this.
> >
> > =C2=A0 =C2=A0 \keys_define:nn { jcsfonts }
> > =C2=A0 =C2=A0 =C2=A0 { font .choice_code:n =3D \tl_gset:NV \g_jcs= fonts_option_tl
> > \l_keys_choice_tl }
> >
> > =C2=A0 =C2=A0 \str_case:Vnn \g_jcsfonts_option_tl
> > =C2=A0 =C2=A0 =C2=A0 { { cmodern } {} % Computer Modern is LaTeX = default
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 { kpfonts } { \RequirePackage{kpfonts= } }
> > =C2=A0 =C2=A0 =C2=A0 } { \msg_error=E2=80=A6 }
>
> What about
>
> =C2=A0 =C2=A0 \keys_define:nn { jcsfonts }
> =C2=A0 =C2=A0 =C2=A0 {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 font .choice: ,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 font / cmodern .code:n =3D { } ,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 font / kpfonts .code:n =3D { \RequirePacka= ge{kpfonts} } ,
> =C2=A0 =C2=A0 =C2=A0 }
>
> This will trigger a "key-choice-unknown" error upon encounte= ring an
> unknown choice (well, right now the message is not defined... that'= ;ll
> be fixed). =C2=A0Maybe we could add a feature to allow arbitrary code = for
> unknown choices.

The code in the various options is more than a single line =E2=80=94 abo= ut ten lines per option, actually, and it seems messy to intertwine option = processing with option execution like that.

> > I recently asked =E2=80=9CCan I refer to key value in general = code?=E2=80=9D (
> > http://tex= .stackexchange.com/q/120258/2966). My initial thought (somewhat
> > bizarre, I=E2=80=99ll admit) was to save the option is a quark, s= et equal to one of
> > a group of quarks.
>
> I think that code was missing at least one "_". =C2=A0Does m= y answer there help you?

I didn't get a chance to look at it closely, but the basic idea of c= ombining property lists and key options feels =E2=80=9Cright", and wou= ld provide the decoupling I'm looking for.

> I don't really get the issue with \str_case:Vnn, to be honest, = and I
> don't see the advantage of an enum type. =C2=A0Given that it makes= the
> syntax much more verbose, I am so far not convinced.
<snip>
> An enum type seems to only be useful if it is significantly more
> efficient than a property list ("associative array"/"di= ctionary") with
> empty values.

I'm not fixated on enumerations, but I don't see how a property = list is at all the same thing. A enum object is one that can only take one = of a restricted list of values; in C it's basically a thinly-disguised = integer, combined with a list of integer constants. In expl3 it could be in= tegers or quarks (as in my bizarre idea above), whichever works better. (Or= neither, if the need for such a type is not there.)

Could you please explain what you meant?

=E2=80=94Joel

--089e013d1dc6ebe7a904e10bbc6f--