On 17 Jun 2024, at 18:35, C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com> wrote:
Suppose that a program written in a set of XQuery modules made use of
some abstract data type. Suppose further that the programmer wished to
be able to experiment with different implementations of that abstract
data type. (Maybe it's an XML element node, or a sequence of elements,
maybe it's a map indexed by strings, maybe it's a two-level map, maybe
...)
Since XQuery doesn't have the ability to declare new type names (or am I
missing something very important?), I don't see a straightforward way to
do this inside of XQuery.
As an alternative, I can imagine handling this with a level of
indirection (is there any problem in programming that cannot be solved
or papered over by adding a level of indirection?).
For example, I could use a macro pre-processor to define a short name
for the abstract data type and as its expansion supply the appropriate
type description.
#define FOO element(foo)
or
#define FOO map(*)
Then I can declare a function as
define function make-foo($s as xs:string) as FOO {
...
};
and run my source code through the macro pre-processor before submitting
it to the XQuery engine.
I suspect there are other ways. (In my case, I work with a literate
programming system that allows me to maintain multiple versions of code
in parallel. But I'm finding that method a little klunky, and it does
nothing to enforce appropriate information-hiding boundaries. Although
neither does a macro-preprocessor, come to that.)
Do any readers of this list have experience with ways of layering some
feature over XQuery by use of a preprocessor of some kind, or by other
means? Failing that, does anyone have ideas of suggestions that might
be worth trying?
Thanks!
--
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com
_______________________________________________________________________
XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.
[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php