LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Denis Bitouzé <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Thu, 2 Oct 2014 16:26:36 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (77 lines)
Le 02/10/14 à 09h22, Ulrike Fischer <[log in to unmask]> a écrit :

> Am Wed, 1 Oct 2014 17:39:46 +0200 schrieb
>> Now I see what you mean and I agree with you. But I guess I'd choose the
>> second case between the two following cases:
>> 
>> 1. deliberately providing a many-to-one relation between keys and value,
>>    and writing code that ensures all these values of all theses *number*
>>    keys lead to the single issue's number,
>> 2. be careful in providing a one-to-one relation between a single
>>    "number" key and issue's number value, and being able to specify that
>>    this key is required.
>
> That was what I meant with that you need to be careful to define and
> use "basic keys". 

Did I give the impression I was going to define complex keys? That's
already fairly complicated with simple ones! ;)

> Beside this there is also the timing problem Joseph mentioned: when
> should be tested if a key has been used? It is obviously not the key
> code of the key that can do it.

No, but as answered to Joseph, a `.required:' key property could
automatically check at the end of document (\AtEndDocument) that the
corresponding key has been used and, if not, emit an error message.

> So imho you are not looking for a .required property but
> a .enableifsettest property which adds and sets some boolean which you
> can later check.

I'm not sure to understand well such a .enableifsettest property, but
I guess that's what I'm currently doing by hands:

--8<---------------cut here---------------start------------->8---
\msg_new:nnnn{journal}{issue-number-needed}{Option~`#1'~needed!}
  {Please~specify~`#1=<number>'.}

\int_new:N \l_journal_issue_number_int

\keys_define:nn { journal/issuesetup }
{
  number .int_set:N = \l_journal_issue_number_int,
  number .value_required:,
  % [...]
}

\NewDocumentCommand{\issuesetup}{ m } {
  \keys_set:nn { journal/issuesetup } { #1 }
  % If `number' is not set, the corresponding integer value is 0.
  \int_compare:nNnT {\l_journal_issue_number_int}<{1}
    {
      \int_set:Nn \l_journal_issue_number_int { \c_journal_first_issue_number_int }
      \msg_warning:nnn{journal}{issue-number-needed}{number}
    }
  % [...]
}
% [...]
--8<---------------cut here---------------end--------------->8---

I must admit, checking the `number' key has been used only
\AtEndDocument would be too late in this case.

Maybe that's what you meant with `.enableifsettest': what I would need
here is, for each ⟨key⟩ tagged as required by, say, a `.required:'
property, a corresponding (/TF/ for `T', `F' or `TF'):

  ┌────
  │ \keys_has_been_used:n/TF/ {⟨key⟩} 
  │   {⟨true code⟩} {⟨false code⟩}
  └────

and, why not, a standardized (error? warning? etc.) message in `false'
case.
-- 
Denis

ATOM RSS1 RSS2