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 s52NsKAP029998 for ; Tue, 3 Jun 2014 01:54:21 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx113) with ESMTPS (Nemesis) id 0MPHau-1Ww1uJ0Rhw-004TVj for ; Tue, 03 Jun 2014 01:54:15 +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 s52Np0Cw010319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Jun 2014 01:51:00 +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 s52M133W018232; Tue, 3 Jun 2014 01:50:59 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 11059260 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 3 Jun 2014 01:50:59 +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 s52NoxSC024954 for ; Tue, 3 Jun 2014 01:50:59 +0200 Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3lp0079.outbound.protection.outlook.com [213.199.154.79]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id s52NomaP010255 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Tue, 3 Jun 2014 01:50:50 +0200 Received: from [192.168.0.2] (80.177.31.128) by AMSPR05MB358.eurprd05.prod.outlook.com (10.242.224.14) with Microsoft SMTP Server (TLS) id 15.0.954.9; Mon, 2 Jun 2014 23:50:46 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 References: <538C959C.3060904@morningstar2.co.uk> <538CA727.1000203@morningstar2.co.uk> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [80.177.31.128] X-ClientProxiedBy: DB4PR03CA0007.eurprd03.prod.outlook.com (25.160.39.145) To AMSPR05MB358.eurprd05.prod.outlook.com (10.242.224.14) X-Microsoft-Antispam: BL:0;ACTION:Default;RISK:Low;SCL:0;SPMLVL:NotSpam;PCL:0;RULEID: X-Forefront-PRVS: 0230B09AC4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(6049001)(6009001)(428001)(189002)(479174003)(199002)(51704005)(53754006)(24454002)(101416001)(76176999)(54356999)(87266999)(79102001)(50986999)(92566001)(92726001)(85852003)(83072002)(4396001)(74826001)(46102001)(20776003)(50466002)(47776003)(31966008)(74662001)(81542001)(33656002)(102836001)(74482001)(74502001)(81342001)(36756003)(77982001)(21056001)(42186004)(59896001)(83506001)(15975445006)(76482001)(99396002)(65816999)(23756003)(80316001)(87976001)(83322001)(80022001)(19580395003)(66066001)(15202345003);DIR:OUT;SFP:;SCL:1;SRVR:AMSPR05MB358;H:[192.168.0.2];FPR:;MLV:sfv;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (: nag.co.uk does not designate permitted sender hosts) X-OriginatorOrg: nag.co.uk Message-ID: <538D0DD2.2090106@nag.co.uk> Date: Tue, 3 Jun 2014 00:50:42 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: David Carlisle Subject: Re: 'Preseting' keys To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <538CA727.1000203@morningstar2.co.uk> 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: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HMuuHTTKoYhrWw6GovKnK7zAP3jqJ+mZ8JUia9YwhiNKwieo3BzHzabdrty8P4O9xbRWAWONq m7DXG1I926tKJY4zMV5s/7y2xHjY+4WwaAju3MKJCMJ1yljvepXPyFABe7I5r+ylrvGY1a0gH Oh2Q4S9jKSmecktvSGwqd+YF+QhwaD/Ae9q7dgbldHXeqOnlBcncGmZ0vpWy+jwtpMnFUpLak teMo6FD6qBMwbNzVzKaf/dPPmPl4wnnA7ZNqorDzKY3KiU4K/pA554UBmQdTnp/MfrVEF49vr pqMNh1X4jhps3BBLrq4V6dp+poEb0kF5jV8vm9fzXiPq4rNByQsG0FWLtXjg8D474CJyXwvCH d/Dpu2raXZQX9Ht+pv/jGebyevuI3rAcrKNfzHqEhstyHRg2X7STMP59fy5Ta1NpaOQPbvXiQ 0Ib6OkahR8/CF9R6Xu5zeucdIb46YvmfcyPXrTCUOruFMl2kXinLB0NIfFPAL/7ePnaBy4nlv nytqS/rc7S9dFFEhwv5sXBNaGVkH9P/YjWz//EOp7 X-UI-Loop:V01:hTqQdH//LGQ=:yaCu3xJI3m/NuTXpvzi+z2OYKepMT+le32c4t3LWwok= Status: R X-Status: X-Keywords: X-UID: 7482 On 02/06/2014 17:32, Joseph Wright wrote: > On 02/06/2014 16:17, Joseph Wright wrote: >> Hello all, >> >> A reasonably common use case for keyval method is is the situation where >> one or more keys are set to a value implicitly. This is often managed in >> LaTeX using grouping. >> >> % Set up keys >> \keys_define:nn { mymod } >> { >> key-a .tl_set:N = \l_mya_tl , >> ... >> } >> \keys_set:nn { mymod } >> { >> key-a = value % Applies unless set otherwise >> } >> ... >> \group_begin: >> \keys_set:nn { mymod } >> { >> key-a = new-value >> } >> \group-end: >> % key-a will be "value" again >> \group_begin: >> \keys_set:nn { mymod } >> { >> % No key-a set => "value" >> } >> >> However, there are cases where you'd like to 'preset' the key every >> time. Currently, that would require >> >> \cs_new_protected:Npn \foo #1#2 % #1 = keys >> { >> \keys_set:nn { mymod } >> { >> key-a = new-value , >> #1 >> } >> >> but that is not that efficient and also not that clear. >> >> An alternative approach is to provide a method to 'preset' keys from >> within the key system, something like >> >> \keys_define:nn { mymod } >> { >> key-a .tl_set:N = \l_mya_tl , >> key-a .preset:n = value >> ... >> } >> >> where the presetting can avoid having to parse the keys each time it's >> run (cf. what happens in xtemplate). >> >> The team have some use cases where this makes sense, so I will be >> looking to add it as an experimental idea. Before I do, thought, I'd >> like to know if the name, etc., makes sense. It's distinct from >> ".default:n" (used if a key name is given with no property) and >> ".initial:n" (a 'set up' shortcut). >> >> I note that xkeyval offers the idea of preset keys, but in a slightly >> more complex fashion as it allows 'tail' keys and does some tests for >> the presence of keys before doing presetting. I don't see a similar >> concept in the pgfkeys manual: I have a feeling there just the 'manual' >> approach is used. >> >> Thoughts? > Particular questions here as well as the name are whether 'presetting' > depends on what is in the key list (should keys be preset if they are > found in the key list?) and what, if anything, should be done > differently in the key filtering cases. This reminds me of http://tex.stackexchange.com/questions/164116/which-arguments-of-includegraphics-cannot-be-set-beforehand/164132#164132 graphics essentially pre-sets scale=1 (it shouldn't, but it does) the unexpected user experience as a result of that is that you can go \includegraphics[scale=2]{...} but (unlike almost all other keys) you can't go \setkeys{Gin}{scale=2} \includegraphics[]{...} as the key gets set to 2 then "preset" back to 1 before any keys in the actual graphics call are handled. I can't change graphics now, but I suspect that either of the following two alternatives would have been better 1) initialise the key _at the point of definition_ so scale always had a value (defaulting to 1). 2) preset the key at the point of use, but only if it is currently unset (ie some internal macro is either undefined or has some \NoValue value, however it's implemented). This seems to be a general feature not something specific to graphics/scale so I wonder if it would be possible to accommodate these choices in a declarative l3keys interface David