summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-11-25 00:14:23 +0000
committerKarl Berry <karl@freefriends.org>2011-11-25 00:14:23 +0000
commit4796116f06de1574987757c8945f6678d21f0a40 (patch)
treeb6d95196b38ef31d6021471ecbf7c4d48fcaa730 /Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
parent27ecf3bfa131e03a530396ff6c0016cf6dffacd0 (diff)
l3kernel 2966 (19nov11)
git-svn-id: svn://tug.org/texlive/trunk@24657 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3basics.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3basics.dtx87
1 files changed, 61 insertions, 26 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
index 51bbd55bfab..fe88fa327ee 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3basics.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3basics.dtx 2896 2011-10-09 20:36:50Z joseph $
+\GetIdInfo$Id: l3basics.dtx 2915 2011-10-15 21:21:08Z bruno $
{L3 Experimental basic definitions}
%</driver|package>
%<*driver>
@@ -1143,24 +1143,6 @@
% identical. "\if_charcode:w" is an alternative name for "\if:w".
% \end{function}
%
-% \begin{function}[EXP]{\if_predicate:w}
-% \begin{syntax}
-% "\if_predicate:w" <predicate> <true code> "\else:" <false code> "\fi:"
-% \end{syntax}
-% This function takes a predicate function and
-% branches according to the result. (In practice this function would also
-% accept a single boolean variable in place of the <predicate> but to make the
-% coding clearer this should be done through "\if_bool:N".)
-% \end{function}
-%
-% \begin{function}[EXP]{\if_bool:N}
-% \begin{syntax}
-% "\if_bool:N" <boolean> <true code> "\else:" <false code> "\fi:"
-% \end{syntax}
-% This function takes a boolean variable and
-% branches according to the result.
-% \end{function}
-%
% \begin{function}[EXP]{\if_cs_exist:N, \if_cs_exist:w}
% \begin{syntax}
% "\if_cs_exist:N" <cs> <true code> "\else:" <false code> "\fi:" \\
@@ -1205,6 +1187,35 @@
% error.
% \end{function}
%
+% \section{Experimental functions}
+%
+% \begin{function}[EXP,TF,added=2011-10-10]
+% {\cs_if_exist_use:N, \cs_if_exist_use:c}
+% \begin{syntax}
+% \cs{cs_if_exist_use:NTF} \meta{control sequence} \Arg{true code} \Arg{false code}
+% \end{syntax}
+% \begin{function}[EXP,added=2011-10-10]
+% {\cs_if_exist_use:N, \cs_if_exist_use:c}
+% \begin{syntax}
+% \cs{cs_if_exist_use:N} \meta{control sequence}
+% \end{syntax}
+% If the \meta{control sequence} exists, leave it in the input stream,
+% followed by the \meta{true code} (unbraced). Otherwise, leave the
+% \meta{false} code in the input stream. For example,
+% \begin{verbatim}
+% \cs_set:Npn \mypkg_use_character:N #1
+% { \cs_if_exist_use:cF { mypkg_#1:n } { \mypkg_default:N #1 } }
+% \end{verbatim}
+% calls the function |\mypkg_#1:n| if it exists, and falls back to
+% a default action otherwise. This could also be done (more slowly)
+% using \cs{prg_case_str:xxn}.
+% \begin{texnote}
+% The \texttt{c} variants do not introduce the \meta{control sequence}
+% in the hash table if it is not there.
+% \end{texnote}
+% \end{function}
+% \end{function}
+%
% \end{documentation}
%
% \begin{implementation}
@@ -1239,8 +1250,6 @@
% \begin{macro}{\fi:}
% \begin{macro}{\reverse_if:N}
% \begin{macro}{\if:w}
-% \begin{macro}{\if_bool:N}
-% \begin{macro}{\if_predicate:w}
% \begin{macro}{\if_charcode:w}
% \begin{macro}{\if_catcode:w}
% \begin{macro}{\if_meaning:w}
@@ -1253,8 +1262,6 @@
\tex_let:D \fi: \tex_fi:D
\tex_let:D \reverse_if:N \etex_unless:D
\tex_let:D \if:w \tex_if:D
-\tex_let:D \if_bool:N \tex_ifodd:D
-\tex_let:D \if_predicate:w \tex_ifodd:D
\tex_let:D \if_charcode:w \tex_if:D
\tex_let:D \if_catcode:w \tex_ifcat:D
\tex_let:D \if_meaning:w \tex_ifx:D
@@ -1269,8 +1276,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
-% \end{macro}
-% \end{macro}
%
% \begin{macro}{\if_mode_math:}
% \begin{macro}{\if_mode_horizontal:}
@@ -2163,6 +2168,36 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[EXP,TF,added=2011-10-10]
+% {\cs_if_exist_use:N, \cs_if_exist_use:c}
+% \begin{macro}[EXP,added=2011-10-10]
+% {\cs_if_exist_use:N, \cs_if_exist_use:c}
+% The \cs{cs_if_exist_use:\ldots{}} functions cannot be implemented
+% as conditionals because the true branch must leave both the control
+% sequence itself and the true code in the input stream.
+% For the \texttt{c} variants, we are careful not to put the control
+% sequence in the hash table if it does not exist.
+% \begin{macrocode}
+\cs_set:Npn \cs_if_exist_use:NTF #1#2
+ { \cs_if_exist:NTF #1 { #1 #2} }
+\cs_set:Npn \cs_if_exist_use:NF #1
+ { \cs_if_exist:NTF #1 { #1 } }
+\cs_set:Npn \cs_if_exist_use:NT #1 #2
+ { \cs_if_exist:NTF #1 { #1#2 } { } }
+\cs_set:Npn \cs_if_exist_use:N #1
+ { \cs_if_exist:NTF #1 { #1 } { } }
+\cs_set:Npn \cs_if_exist_use:cTF #1#2
+ { \cs_if_exist:cTF {#1} { \use:c {#1} #2 } }
+\cs_set:Npn \cs_if_exist_use:cF #1
+ { \cs_if_exist:cTF {#1} { \use:c {#1} } }
+\cs_set:Npn \cs_if_exist_use:cT #1#2
+ { \cs_if_exist:cTF {#1} { \use:c {#1} #2 } { } }
+\cs_set:Npn \cs_if_exist_use:c #1
+ { \cs_if_exist:cTF {#1} { \use:c {#1} } { } }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Defining and checking (new) functions}
%
% \begin{macro}{\c_minus_one, \c_zero, \c_sixteen}
@@ -2561,7 +2596,7 @@
{ \cs_split_function:NN #1 \cs_get_arg_count_from_signature_aux:nnN }
\cs_new:Npn \cs_get_arg_count_from_signature_aux:nnN #1#2#3
{
- \if_predicate:w #3
+ \if_meaning:w \c_true_bool #3
\exp_after:wN \use_i:nn
\else:
\exp_after:wN\use_ii:nn