\procedure vs \define

Until recently, I was not aware of \procedure. I don’t use them yet.

I can’t really see in the doc what it does better than \define. Except using the \parameters pragma. But the docs don’t really show why it would be such a great feature. Would the combination of the two works better (than \define) if I use functions (defined by \function) in my filter? And again, how’s that?

Also’ in the " Macro Definition Syntax" there is no mention of \procedure. What are we creating with \procedure?

You might want to read #4673, which contains a lot of information about this and links to more.

For that matter, I should re-read it, as I still haven’t internalized them. :grinning_face_with_smiling_eyes:

@jypre https://tiddlywiki.com/#Variable%20Usage

@CodaCoder In variable usage, I can read

<$set name="sp2" value="""
<$parameters a1><<a1>></$parameters>

I suppose it is meant to say that you can do

<$set name="sp2" value="""

otherwise I don’t see the use of \parameters(a1). This is indeed the case (just tested it). I think the doc has wanted to be a bit shorter that it should have been.

Thank you @Scott_Sauyet for the link.

Now I krow that \procedure is the new macro mechanism and I ought not to use \define anymore. A good point for this being there is no more (slow) text substitution.

So we definitely must update the doc about macro, mustn’t we?

I read in this help page that with \defined macro called along the usual way, that “all wikitext and variable substitution and textual substitution takes place”.

But this is not illustrated. I may be a bit dumb’ but what is the difference with “All wikitext and variable substitution takes place”? There in tiddler called “textual substitution” (or including that in its title) to enlight me. I //suspect// this is the bit about using $myFirstArg$ for instance. Is that so?

I don’t know. I had exactly the same question when I read it – I wondered why “textual substitution” was added. I figured I’d glossed over something and never did go back to see what I’d missed.

In “Variable usage” all the usage is within a simple wiki context. Ther is not a word about filter context.

My tests indicate this is a whole different story. A lot of things are different (read as producing blank only).

In fact one may argue its poorer as the variable substitutions are now ONLY as variables. However with the parameters widget and “functions” now available (that allows many forms of substitution), I think we have “won back” the functionality.

  • The advantage of parameters as “only” variables is we can now focus on parameters as having a consistent representation.
  • The way the new functions work you can replace 90% even 100% of the reasons for using the \define substitutions by moving them into filters (\functions) which has it’s own values. See also substitution operator.

(As I understand it) keep in mind this is part of gradual change and a move to procedures is part of a larger picture by the core team, the value will only be fully realised in time

Despite the above this is also true

  • Define and substitution features are only depricated and I cant see them ever going completely (speculation).
    • But is wise to migrate away from them.
  • You can nest \defines inside custom widgets and procedures, and use them in that scope.
  • You can call defines and procedures, with <$transclude $variable= and procedures with <$macrocall $name= when you do not need to use a feature of the new $transclude $variable.
  • using functions, and the new backtick attribute values allows you to avoid definition of a macro (\define) by providing an “evaluated value” as an attribute value right where it is needed.

7 posts were split to a new topic: TW5+TW6 informal discussion