[seqfan] Re: metadata for Mathematica code

Eric Rowland rowland at lacim.ca
Tue Nov 3 14:22:13 CET 2015


Lots of good comments.

Yes, it is intended that the metadata be sufficient to programmatically use
the associated code.  For example, a TermFunction should be an expression
that can immediately be passed an argument.  A TermFunctionDefinition is a
piece of code that defines a function, so there is some overhead required
to extract the function name, but this isn't terribly difficult:

In[1]:= Replace[Hold[A000108[n_] := (2 n)!/n!/(n + 1)!],
Hold[_[functionname_[__], _]] :> functionname]
Out[1]= A000108

The labels are somewhat Mathematica-specific, since the notion of a pure
function doesn't exist in all languages.  So in other languages there may
only be TermFunctionDefinition labels and no TermFunction labels.  Or maybe
we would use different labels entirely.

Yes, putting metadata in comments takes up space on the page.  Charles has
a great idea to display the metadata in the margin along with the
MATHEMATICA heading.  An alternative might be to suppress the metadata from
the human-readable version.  But either way, changing formatting on the
site takes work, and if we wait for that then I'm afraid nothing will ever
happen.  On the other hand, if we start adding metadata, then we will see
whether we need different formatting, and if we decide we do then it will
encourage us to add it.

Since we designed the labels to be Mathematica-specific, they follow
standard Mathematica naming conventions (no abbreviations, camel case).
Everything you need to know is there.

There are a couple problems with standardizing function names.  One is that
it would require changing a lot (most?) of the existing code, rather than
simply adding metadata to it.  (And if we are prepared to change most of
the existing code, then ideally we would convert all the function
definitions to pure functions and not have function names at all, since
pure functions are programmatically much more flexible.)  Another is that
it's more complicated to programmatically access the function you want, if
the only information you have is the function name (see above).  If the
program type is identified by a dedicated label, then you just check for
the right label and you don't need to do any string processing.

Eric



More information about the SeqFan mailing list