Subject: | |
From: | |
Reply To: | |
Date: | Mon, 1 Jul 2013 18:30:29 -0400 |
Content-Type: | multipart/alternative |
Parts/Attachments: |
|
|
A moment ago, I wrote:
> I’ve invited A. Ellett (the fellow who requested \bool_case on TeX.SE)
> to join this thread and explain, but my guess would be that he's got a
> group of booleans, only one of which is supposed to be set at any
> given time: a selection from a set of mutually-exclusive options, for
> example.
This use of named options feels like it should be reasonably common in
user-facing code, but Expl3 doesn’t have an obvious way of managing this.
I recently asked “Can I refer to key value in general code?” (
http://tex.stackexchange.com/q/120258/2966). My initial thought (somewhat
bizarre, I’ll admit) was to save the option is a quark, set equal to one of
a group of quarks.
Enrico pointed me in the direction of string comparisons, and I’ve moved to
using code like this:
\keys_define:nn { jcsfonts }
{ font .choice_code:n = \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… }
This works, but does not feel entirely satisfactory. Given my C background,
I’m tempted to write an enum package, loosely wrapping l3int, to be used
something like this:
\enum_case:Vnn \g_jcsfonts_option_enum
{ \c_jcsfonts_cmodern_enum {}
\c_jcsfonts_kpfonts_enum { \RequirePackage{kpfonts} }
} { \msg_error… }
It’s too early for anything to be idiomatic LaTeX3, but what should
*become* idiomatic?
—Joel
|
|
|