# \edef in LaTeX 3?

Is there a version of \DeclareDocumentCommand (in LaTeX 3) which performs like \edef? I.e. where the argument is evaluated at the time of definition as opposed to the time the macro is called?

For example

\ExplSyntaxOn
\fp_zero_new:N {\fpX}
\fp_set:Nn {\fpX} {6}
\DeclareDocumentCommand { \dX } {} {\fp_to_decimal:N{\fpX}}

\fp_set:Nn{\fpX} {12}

\dX
\ExplSyntaxOff

prints 12

\ExplSyntaxOn
\fp_zero_new:N {\fpX}
\fp_set:Nn {\fpX} {6}
\edef\dX{\fp_to_decimal:N{\fpX}}

\fp_set:Nn{\fpX} {12}

\dX
\ExplSyntaxOff

prints 6

and I would like \dX to expand to 6

-
Can you show a use case? –  egreg Jul 6 at 23:42

The family of commands in xparse for creating new document commands are not really intended for this sort of thing. This can be seen in your example where \DeclareDocumentCommand is intermixed with expl3 code.

The short answer is that the expl3 version of \edef is either \cs_set:Npx or \tl_set:Nx depending if you're creating a macro that takes arguments or simply a token list.