tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

Evaluate functions in keyval inputs with functional library

Open lvjr opened this issue 3 years ago • 1 comments

From https://tex.stackexchange.com/questions/648786/how-to-define-new-key-properties-in-l3keys

Recently I found tcolorbox has an interesting IfEmptyTF key, with which you can write

IfEmptyTF = {⟨token list⟩}{key=val1}{key=val2}

And I decided tabularray should have a similar feature, and can make the interface more natural and more powerful to users:

key = \tlIfEmptyTF{⟨token list⟩}{\prgReturn{val1}}{\prgReturn{val2}}

where \tlIfEmptyTF function is from functional package. That is to say, users can use all functions in functional package in the values and tabularray should replace them with their return values. And this feature should only be enabled if functional library is load by users.

lvjr avatar Jun 25 '22 03:06 lvjr

Now I think it is an elegant solution to apply \evalWhole to the second argument of every \keys_set:nn command beforehand. With this solution you can also use functions from functional packages or (defined a new one with \prgNewFunction) in the key:

\someFunc{aaa} = \otherFunc{bbb}

where \someFunc returns a key name, and \otherFunc returns its value.

Also issue #207 can be solved by making a function return both key name and its value.

But we need to keep evaluate and process options safe in making this change.

lvjr avatar Jun 25 '22 03:06 lvjr