expand-to-string (マクロ)
パッケージ: CURL.LANGUAGE.COMPILER

マクロの呼び出しを展開し、文字列を結果と共に生成します。

シグネチャ

{expand-to-string [ max-iterations = 1, ] {name ...} }
max-iterations: は展開の反復回数の最大値で、既定は 1 に設定されています。反復処理は、コードの一番外側のレベルにのみ適用されます。値は整数リテラル、max-int または infinity であることが必要です。

注意事項

これは、主にユーザー定義のマクロのテストに使用することが目的です。

{define-macro public {hello}
    {return {expand-template "hello world"}}
}

{expand-to-string {hello}}


{define-macro public {hello}
    {return {expand-template "hello world"}}
}
{define-macro public {indirect-hello}
    {return {expand-template {hello}}}
}
{define-macro public {block-hello}
    {return {expand-template {value {hello}}}}
}

|| This expands to: "hello world"
{expand-to-string {hello}}

|| This expands to {hello}
{expand-to-string {indirect-hello}}

|| This expands to "hello world"
{expand-to-string max-iterations = 2, {indirect-hello}} 

|| This expands to: {value {hello}}
{expand-to-string max-iterations = max-int, {block-hello}}