%%
%% This is file `l3basics.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3basics.dtx  (with options: `package')
%% 
%% EXPERIMENTAL CODE
%% 
%% Do not distribute this file without also distributing the
%% source files specified above.
%% 
%% Do not distribute a modified version of this file.
%% 
%% File: l3basics.dtx Copyright (C) 1990-2011 The LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3kernel bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX3 Project.
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
\GetIdInfo$Id: l3basics.dtx 2896 2011-10-09 20:36:50Z joseph $
  {L3 Experimental basic definitions}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\package_check_loaded_expl:
\tex_let:D \if_true:           \tex_iftrue:D
\tex_let:D \if_false:          \tex_iffalse:D
\tex_let:D \or:                \tex_or:D
\tex_let:D \else:              \tex_else:D
\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
\tex_let:D \if_mode_math:       \tex_ifmmode:D
\tex_let:D \if_mode_horizontal: \tex_ifhmode:D
\tex_let:D \if_mode_vertical:   \tex_ifvmode:D
\tex_let:D \if_mode_inner:      \tex_ifinner:D
\tex_let:D \if_cs_exist:N      \etex_ifdefined:D
\tex_let:D \if_cs_exist:w      \etex_ifcsname:D
\tex_let:D \exp_after:wN       \tex_expandafter:D
\tex_let:D \exp_not:N          \tex_noexpand:D
\tex_let:D \exp_not:n          \etex_unexpanded:D
\tex_let:D \token_to_meaning:N \tex_meaning:D
\tex_let:D \token_to_str:N     \tex_string:D
\tex_let:D \cs:w               \tex_csname:D
\tex_let:D \cs_end:            \tex_endcsname:D
\tex_let:D \cs_meaning:N       \tex_meaning:D
\tex_let:D \cs_show:N          \tex_show:D
\tex_let:D \scan_stop:         \tex_relax:D
\tex_let:D \group_begin:       \tex_begingroup:D
\tex_let:D \group_end:         \tex_endgroup:D
\tex_let:D \if_int_compare:w   \tex_ifnum:D
\tex_let:D \int_to_roman:w     \tex_romannumeral:D
\tex_let:D \group_insert_after:N \tex_aftergroup:D
\tex_let:D \tex_global:D      \tex_global:D
\tex_let:D \tex_long:D        \tex_long:D
\tex_let:D \tex_protected:D   \etex_protected:D
\tex_long:D \tex_def:D \exp_args:Nc #1#2 { \exp_after:wN #1 \cs:w #2 \cs_end: }
%%  A small number of variants by hand.
\tex_def:D \cs_meaning:c   { \exp_args:Nc \cs_meaning:N }
\tex_def:D \token_to_str:c { \exp_args:Nc \token_to_str:N }
\tex_def:D \cs_show:c      { \exp_args:Nc \cs_show:N }
\tex_let:D \cs_set_nopar:Npn            \tex_def:D
\tex_let:D \cs_set_nopar:Npx            \tex_edef:D
\tex_protected:D \cs_set_nopar:Npn \cs_set:Npn
  { \tex_long:D \cs_set_nopar:Npn }
\tex_protected:D \cs_set_nopar:Npn \cs_set:Npx
  { \tex_long:D \cs_set_nopar:Npx }
\tex_protected:D \cs_set_nopar:Npn \cs_set_protected_nopar:Npn
  { \tex_protected:D \cs_set_nopar:Npn }
\tex_protected:D \cs_set_nopar:Npn \cs_set_protected_nopar:Npx
  { \tex_protected:D \cs_set_nopar:Npx }
\cs_set_protected_nopar:Npn \cs_set_protected:Npn
  { \tex_protected:D \tex_long:D \cs_set_nopar:Npn }
\cs_set_protected_nopar:Npn \cs_set_protected:Npx
  { \tex_protected:D \tex_long:D \cs_set_nopar:Npx }
\tex_let:D \cs_gset_nopar:Npn           \tex_gdef:D
\tex_let:D \cs_gset_nopar:Npx           \tex_xdef:D
\cs_set_protected_nopar:Npn \cs_gset:Npn
  { \tex_long:D \cs_gset_nopar:Npn }
\cs_set_protected_nopar:Npn \cs_gset:Npx
  { \tex_long:D \cs_gset_nopar:Npx }
\cs_set_protected_nopar:Npn \cs_gset_protected_nopar:Npn
  { \tex_protected:D \cs_gset_nopar:Npn }
\cs_set_protected_nopar:Npn \cs_gset_protected_nopar:Npx
  { \tex_protected:D \cs_gset_nopar:Npx }
\cs_set_protected_nopar:Npn \cs_gset_protected:Npn
  { \tex_protected:D \tex_long:D \cs_gset_nopar:Npn }
