Latex3: [xtemplate] Use of instance-type keys not clearly documented

Created on 6 Jan 2020  ·  8Comments  ·  Source: latex3/latex3

Template parameters can include instances of other templates, however, the documentation does not say what type of variable the instances should be assigned to, nor does it say how to use an instance-type parameter in template code.

That is, given

\DeclareTemplateInterface { myobject } { mytemplate } { 0 }
  { foo : instance { otherobject } }

it is unclear how to proceed at the next step:

\DeclareTemplateCode { myobject } { mytemplate } { 0 }
  { foo = ??? }
  { how to use foo? }
documentation xtemplate

Most helpful comment

In that case, I’ll continue developing the class, using xtemplate. When a better solution is ready, then I’ll replace the old code.

All 8 comments

Reading through the code of xgalley and its example file, I’ve found that the name of the instance is what should be passed to the parameter key, that the appropriate variable is a function name with the correct signature, and that the assigned instance is then used like any other function.

That is, the next step would be

\DeclareTemplateCode { myobject } { mytemplate } { 0 }
  { foo = \__my_foo: }
  { \__my_foo: }

and

\DeclareInstance { myobject } { myinstance } { mytemplate }
  { foo = myotherinstance }

It's pretty clear that xtemplate is a set of good ideas but won't go forward: I'm not sure what's best here.

but won't go forward

Meaning?

but won't go forward

Meaning?

meaning that most of us (all? I?) think that xtemplate was a good prototype with good ideas but not necessarily the best or the most appropriate ones in the end and that by the end of the days the final interface will look different even though it will probably incoprporate several of the ideas in xtemplate in one way or the other. And that's what Joseph referred to.

Ok, so just the interfaces will not 'go forward'. Much relief.

Considering this information and considering how heavily my experimental class relies on xtemplate, it sounds like it might be best to shelve the class, for the time being, and spend my time on other LaTeX-related development.

@tail-reversion xtemplate is not going to get removed or anything like that: there will at some stage be an improved approach. I wouldn't want to put you off: if no one tries stuff out, we don't know where to go next!

In that case, I’ll continue developing the class, using xtemplate. When a better solution is ready, then I’ll replace the old code.

Was this page helpful?
0 / 5 - 0 ratings