LATEX-L Archives

Mailing list for the LaTeX3 project


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
Denis Bitouzé <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Wed, 1 Oct 2014 16:46:13 +0200
text/plain (82 lines)
Le 01/10/14 à 15h18, Ulrike Fischer
<[log in to unmask]> a écrit :

> Am Tue, 30 Sep 2014 19:00:52 +0200 schrieb
> [log in to unmask]:
>> In the use case I have in mind, `key' would be required and expect an
>> integer. Would it be missing, an error message would be emitted; would
>> its value be anything but an integer, an(other) error message would be
>> emitted.
> It is normally not the *key* that is required but a *value*

Except if some keys are considered as mandatory arguments (and they
could not be turned into arguments because keys are much more explicit
than arguments).

> and there is no one-to-one relation between keys and values: e.g. in
> geometry you can set the left margins through the keys hmargin,
> margin, implicitly when you set other width etc.


> So a key property .required would be senseful only for "basic keys"
> and you would have to be very careful that you use these basic key
> if you set the value with other keys too.

Indeed but I guess I wouldn't be bitten by this in my real usecase.

> Imho it is easier and more logical to test for the value and emit an
> error if is doesn't exist.

OK but, AFAICS, there isn't any high level key property for this (and
that's the point of this thread): `.value_required:' tests for the value
only if the corresponding key is used. This is pointed out by the
following MWE (that outlines my real usecase as detailed yesterday): the
`month' key property has the `.value_required:' property but nothing
happens if it isn't used.

--8<---------------cut here---------------start------------->8---

\int_new:N \l_issue_number_int
\int_new:N \l_issue_month_int
\int_new:N \l_issue_year_int

\keys_define:nn { journal/issuesetup }
  number .int_set:N = \l_issue_number_int,
  month .int_set:N = \l_issue_month_int,
  year .int_set:N = \l_issue_year_int,
  number .value_required:,
  month .value_required:,
  year .value_required:,

\NewDocumentCommand{\issuesetup}{ m } {
  \keys_set:nn { journal/issuesetup } { #1 }
  The~issue's~number~is:~\int_use:N \l_issue_number_int

--8<---------------cut here---------------end--------------->8---

> (Actually I wouldn't emit an error. As almost everyone is using
> scrollmode today error message are often ignored.

Most of the TeX editors highlight errors, no? At least it is the case
for TeXstudio, for instance.

>  I would give the issue number a default value of
> a {\Huge\color{red}XXXXXXX})

I could provide both of them: belt /and/ suspenders! :)