\cs_set_protected_nopar:Npn \cs_gset_protected:Npx
  { \tex_protected:D \tex_long:D \cs_gset_nopar:Npx }
\cs_set:Npn \use:c #1 { \cs:w #1 \cs_end: }
\cs_set_protected:Npn \use:x #1
  {
    \group_begin:
      \cs_set:Npx \cs_tmp:w {#1}
      \exp_after:wN
    \group_end:
    \cs_tmp:w
  }
\cs_set:Npn \cs_tmp:w { }
\cs_set:Npn \use:n    #1       {#1}
\cs_set:Npn \use:nn   #1#2     {#1#2}
\cs_set:Npn \use:nnn  #1#2#3   {#1#2#3}
\cs_set:Npn \use:nnnn #1#2#3#4 {#1#2#3#4}
\cs_set:Npn \use_i:nn  #1#2 {#1}
\cs_set:Npn \use_ii:nn #1#2 {#2}
\cs_set:Npn \use_i:nnn    #1#2#3 {#1}
\cs_set:Npn \use_ii:nnn   #1#2#3 {#2}
\cs_set:Npn \use_iii:nnn  #1#2#3 {#3}
\cs_set:Npn \use_i_ii:nnn #1#2#3 {#1#2}
\cs_set:Npn \use_i:nnnn   #1#2#3#4 {#1}
\cs_set:Npn \use_ii:nnnn  #1#2#3#4 {#2}
\cs_set:Npn \use_iii:nnnn #1#2#3#4 {#3}
\cs_set:Npn \use_iv:nnnn  #1#2#3#4 {#4}
\cs_set:Npn \use_none_delimit_by_q_nil:w  #1 \q_nil  { }
\cs_set:Npn \use_none_delimit_by_q_stop:w #1 \q_stop { }
\cs_set:Npn \use_none_delimit_by_q_recursion_stop:w #1 \q_recursion_stop { }
\cs_set:Npn \use_i_delimit_by_q_nil:nw  #1#2 \q_nil  {#1}
\cs_set:Npn \use_i_delimit_by_q_stop:nw #1#2 \q_stop {#1}
\cs_set:Npn \use_i_delimit_by_q_recursion_stop:nw #1#2 \q_recursion_stop {#1}
\cs_set:Npn \use_none:n         #1                 { }
\cs_set:Npn \use_none:nn        #1#2               { }
\cs_set:Npn \use_none:nnn       #1#2#3             { }
\cs_set:Npn \use_none:nnnn      #1#2#3#4           { }
\cs_set:Npn \use_none:nnnnn     #1#2#3#4#5         { }
\cs_set:Npn \use_none:nnnnnn    #1#2#3#4#5#6       { }
\cs_set:Npn \use_none:nnnnnnn   #1#2#3#4#5#6#7     { }
\cs_set:Npn \use_none:nnnnnnnn  #1#2#3#4#5#6#7#8   { }
\cs_set:Npn \use_none:nnnnnnnnn #1#2#3#4#5#6#7#8#9 { }
\cs_set_nopar:Npn \prg_return_true:
  { \exp_after:wN \use_i:nn  \int_to_roman:w }
\cs_set_nopar:Npn \prg_return_false:
  { \exp_after:wN \use_ii:nn \int_to_roman:w}
\cs_set_protected:Npn \prg_set_conditional:Npnn #1
  {
    \prg_get_parm_aux:nw
      {
        \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
        \cs_set:Npn { parm }
      }
  }
\cs_set_protected:Npn \prg_new_conditional:Npnn #1
  {
    \prg_get_parm_aux:nw
      {
        \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
        \cs_new:Npn { parm }
      }
  }
\cs_set_protected:Npn \prg_set_protected_conditional:Npnn #1
  {
    \prg_get_parm_aux:nw{
      \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
      \cs_set_protected:Npn { parm }
    }
  }
\cs_set_protected:Npn \prg_new_protected_conditional:Npnn #1
  {
    \prg_get_parm_aux:nw
      {
        \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
        \cs_new_protected:Npn { parm }
     }
  }
\cs_set_protected:Npn \prg_set_conditional:Nnn #1
  {
    \exp_args:Nnf \prg_get_count_aux:nn
      {
        \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
        \cs_set:Npn { count }
      }
      { \cs_get_arg_count_from_signature:N #1 }
  }
\cs_set_protected:Npn \prg_new_conditional:Nnn #1
  {
    \exp_args:Nnf \prg_get_count_aux:nn
      {
        \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
        \cs_new:Npn { count}
      }
      { \cs_get_arg_count_from_signature:N #1 }
  }

\cs_set_protected:Npn \prg_set_protected_conditional:Nnn #1{
  \exp_args:Nnf \prg_get_count_aux:nn{
    \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
    \cs_set_protected:Npn {count}
  }{\cs_get_arg_count_from_signature:N #1}
}

\cs_set_protected:Npn \prg_new_protected_conditional:Nnn #1
  {
    \exp_args:Nnf \prg_get_count_aux:nn
      {
        \cs_split_function:NN #1 \prg_generate_conditional_aux:nnNNnnnn
        \cs_new_protected:Npn {count}
      }
      { \cs_get_arg_count_from_signature:N #1 }
  }
\cs_set_protected:Npn \prg_set_eq_conditional:NNn #1#2#3
  { \prg_set_eq_conditional_aux:NNNn \cs_set_eq:cc #1#2 {#3} }
\cs_set_protected:Npn \prg_new_eq_conditional:NNn #1#2#3
  { \prg_set_eq_conditional_aux:NNNn \cs_new_eq:cc #1#2 {#3} }
\cs_set:Npn \prg_get_count_aux:nn #1#2 { #1 {#2} }
\cs_set:Npn \prg_get_parm_aux:nw #1#2# { #1 {#2} }
\cs_set_protected:Npn \prg_generate_conditional_aux:nnNNnnnn #1#2#3#4#5#6#7#8
  {
    \prg_generate_conditional_aux:nnw {#5}
      {
        #4 {#1} {#2} {#6} {#8}
      }
      #7 , ? , \q_recursion_stop
  }
\cs_set_protected:Npn \prg_generate_conditional_aux:nnw #1#2#3 ,
  {
    \if:w ?#3
      \exp_after:wN \use_none_delimit_by_q_recursion_stop:w
    \fi:
    \use:c { prg_generate_#3_form_#1:Nnnnn } #2
    \prg_generate_conditional_aux:nnw {#1} {#2}
  }
\cs_set_protected:Npn \prg_generate_p_form_parm:Nnnnn #1#2#3#4#5
  {
    \exp_args:Nc #1 { #2 _p: #3 } #4
      {
        #5 \c_zero
        \c_true_bool \c_false_bool
      }
  }
\cs_set_protected:Npn \prg_generate_T_form_parm:Nnnnn #1#2#3#4#5
  {
    \exp_args:Nc #1 { #2 : #3 T } #4
      {
        #5 \c_zero
        \use:n \use_none:n
      }
  }
\cs_set_protected:Npn \prg_generate_F_form_parm:Nnnnn #1#2#3#4#5
  {
    \exp_args:Nc #1 { #2 : #3 F } #4
      {
        #5 \c_zero
        { }
      }
  }
\cs_set_protected:Npn \prg_generate_TF_form_parm:Nnnnn #1#2#3#4#5
  {
    \exp_args:Nc #1 { #2 : #3 TF } #4
      { #5 \c_zero }
  }
\cs_set_protected:Npn \prg_generate_p_form_count:Nnnnn #1#2#3#4#5
  {
    \cs_generate_from_arg_count:cNnn { #2 _p: #3 } #1 {#4}
      {
        #5 \c_zero
        \c_true_bool \c_false_bool
      }
  }
\cs_set_protected:Npn \prg_generate_T_form_count:Nnnnn #1#2#3#4#5
  {
    \cs_generate_from_arg_count:cNnn { #2 : #3 T } #1 {#4}
      {
        #5 \c_zero
        \use:n \use_none:n
      }
  }
\cs_set_protected:Npn \prg_generate_F_form_count:Nnnnn #1#2#3#4#5
  {
    \cs_generate_from_arg_count:cNnn { #2 : #3 F } #1 {#4}
      {
        #5 \c_zero
        { }
      }
  }
\cs_set_protected:Npn \prg_generate_TF_form_count:Nnnnn #1#2#3#4#5
  {
    \cs_generate_from_arg_count:cNnn { #2 : #3 TF } #1 {#4}
      { #5 \c_zero }
  }
\cs_set_protected:Npn \prg_set_eq_conditional_aux:NNNn #1#2#3#4
 { \prg_set_eq_conditional_aux:NNNw #1#2#3#4 , ? , \q_recursion_stop }
\cs_set_protected:Npn \prg_set_eq_conditional_aux:NNNw #1#2#3#4 ,
  {
    \if:w ? #4 \scan_stop:
      \exp_after:wN \use_none_delimit_by_q_recursion_stop:w
    \fi:
    #1
    { \exp_args:NNc \cs_split_function:NN #2 { prg_conditional_form_#4:nnn } }
    { \exp_args:NNc \cs_split_function:NN #3 { prg_conditional_form_#4:nnn } }
    \prg_set_eq_conditional_aux:NNNw #1 {#2} {#3}
  }
\cs_set:Npn \prg_conditional_form_p:nnn  #1#2#3 { #1 _p : #2 }
\cs_set:Npn \prg_conditional_form_TF:nnn #1#2#3 { #1    : #2 TF }
\cs_set:Npn \prg_conditional_form_T:nnn  #1#2#3 { #1    : #2 T }
\cs_set:Npn \prg_conditional_form_F:nnn  #1#2#3 { #1    : #2 F }
\tex_chardef:D \c_true_bool  = 1~
\tex_chardef:D \c_false_bool = 0~
\cs_set_nopar:Npn \cs_to_str:N
  {
    \if:w \int_to_roman:w - `0 \token_to_str:N \ %
      \cs_to_str_aux:w
    \fi:
    \exp_after:wN \use_none:n \token_to_str:N
 }
\cs_set_nopar:Npn \cs_to_str_aux:w #1 \use_none:n
  { ~ \int_to_roman:w - `0 \fi: }
\group_begin:
  \tex_lccode:D  `\@ = `\: \scan_stop:
  \tex_catcode:D `\@ = 12~
\tex_lowercase:D
  {
    \group_end:
    \cs_set:Npn \cs_split_function:NN #1#2
      {
        \exp_after:wN \cs_split_function_aux:w
          \int_to_roman:w - `\q \cs_to_str:N #1 @ a \q_stop #2
      }
    \cs_set:Npn \cs_split_function_aux:w #1 @ #2#3 \q_stop #4
      {
        \if_meaning:w a #2
          \exp_after:wN \use_i:nn
        \else:
          \exp_after:wN\use_ii:nn
        \fi:
        { #4 {#1} { } \c_false_bool }
        { \cs_split_function_auxii:w #2#3 \q_stop #4 {#1} }
      }
    \cs_set:Npn \cs_split_function_auxii:w #1 @a \q_stop #2#3
      { #2{#3}{#1}\c_true_bool }
  }
\cs_set:Npn \cs_get_function_name:N #1
  { \cs_split_function:NN #1 \use_i:nnn }
\cs_set:Npn \cs_get_function_signature:N #1
  { \cs_split_function:NN #1 \use_ii:nnn }
\prg_set_conditional:Npnn \cs_if_exist:N #1 { p , T , F , TF }
  {
    \if_meaning:w #1 \scan_stop:
      \prg_return_false:
    \else:
      \if_cs_exist:N #1
        \prg_return_true:
      \else:
        \prg_return_false:
      \fi:
    \fi:
  }
\prg_set_conditional:Npnn \cs_if_exist:c #1 { p , T , F , TF }
  {
    \if_cs_exist:w #1 \cs_end:
      \exp_after:wN \use_i:nn
    \else:
      \exp_after:wN \use_ii:nn
    \fi:
    {
      \exp_after:wN \if_meaning:w \cs:w #1 \cs_end: \scan_stop:
        \prg_return_false:
      \else:
        \prg_return_true:
      \fi:
    }
    \prg_return_false:
  }
\prg_set_conditional:Npnn \cs_if_free:N #1 { p , T , F , TF }
  {
    \if_meaning:w #1 \scan_stop:
      \prg_return_true:
    \else:
      \if_cs_exist:N #1
        \prg_return_false:
      \else:
        \prg_return_true:
      \fi:
    \fi:
  }
\prg_set_conditional:Npnn \cs_if_free:c #1 { p , T , F , TF }
  {
    \if_cs_exist:w #1 \cs_end:
      \exp_after:wN \use_i:nn
    \else:
      \exp_after:wN \use_ii:nn
    \fi:
      {
        \exp_after:wN \if_meaning:w \cs:w #1 \cs_end: \scan_stop:
          \prg_return_true:
        \else:
          \prg_return_false:
        \fi:
      }
      { \prg_return_true: }
  }
\tex_let:D \c_minus_one \m@ne
\tex_chardef:D \c_sixteen = 16~
\tex_chardef:D \c_zero    = 0~
\tex_chardef:D \c_six     = 6~
\tex_chardef:D \c_seven   = 7~
\tex_chardef:D \c_twelve  = 12~
\tex_mathchardef:D \c_max_register_int = 32 767 \scan_stop:
\cs_set_protected_nopar:Npn \iow_log:x
  { \tex_immediate:D \tex_write:D \c_minus_one }
\cs_set_protected_nopar:Npn \iow_term:x
  { \tex_immediate:D \tex_write:D \c_sixteen }
\cs_set_protected_nopar:Npn \msg_kernel_error:nnxx #1#2#3#4
  {
    \tex_errmessage:D
      {
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!~! ^^J
        Argh,~internal~LaTeX3~error! ^^J ^^J
        Module ~ #1 , ~ message~name~"#2": ^^J
        Arguments~'#3'~and~'#4' ^^J ^^J
        This~is~one~for~The~LaTeX3~Project:~bailing~out
      }
    \tex_end:D
  }
\cs_set_protected_nopar:Npn \msg_kernel_error:nnx #1#2#3
  { \msg_kernel_error:nnxx {#1} {#2} {#3} { } }
\cs_set_protected_nopar:Npn \msg_kernel_error:nn #1#2
  { \msg_kernel_error:nnxx {#1} {#2} { } { } }
\cs_set_nopar:Npn \msg_line_context:
  { on~line~\tex_the:D \tex_inputlineno:D }
\cs_set_protected_nopar:Npn \chk_if_free_cs:N #1
  {
    \cs_if_free:NF #1
      {
        \msg_kernel_error:nnxx { kernel } { command-already-defined }
          { \token_to_str:N #1 } { \token_to_meaning:N #1 }
      }
}
\tex_ifodd:D \l@expl@log@functions@bool
  \cs_set_protected_nopar:Npn \chk_if_free_cs:N #1
    {
      \cs_if_free:NF #1
        {
          \msg_kernel_error:nnxx { kernel } { command-already-defined }
            { \token_to_str:N #1 } { \token_to_meaning:N #1 }
        }
    \iow_log:x { Defining~\token_to_str:N #1~ \msg_line_context: }
  }
\fi:
\cs_set_protected_nopar:Npn \chk_if_free_cs:c
  { \exp_args:Nc \chk_if_free_cs:N }
\cs_set_protected_nopar:Npn \chk_if_exist_cs:N #1
  {
    \cs_if_exist:NF #1
      {
        \msg_kernel_error:nnxx { kernel } { command-not-defined }
          { \token_to_str:N #1 } { \token_to_meaning:N #1 }
      }
  }
\cs_set_protected_nopar:Npn \chk_if_exist_cs:c
  { \exp_args:Nc \chk_if_exist_cs:N }
\cs_set:Npn \cs_tmp:w #1#2
  {
    \cs_set_protected_nopar:Npn #1 ##1
       {
         \chk_if_free_cs:N ##1
         #2 ##1
      }
  }
\cs_tmp:w \cs_new_nopar:Npn           \cs_gset_nopar:Npn
\cs_tmp:w \cs_new_nopar:Npx           \cs_gset_nopar:Npx
\cs_tmp:w \cs_new:Npn                 \cs_gset:Npn
\cs_tmp:w \cs_new:Npx                 \cs_gset:Npx
\cs_tmp:w \cs_new_protected_nopar:Npn \cs_gset_protected_nopar:Npn
\cs_tmp:w \cs_new_protected_nopar:Npx \cs_gset_protected_nopar:Npx
\cs_tmp:w \cs_new_protected:Npn       \cs_gset_protected:Npn
\cs_tmp:w \cs_new_protected:Npx       \cs_gset_protected:Npx
\cs_set:Npn \cs_tmp:w #1#2
  { \cs_new_protected_nopar:Npn #1 { \exp_args:Nc #2 } }
\cs_tmp:w \cs_set_nopar:cpn  \cs_set_nopar:Npn
\cs_tmp:w \cs_set_nopar:cpx  \cs_set_nopar:Npx
\cs_tmp:w \cs_gset_nopar:cpn \cs_gset_nopar:Npn
\cs_tmp:w \cs_gset_nopar:cpx \cs_gset_nopar:Npx
\cs_tmp:w \cs_new_nopar:cpn  \cs_new_nopar:Npn
\cs_tmp:w \cs_new_nopar:cpx  \cs_new_nopar:Npx
\cs_tmp:w \cs_set:cpn  \cs_set:Npn
\cs_tmp:w \cs_set:cpx  \cs_set:Npx
\cs_tmp:w \cs_gset:cpn \cs_gset:Npn
\cs_tmp:w \cs_gset:cpx \cs_gset:Npx
\cs_tmp:w \cs_new:cpn  \cs_new:Npn
\cs_tmp:w \cs_new:cpx  \cs_new:Npx
\cs_tmp:w \cs_set_protected_nopar:cpn  \cs_set_protected_nopar:Npn
\cs_tmp:w \cs_set_protected_nopar:cpx  \cs_set_protected_nopar:Npx
\cs_tmp:w \cs_gset_protected_nopar:cpn \cs_gset_protected_nopar:Npn
\cs_tmp:w \cs_gset_protected_nopar:cpx \cs_gset_protected_nopar:Npx
\cs_tmp:w \cs_new_protected_nopar:cpn  \cs_new_protected_nopar:Npn
\cs_tmp:w \cs_new_protected_nopar:cpx  \cs_new_protected_nopar:Npx
\cs_tmp:w \cs_set_protected:cpn  \cs_set_protected:Npn
\cs_tmp:w \cs_set_protected:cpx  \cs_set_protected:Npx
\cs_tmp:w \cs_gset_protected:cpn \cs_gset_protected:Npn
\cs_tmp:w \cs_gset_protected:cpx \cs_gset_protected:Npx
\cs_tmp:w \cs_new_protected:cpn  \cs_new_protected:Npn
\cs_tmp:w \cs_new_protected:cpx  \cs_new_protected:Npx
\cs_new_protected:Npn \cs_set_eq:NN #1 { \tex_let:D #1 =~ }
\cs_new_protected_nopar:Npn \cs_set_eq:cN { \exp_args:Nc  \cs_set_eq:NN }
\cs_new_protected_nopar:Npn \cs_set_eq:Nc { \exp_args:NNc \cs_set_eq:NN }
\cs_new_protected_nopar:Npn \cs_set_eq:cc { \exp_args:Ncc \cs_set_eq:NN }
\cs_new_protected:Npn \cs_new_eq:NN #1
  {
    \chk_if_free_cs:N #1
    \tex_global:D \cs_set_eq:NN #1
  }
\cs_new_protected_nopar:Npn \cs_new_eq:cN { \exp_args:Nc  \cs_new_eq:NN }
\cs_new_protected_nopar:Npn \cs_new_eq:Nc { \exp_args:NNc \cs_new_eq:NN }
\cs_new_protected_nopar:Npn \cs_new_eq:cc { \exp_args:Ncc \cs_new_eq:NN }
\cs_new_protected_nopar:Npn \cs_gset_eq:NN { \tex_global:D  \cs_set_eq:NN }
\cs_new_protected_nopar:Npn \cs_gset_eq:Nc { \exp_args:NNc  \cs_gset_eq:NN }
\cs_new_protected_nopar:Npn \cs_gset_eq:cN { \exp_args:Nc   \cs_gset_eq:NN }
\cs_new_protected_nopar:Npn \cs_gset_eq:cc { \exp_args:Ncc  \cs_gset_eq:NN }
\cs_new_protected_nopar:Npn \cs_undefine:N #1
  { \cs_gset_eq:NN #1 \c_undefined:D }
\cs_new_protected_nopar:Npn \cs_undefine:c #1
  {
    \if_cs_exist:w #1 \cs_end:
      \exp_after:wN \use:n
    \else:
      \exp_after:wN \use_none:n
    \fi:
    { \cs_gset_eq:cN {#1} \c_undefined:D }
  }
\cs_new:Npn \cs_get_arg_count_from_signature:N #1
  { \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
      \exp_after:wN \use_i:nn
    \else:
      \exp_after:wN\use_ii:nn
    \fi:
    {
      \exp_after:wN \cs_get_arg_count_from_signature_auxii:w
        \use_none:nnnnnnnnn  #2 9876543210 \q_stop
    }
    { -1 }
}
\cs_new:Npn \cs_get_arg_count_from_signature_auxii:w #1#2 \q_stop {#1}
\cs_new_nopar:Npn \cs_get_arg_count_from_signature:c
  { \exp_args:Nc \cs_get_arg_count_from_signature:N }
\cs_new_protected:Npn \cs_generate_from_arg_count:NNnn #1#2#3#4
  {
    \if_case:w \int_eval:w #3 \int_eval_end:
         \cs_generate_from_arg_count_aux:nwn {}
    \or: \cs_generate_from_arg_count_aux:nwn {##1}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3##4}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3##4##5}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3##4##5##6}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3##4##5##6##7}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3##4##5##6##7##8}
    \or: \cs_generate_from_arg_count_aux:nwn {##1##2##3##4##5##6##7##8##9}
    \else:
      \cs_generate_from_arg_count_error_msg:Nn #1 {#3}
      \use_i:nnn
    \fi:
    {#2#1}
    {#4}
  }
\cs_new_protected_nopar:Npn
  \cs_generate_from_arg_count_aux:nwn #1 #2 \fi: #3
  { \fi: #3 #1 }
\cs_new_nopar:Npn \cs_generate_from_arg_count:cNnn
  { \exp_args:Nc \cs_generate_from_arg_count:NNnn }
\cs_new:Npn \cs_generate_from_arg_count_error_msg:Nn #1#2
  {
    \msg_kernel_error:nnxx { kernel } { bad-number-of-arguments }
      { \token_to_str:N #1 } { \int_eval:n {#2} }
  }
\cs_set:Npn \cs_tmp:w #1#2#3
  {
    \cs_set_protected:cpx { cs_ #1 : #2 } ##1##2
      {
        \exp_not:N \cs_generate_from_arg_count:NNnn ##1
        \exp_after:wN \exp_not:N \cs:w cs_#1 : #3 \cs_end:
          { \exp_not:N\cs_get_arg_count_from_signature:N ##1 }{##2}
      }
  }
\cs_tmp:w { set }                  { Nn } { Npn }
\cs_tmp:w { set }                  { Nx } { Npx }
\cs_tmp:w { set_nopar }            { Nn } { Npn }
\cs_tmp:w { set_nopar }            { Nx } { Npx }
\cs_tmp:w { set_protected }        { Nn } { Npn }
\cs_tmp:w { set_protected }        { Nx } { Npx }
\cs_tmp:w { set_protected_nopar }  { Nn } { Npn }
\cs_tmp:w { set_protected_nopar }  { Nx } { Npx }
\cs_tmp:w { gset }                 { Nn } { Npn }
\cs_tmp:w { gset }                 { Nx } { Npx }
\cs_tmp:w { gset_nopar }           { Nn } { Npn }
\cs_tmp:w { gset_nopar }           { Nx } { Npx }
\cs_tmp:w { gset_protected }       { Nn } { Npn }
\cs_tmp:w { gset_protected }       { Nx } { Npx }
\cs_tmp:w { gset_protected_nopar } { Nn } { Npn }
\cs_tmp:w { gset_protected_nopar } { Nx } { Npx }
\cs_tmp:w { new }                 { Nn } { Npn }
\cs_tmp:w { new }                 { Nx } { Npx }
\cs_tmp:w { new_nopar }           { Nn } { Npn }
\cs_tmp:w { new_nopar }           { Nx } { Npx }
\cs_tmp:w { new_protected }       { Nn } { Npn }
\cs_tmp:w { new_protected }       { Nx } { Npx }
\cs_tmp:w { new_protected_nopar } { Nn } { Npn }
\cs_tmp:w { new_protected_nopar } { Nx } { Npx }
\cs_set:Npn \cs_tmp:w #1#2#3
  {
    \cs_set_protected:cpx {cs_#1:#2}##1##2{
      \exp_not:N\cs_generate_from_arg_count:cNnn {##1}
      \exp_after:wN \exp_not:N \cs:w cs_#1:#3 \cs_end:
        { \exp_not:N \cs_get_arg_count_from_signature:c {##1} } {##2}
    }
  }
\cs_tmp:w { set }                  { cn } { Npn }
\cs_tmp:w { set }                  { cx } { Npx }
\cs_tmp:w { set_nopar }            { cn } { Npn }
\cs_tmp:w { set_nopar }            { cx } { Npx }
\cs_tmp:w { set_protected }        { cn } { Npn }
\cs_tmp:w { set_protected }        { cx } { Npx }
\cs_tmp:w { set_protected_nopar }  { cn } { Npn }
\cs_tmp:w { set_protected_nopar }  { cx } { Npx }
\cs_tmp:w { gset }                 { cn } { Npn }
\cs_tmp:w { gset }                 { cx } { Npx }
\cs_tmp:w { gset_nopar }           { cn } { Npn }
\cs_tmp:w { gset_nopar }           { cx } { Npx }
\cs_tmp:w { gset_protected }       { cn } { Npn }
\cs_tmp:w { gset_protected }       { cx } { Npx }
\cs_tmp:w { gset_protected_nopar } { cn } { Npn }
\cs_tmp:w { gset_protected_nopar } { cx } { Npx }
\cs_tmp:w { new }                 { cn } { Npn }
\cs_tmp:w { new }                 { cx } { Npx }
\cs_tmp:w { new_nopar }           { cn } { Npn }
\cs_tmp:w { new_nopar }           { cx } { Npx }
\cs_tmp:w { new_protected }       { cn } { Npn }
\cs_tmp:w { new_protected }       { cx } { Npx }
\cs_tmp:w { new_protected_nopar } { cn } { Npn }
\cs_tmp:w { new_protected_nopar } { cx } { Npx }
\prg_new_conditional:Npnn \cs_if_eq:NN #1#2 { p , T , F , TF }
  {
    \if_meaning:w #1#2
      \prg_return_true: \else: \prg_return_false: \fi:
  }
\cs_new_nopar:Npn \cs_if_eq_p:cN { \exp_args:Nc  \cs_if_eq_p:NN }
\cs_new_nopar:Npn \cs_if_eq:cNTF { \exp_args:Nc  \cs_if_eq:NNTF }
\cs_new_nopar:Npn \cs_if_eq:cNT  { \exp_args:Nc  \cs_if_eq:NNT }
\cs_new_nopar:Npn \cs_if_eq:cNF  { \exp_args:Nc  \cs_if_eq:NNF }
\cs_new_nopar:Npn \cs_if_eq_p:Nc { \exp_args:NNc \cs_if_eq_p:NN }
\cs_new_nopar:Npn \cs_if_eq:NcTF { \exp_args:NNc \cs_if_eq:NNTF }
\cs_new_nopar:Npn \cs_if_eq:NcT  { \exp_args:NNc \cs_if_eq:NNT }
\cs_new_nopar:Npn \cs_if_eq:NcF  { \exp_args:NNc \cs_if_eq:NNF }
\cs_new_nopar:Npn \cs_if_eq_p:cc { \exp_args:Ncc \cs_if_eq_p:NN }
\cs_new_nopar:Npn \cs_if_eq:ccTF { \exp_args:Ncc \cs_if_eq:NNTF }
\cs_new_nopar:Npn \cs_if_eq:ccT  { \exp_args:Ncc \cs_if_eq:NNT }
\cs_new_nopar:Npn \cs_if_eq:ccF  { \exp_args:Ncc \cs_if_eq:NNF }
\cs_new_nopar:Npn \kernel_register_show:N #1
  {
    \cs_if_exist:NTF #1
     { \tex_showthe:D #1 }
     {
       \msg_kernel_error:nnx { kernel } { variable-not-defined }
         { \token_to_str:N #1 }
     }
  }
\cs_new_nopar:Npn \kernel_register_show:c { \exp_args:Nc \int_show:N }
\cs_new_eq:NN \luatex_if_engine:T  \use_none:n
\cs_new_eq:NN \luatex_if_engine:F  \use:n
\cs_new_eq:NN \luatex_if_engine:TF \use_ii:nn
\cs_new_eq:NN \pdftex_if_engine:T  \use:n
\cs_new_eq:NN \pdftex_if_engine:F  \use_none:n
\cs_new_eq:NN \pdftex_if_engine:TF \use_i:nn
\cs_new_eq:NN \xetex_if_engine:T   \use_none:n
\cs_new_eq:NN \xetex_if_engine:F   \use:n
\cs_new_eq:NN \xetex_if_engine:TF  \use_ii:nn
\cs_new_eq:NN \luatex_if_engine_p: \c_false_bool
\cs_new_eq:NN \pdftex_if_engine_p: \c_true_bool
\cs_new_eq:NN \xetex_if_engine_p:  \c_false_bool
\cs_if_exist:NT \xetex_XeTeXversion:D
  {
    \cs_set_eq:NN \pdftex_if_engine:T  \use_none:n
    \cs_set_eq:NN \pdftex_if_engine:F  \use:n
    \cs_set_eq:NN \pdftex_if_engine:TF \use_ii:nn
    \cs_set_eq:NN \xetex_if_engine:T   \use:n
    \cs_set_eq:NN \xetex_if_engine:F   \use_none:n
    \cs_set_eq:NN \xetex_if_engine:TF  \use_i:nn
    \cs_set_eq:NN \pdftex_if_engine_p: \c_false_bool
    \cs_set_eq:NN \xetex_if_engine_p:  \c_true_bool
  }
\cs_if_exist:NT \luatex_directlua:D
  {
    \cs_set_eq:NN \luatex_if_engine:T  \use:n
    \cs_set_eq:NN \luatex_if_engine:F  \use_none:n
    \cs_set_eq:NN \luatex_if_engine:TF \use_i:nn
    \cs_set_eq:NN \pdftex_if_engine:T  \use_none:n
    \cs_set_eq:NN \pdftex_if_engine:F  \use:n
    \cs_set_eq:NN \pdftex_if_engine:TF \use_ii:nn
    \cs_set_eq:NN \luatex_if_engine_p: \c_true_bool
    \cs_set_eq:NN \pdftex_if_engine_p: \c_false_bool
  }
\cs_new_nopar:Npn \prg_do_nothing: { }
\prg_new_conditional:Npnn \str_if_eq:nn #1#2 { p , T , F , TF }
  {
    \if_int_compare:w \pdftex_strcmp:D { \exp_not:n {#1} } { \exp_not:n {#2} }
      = \c_zero
     \prg_return_true: \else: \prg_return_false: \fi:
  }
\prg_new_conditional:Npnn \str_if_eq:xx #1#2 { p , T , F , TF }
  {
    \if_int_compare:w \pdftex_strcmp:D {#1} {#2} = \c_zero
      \prg_return_true: \else: \prg_return_false: \fi:
  }
\cs_new_eq:NN \c_luatex_is_engine_bool \luatex_if_engine_p:
\cs_new_eq:NN \c_pdftex_is_engine_bool \pdftex_if_engine_p:
\cs_new_eq:NN \c_xetex_is_engine_bool  \xetex_if_engine_p:
\cs_set:Npn \use_i_after_fi:nw #1 \fi: { \fi: #1 }
\cs_set:Npn \use_i_after_else:nw #1 \else: #2 \fi: { \fi: #1 }
\cs_set:Npn \use_i_after_or:nw #1 \or: #2 \fi: { \fi: #1 }
\cs_set:Npn \use_i_after_orelse:nw #1#2#3 \fi: { \fi: #1 }
\tex_let:D \cs_set_eq:NwN \tex_let:D
%% 
%%
%% End of file `l3basics.sty'.
