I really do not understand the purpose of .initial:n. It is only useful for the first call to a command that does not have user-values, after that the current values are used.
Would like to have the starred version always using the initial values when not having the argument, default when just using the key names, and using the supplied values when set as arguments.
For the unstarred version, I would like to use the initial or current values when not having the argument, default when just using the key names, and using the supplied values when set as arguments.
\documentclass{article}
\ExplSyntaxOn
\dim_new:N \l_mymodule_width_dim
\dim_new:N \l_mymodule_height_dim
\dim_new:N \l_mymodule_margin_dim
\keys_define:nn { mymodule }
{
width .dim_set:N = \l_mymodule_width_dim,
width .initial:n = 34pt,
width .default:n = 36pt,
height .dim_set:N = \l_mymodule_height_dim,
height .initial:n = 34pt,
height .default:n = 36pt,
margin .dim_set:N = \l_mymodule_margin_dim,
margin .initial:n = 34pt,
margin .default:n = 36pt,
}
\NewDocumentCommand {\setdimensionsC} { s o }
{
\IfBooleanTF {#1}
{
\IfValueTF {#2}
{
\keys_set:nn { mymodule }
{ width = 36pt, height = 36pt, margin = 36pt }
\keys_set:nn {mymodule} {#2}
}
{
\keys_set:nn { mymodule }
{ width = 36pt, height = 36pt, margin = 36pt }
}
}
{
\IfValueTF {#2}
{ \keys_set:nn {mymodule} {#2} }
{ \keys_set:nn {mymodule} {} }
}
% Use the dimensions in your document or perform other actions
\fbox { \begin{tabular}{ll}
Width: & \dim_use:N \l_mymodule_width_dim \\
Height: & \dim_use:N \l_mymodule_height_dim \\
Margin: & \dim_use:N \l_mymodule_margin_dim
\end{tabular} }
}
\ExplSyntaxOff
\begin{document}
With Initial Values:
\setdimensionsC
With Default values:
\setdimensionsC[width,height,margin]
With Current Values:
\setdimensionsC
\end{document}

_mymodule(that has no keys) in the second set command? – David Carlisle Mar 01 '24 at 23:18! LaTeX Error: The key '\mymodule/width' is unknown and is being ignored.– David Carlisle Mar 01 '24 at 23:19mymodulenot\mymodulein the first setting. – David Carlisle Mar 01 '24 at 23:22\keys_set:nn {mymodule} {}as you are explicitly calling it with an empty key list so this will never do anything? (as previously explained it does not reset the.initialvalues which is what I guess you are hoping). – David Carlisle Mar 02 '24 at 00:12.initial:n. I then wonder about the real usefulness of.initial:n. – Ragonese Mar 02 '24 at 01:34initial:nis there as a convenience for those who would like to put everything in\keys_define:nnrather than initialising with a use of\keys_set:nn. This has been explained several times already. – Joseph Wright Mar 02 '24 at 06:45initialsets the value at the point of definition why is that not clear, that you keep re-asking the same thing? – David Carlisle Mar 02 '24 at 10:07.initial:n". – Skillmon Mar 02 '24 at 20:44