Still hard at work on my Periodic Table demo, I’m working on an idea that would be much easier if I could supply one macro as a parameter to another one. (For programmers, this would be something like higher-order functions, being able to pass functions as arguments to other functions.)
There may well be a different technique easily available to do the same thing. I’m not picky, just looking for appropriate mechanisms.
The main tiddler shows a periodic table; I would like to abstract it into a macro, and alter that so that I can do different things. You’ll notice that there is a fair bit of white space in the table (two tile wide by two tile high blocks in the bottom left and bottom right, a 10 x 3 block in the top center, a 5 x 1 block to the left of He(lium) and a 1 x 1 block to the right of H(ydrogen). In various situations, I would like to fill this with different content. I might want a flash-card in the largest section, asking you to find a random element in an (unlabeled) version of the table. I might want to add an Element-type list in the bottom-right, in which hovering/long pressing the Noble Gas link deemphasizes all the elements except those seven Nobel Gas elements. I can imagine many things. They all have in common the generation of the table with a call to the current tile macro or a different one for their content.
So my thought was that I might call this like
for the existing table – labeling those empty blocks as “northwest”, “north”, “northeast”, “soutthwest”, “southeast” – I might imagine a flashcard game like
<<make-table tile:"blank-colored-tile", north:"flashcard-game">>
and perhaps something like:
<<make-table tile:"normal-tile" southeast:"element-type-hover">>
and so so, where,
and "element-type-hover" are all names of macros I would want to insert at the appropriate locations.
Is this possible? Is there a way to include macros whose names are passed as arguments? Or is there another way to make direct reference to other macros in the maco-call syntax? Any other suggestions for accomplishing this?