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 r692XMoH005439 for ; Tue, 9 Jul 2013 04:33:23 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx104) with ESMTP (Nemesis) id 0Lr4RD-1UI4yt2bw3-00ed9I for ; Tue, 09 Jul 2013 04:33:16 +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 r692Qjmv011802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Jul 2013 04:26:45 +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 r68M13mm008282; Tue, 9 Jul 2013 04:26:44 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10258394 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 9 Jul 2013 04:26:44 +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 r692Qi9N022784 for ; Tue, 9 Jul 2013 04:26:44 +0200 Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id r692QXgd011787 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 9 Jul 2013 04:26:37 +0200 Received: by mail-pd0-f175.google.com with SMTP id 4so4662594pdd.20 for ; Mon, 08 Jul 2013 19:26:33 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.66.26.179 with SMTP id m19mr25403191pag.4.1373336792806; Mon, 08 Jul 2013 19:26:32 -0700 (PDT) Received: by 10.66.150.226 with HTTP; Mon, 8 Jul 2013 19:26:32 -0700 (PDT) References: Content-Type: text/plain; charset=windows-1252 X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id r692Qi9N022785 Message-ID: Date: Mon, 8 Jul 2013 22:26:32 -0400 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch 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: Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by relay.uni-heidelberg.de id r692Qjmv011802 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:myuOiUekW/8=:ammCeeY6AwqniTRO9zRT2S jzII38k9gyBtAgm9/SR+5DmX6dIJlkmNpTfpB0Zs104OoLzqQ6Th1eGu8oeztE0eziNKhpd tfO2R8mIT3bnOLJPLAI21NmcLdhDXMTCJJHYnAiMCAIf8H6s5vh6yiO/PsXbT+evvpvDvcZ t2OOSUI7njLBv4CPZix9l/cgJ82klH44u4dLyB4f1HV6llDppxdmKsgTM4KzT5Zc/RIG818 gsB0+qo4sloHpilkHniIEt2H3Eq8W6Yb+OHK7ZWBp/HQLgrVsA6jgCuA65mVm3kqTTj4OGz L5RWrlF9o83XNhkvk4koCfQUuvHo1DZiEVMFQbM7BLWwu0TlpJo0UB0LBfIkb5+g+ce/ePl 5JtbgOic8yR8SZxicFYf7GQXVmD5qaH6/CxNKq/OONPAQJStkHifqil3gSz2nMElisalrei IXe0JEqtT2F+QlJCxDbtgjs+5mF56d5Slvu80AzQ+XaLBIoxsHQbyUySXzAbV7qfSy7MBI7 ggLwPN3qSzgyE+qdIa0/wm4j+R5A5xeQyrzr9MkWLXZ9uGuk/wv8Qgw6ESb+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UI-Loop:V01:G9rBfcjnVyY=:eE86zoRmPPVQBJvBSnY75pN66XBNBd0NDj7lINwzx4Y= Status: R X-Status: X-Keywords: X-UID: 7220 Hello Joel, Surely Joseph will have something to say about the topic (he is currently doing some changes to l3keys), but let me try. > This use of named options feels like it should be reasonably common in > user-facing code, but Expl3 doesn=92t have an obvious way of managing t= his. > > \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=85 } 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. > I recently asked =93Can I refer to key value in general code?=94 ( > http://tex.stackexchange.com/q/120258/2966). My initial thought (somewh= at > bizarre, I=92ll admit) was to save the option is a quark, set equal to = one of > a group of quarks. I think that code was missing at least one "_". Does my answer there hel= p you? > \enum_case:Vnn \g_jcsfonts_option_enum > { \c_jcsfonts_cmodern_enum {} > \c_jcsfonts_kpfonts_enum { \RequirePackage{kpfonts} } > } { \msg_error=85 } 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. Alternatively, using a property list to hold the code corresponding to each value could work (and be faster). > It=92s too early for anything to be idiomatic LaTeX3, but what should > *become* idiomatic? Well, it's not clear yet if the enum type is that useful. My second language after TeX is Python, and the enum type was only added after something like 20 years, so presumably people lived without it. An enum type seems to only be useful if it is significantly more efficient than a property list ("associative array"/"dictionary") with empty values. Regards, Bruno