Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id r6A7U5Jc015769 for ; Wed, 10 Jul 2013 09:30:06 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx003) with ESMTP (Nemesis) id 0Lyjkl-1U9qsa0VAF-016AcP for ; Wed, 10 Jul 2013 09:29:59 +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 r6A7QTQt010946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 10 Jul 2013 09:26:29 +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 r69Nk497019834; Wed, 10 Jul 2013 09:26:28 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10265981 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 10 Jul 2013 09:26:28 +0200 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r6A7GRvv009451 for ; Wed, 10 Jul 2013 09:16:28 +0200 Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r6A7GKAk015043 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Wed, 10 Jul 2013 09:16:23 +0200 Received: by mail-wg0-f44.google.com with SMTP id m15so5611696wgh.35 for ; Wed, 10 Jul 2013 00:16:20 -0700 (PDT) X-Received: by 10.180.182.228 with SMTP id eh4mr34099458wic.42.1373440580526; Wed, 10 Jul 2013 00:16:20 -0700 (PDT) Received: from [139.222.114.129] (che12-j-wright1.che.uea.ac.uk. [139.222.114.129]) by mx.google.com with ESMTPSA id fd3sm65163258wic.10.2013.07.10.00.16.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Jul 2013 00:16:19 -0700 (PDT) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 References: Content-Type: text/plain; charset=windows-1252 Message-ID: <51DD0A41.20307@morningstar2.co.uk> Date: Wed, 10 Jul 2013 08:16:17 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright 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 r6A7QTQt010946 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:4X8FB1tWicI=:Ygehe/7qBfTAgZbJwjwc0B XFm+0zRTi6L6EL7b07ZMTwsfiblRlv4sQ+JWLm0y042Patep4XLvJ7HKMvHHFA+wew0pgbf kI7g7XlW+h/zvDRk1EjSNhWmv8o0hrfi130ya910TzqdcpcdLWhBjCkZnkkktBY7UIN3cjy PJ38l75Usz16RONyESxnkkoaQhklSdaszesltvD9HJgJldrWRe5h/jnlaEjLNQvn4CKBgJq bwp0U5xPeRFB5bNuHuCOCxGqv7UvJBpqaCqT1g7ywAlftilMol9PyHK8r/JxWqaaIwjBARK KLletbZXK9NJFz33mdh26PSdry9AjaMlTDAzKNLAm5sfAztdv3bI6b4aJm+eLWd1iA36fTF VQtkag9NQBXu38FNI+2/Og9gXysmhe7kcWr0QpoKUqCGSyCjb/InLkSPDvEKrmjz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 54JV6bT8MFi5K/5TA1jS/+DuctGmlhP9pZaKgIi0Ly2BEDmuIEJT2HEjwwo+m4ObhMbpvjg NrAF2ZnhMQcgO0dABiU6hZvZ8qtK2UQ2wHT5PXtu3orETpgI/xw2P6bTo/7pQpseTOzFf3b 5jrU0074x X-UI-Loop:V01:aBhX4kZ1Tew=:DTnhW7b05LLNIB9Z4qSlGdD3xjMJxoGIRGcMv70yvTQ= Status: R X-Status: X-Keywords: X-UID: 7229 On 09/07/2013 04:27, Joel C. Salomon wrote: >>> This use of named options feels like it should be reasonably common i= n >>> user-facing code, but Expl3 doesn=92t have an obvious way of managing > 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=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. >=20 > The code in the various options is more than a single line =97 about te= n > lines per option, actually, and it seems messy to intertwine option > processing with option execution like that. What's wrong with \keys_define:nn { jcsfonts } { font .choice: , font / cmodern .code:n =3D { } , font / kpfonts .code:n =3D { \jcsfonts_kpfonts: } , ... font / unknown .code:n =3D { \jcsfonts_load_unknown:n {#1} } } or similar, i.e. placing the 'payload' in support functions (may be some are can be combined with different args: no idea what the real code is!). --=20 Joseph Wright