Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id p7M1PcQn003718 for ; Mon, 22 Aug 2011 03:25:50 +0200 Received: (qmail 1766 invoked by alias); 22 Aug 2011 01:25:33 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 22 Aug 2011 01:25:33 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx028) with SMTP; 22 Aug 2011 03:25:33 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p7M1NN6O024133 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Aug 2011 03:23:23 +0200 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p7LM16wM029851; Mon, 22 Aug 2011 03:23:22 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1541919 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 22 Aug 2011 03:23:22 +0200 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p7M1NMJ4009657 for ; Mon, 22 Aug 2011 03:23:22 +0200 Received: from mail-yi0-f49.google.com (mail-yi0-f49.google.com [209.85.218.49]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p7M1NGOL024122 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 22 Aug 2011 03:23:21 +0200 Received: by yic13 with SMTP id 13so4515790yic.22 for ; Sun, 21 Aug 2011 18:23:16 -0700 (PDT) Received: by 10.236.9.71 with SMTP id 47mr10616058yhs.30.1313976196192; Sun, 21 Aug 2011 18:23:16 -0700 (PDT) Received: from staff-248-222.wireless.adelaide.edu.au (staff-248-222.wireless.adelaide.edu.au [129.127.248.222]) by mx.google.com with ESMTPS id f4sm2728582yhn.27.2011.08.21.18.23.12 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Aug 2011 18:23:15 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1081) References: <4E4FF538.7070601@morningstar2.co.uk> <9788A2B7-3E8F-4D2C-A52E-10999BCB59FA@gmail.com> <4E516DF2.4040002@morningstar2.co.uk> X-Mailer: Apple Mail (2.1081) X-Spam-Whitelist: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id p7M1NMJ4009658 Message-ID: <76ACDE5E-CD6C-4409-AAD0-448ECF9D031F@gmail.com> Date: Mon, 22 Aug 2011 10:53:06 +0930 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Will Robertson Subject: Re: couple of l3keys notes To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <4E516DF2.4040002@morningstar2.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (eXpurgate); Detail=5D7Q89H36p6sJLDpZh614CxMiiOljKSnDTNsXmG3sG6CE6iYSc/AJW+2Zf/HDEKIO0em8 z+kTfTwpL+yuTSCsrGjCRw7r0bNhc/32nBmVrAebQ4Nkfv74FkTHjlxa4bSEoPH2mR/3JWDtuDug 3jEXaSeeY1K9ogCArbVkI6VvAaKOV8qAs16Wy3Z8ctIUcN0NAnz3IUR3cA=V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 6815 On 22/08/2011, at 6:13 AM, Joseph Wright wrote: > Okay, there are several approaches we might consider in this area. There > are also questions about what is needed. For example, is it important to > _know_ the two independent lists of keys, or just to pass unknown keys > from one root to another? I guess I favour the later approach, provided > it can do the required work here. In my case, actually the former is more useful. (Well, at least to know the list of keys that weren't set.) In the vein of some of the more complex keyval packages, I don't find it super-useful to be able to set keys for multiple roots at once, as in your suggested: \keys_define:nn { foo } { unknown .redirect:n = { bar } } Perhaps I should clarify a little more here. Speaking generally, the type of option processing I am used to (say in Mathematica) would occur in something like the following stages: * Read user input of keys for some new function * Process the keys specific to this function * Do some stuff * Execute an internal function that takes the leftover keys Speaking for fontspec specifically, the reason I need multiple passes over keys is that some options are more important than others, internally. For example, depending on the "Renderer" setting, font features need to be expressed in different ways; also if the font is path-based rather than automatically found in fc-cache or whatever, its argument to \font needs to be different. So even though it might be considered a bit ugly, the general process is * Read user input with fontspec options * Decide whether the font is path-based (one keyval parse) * Decide what renderer to use and set up font-shape-specific options (another keyval parse) * Finally process all the regular font features (final, main, keyval parse) * (Actually that step happens up to eight or ten times for all the different font shape variations.) I'm certainly willing to admit that this convolution of keyval parsing and actual font-selection mechanics isn't the cleanest way to write the code, it is in some ways simpler. What I'm using presently in fontspec to do this is: \keys_define:nn {fontspec-preparse} { unknown .code:n = { \fontspec_keys_filter:n {#1} } } \cs_new:Nn \fontspec_keys_filter:n { \clist_put_right:Nx \l_fontspec_keys_leftover_clist { \l_keys_key_tl = { \exp_not:n {#1} } } } \cs_new:Nn \fontspec_keys_set:nn { \clist_clear:N \l_fontspec_keys_leftover_clist \keys_set:nn {#1} {#2} } So each \keys_set:nn stage can be separate but information from the previous can be passed along using \l_fontspec_keys_leftover_clist. (Not that this solution is particularly optimal, but it works for now.) If you'd prefer me to refactor my code before trying to accommodate this particular use case, I can certainly understand this. > I'm not sure if a separate \keys_filter: function is needed, or what is > better is an extension to \keys_define:nn such that \keys_set:nn gains > additional abilities. Taking the later approach, we might introduce a > ".redirect:n" property: > > \keys_define:nn { foo } > { > unknown .redirect:n = { bar } > } > > With this approach, we'd need to decide whether to wait until the end of > the 'parent' \keys_set:nn run before doing the redirections, or to do > the setting 'now', or indeed whether we need both variants. As I say, at > the moment I'd go with 'interleaved' setting. You can also imagine > extending such a property to named keys. While I'm not arguing that this isn't a useful feature at all, I don't think it will work for my particular case (at least with the way that the code is written now). I'd be hesitant to add such a feature, though, until a very compelling use case comes along. -- Will