GithubHelp home page GithubHelp logo

inlinedef's People

Contributors

shicks avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

inlinedef's Issues

Cannot expand conditionals

@sasozivanovic

I'd like to conditionally define parts of a macro depending on whether the debug mode is on or not. So, assuming \newif\ifdebug, I'd like to write

\Inline\def\macro{%
   ...
   \ExpandIfT{debug}{debug code }%
   ...
}

With inlinedef, I'm almost there. I can define \ExpandIfT (and its cousins \ExpandIfF and \ExpandIfTF not shown here), and then expand them manually using \MultiExpand:

\def\ExpandIfT#1{%
   \csname
     \csname if#1\endcsname
       @firstofone%
     \else
       @gobble%
     \fi
   \endcsname
}

\newif\ifdebug
\debugtrue

\Inline\def\macro{%
   ...
   \MultiExpand{3}{\ExpandIfT{debug}{debug code }}%
   ...
}

However, being able to use \ExpandIf(T)(F) directly has quite an appeal to me. I investigated inlinedef code a bit and it doesn't seem very hard to extend it to accept user defined keywords inside an \Inline definition. I have drafted a patch makes this possible.

The idea is to define user commands in terms of \Expand, or, more probably, \MultiExpand. When a user keyword is encountered in the definition, it is expanded by the \UnsafeExpand mechanism.

I hope you will consider accepting the extension into the package.

Cannot inlinedef an expanded csname

From @sasozivanovic, in reference to #1:

I also need this mechanism with \csdef.

\expandafter\Inline\expandafter\def\csname macro\endcsname ...{...}

does not work, because \csname macro\endcsname lets \macro to \relax and then \Inline chokes on \meaning\macro.

The workaround, which I believe would be beneficial anyway, could be to have a command (named something like) \InlineNoDef, which would take a single argument, do its expansion magic, and execute it. This would readily support \csdef, though without redefinitions, but I must selfishly admit I'm not interested in those at this time.

Again, I attach the relevant definition which simply skips over the gruesome job of parsing the macro prefixes and parameters ;-)

I guess my example of usage also answers a question from the documentation: no, \Inline should not be \outer.

\def\forest@newarray@#1{%
  ...
  \InlineNoDef{\csdef{#1bottompop}##1{% ##1 = receiving cs
    \Expand{\csname#1ifempty\endcsname}{%
      \forest@array@empty@error{#1}%
    }{%
      \letcs##1{#1\the\Expand{\csname#1M\endcsname}}%
      \ExpandIfT{forest@temp}\global
      \advance\Expand{\csname#1M\endcsname 1}%
    }%
  }}%
  ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.