Telling apart source of first argument
#65
Open
opened 4 years ago by basus
·
2 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
If I'm understanding things correctly, both
◊tagfn["arg"]
and◊tagfn{arg}
will pass "arg" as the first argument to thetagfn
function. Is there some way to tell these two cases apart? I'm thinking about tag functions where the argument between [] could be optional. For example, a◊code
tag where◊code['lang]{...}
treats the stuff inside {} as'lang
but treats it as plaintext if it's just◊code{...}
.There’s not a way to tell them apart strictly by whether they occur in
[ ]
vs{ }
. I’m prettry sure that information gets discarded by the reader.But you know that anything occurring inside the
{ }
will (almost always) be either a string or a tagged X-expression. You could take advantage of that by testing if the first argument is a plain symbol:Or, if you don’t mind being a bit more verbose in your markup, you can use keyword arguments to implement optional stuff. E.g.,
◊code[#:lang 'python]{...}
. And usedefine-tag-function
to handle those automaticallyYes, that’s correct.