In my library it would be
strm
tag: 'h1';
do: aBlockWhichWritesTheTitle;
end.
because one so very often needs to add attributes and/or a namespace.
#tag:do: is related to the C++ "Resource Allocation is Initialisation"
pattern, where the point is to automatically clean up. In RAII, the clean
up is to release a lock or free a resource. In this case, it is to write
an end-tag. In a similar way, it is related to the Common Lisp with...
pattern, where (with-open-file (variable filespec option...) body...)
ensures that the file is closed, to unwind-protect, and of course to the
#critical: method on Semaphores, Mutexes, &c.
I don't know if there is an official name other than RAII;
I've always thought of it as "automatic cleanup". The difference
between this and #ensure: or try-finally or unwind-protect is that
in those you have to say what the clean-up action is while in this
it is implicit.
Hi.
I was looking at the zink stream, and noticed this pattern with
strm tag: 'h1' do: aBlockWhichWriteTheTitle
It is also used in baselines, and I have used it myself a few times.
Is anyone aware of this having a name?
Best,
Kasper