[xquery-talk] Extend and override

Tim Finney tjf at tfinney.net
Wed Aug 10 09:02:04 PDT 2011

Hi Everyone,

I'm interested to know how to do extension and override.

Say I have a set of generic library modules that do generally useful
things that I might use over and over again. Let's call them model.xqy,
view.xqy, and controller.xqy just for fun. Now, let's say that I also
have particular versions of these modules, say, model-p.xqy, view-p.xqy,
and controller-p.xqy which may or may not extend function definitions in
the corresponding general modules. The particular modules might even
define entirely new functions.

What I'd like is to be able to use the function interface (signature)
defined in a general module to constrain the corresponding function in
the particular module. That is, I want to guarantee that a function in a
particular module has the same signature as the corresponding one in the
general module, preferably in some automatic way besides generating an
error at run time. More importantly, I want to be able to extend or
override what a general function does by changing the body of the
corresponding particular function. That is, if there is a definition of
a function in a particular module then the system knows that it should
use this definition of the function rather than the corresponding one in
the general module.

I'd also like the same things to happen with variables: if one is
defined in a particular module then it must conform to the type of the
corresponding variable in the general module and the system must know
that, if a variable is defined in a particular module, the value
overrides what is in the general module for that variable.

Can it be done in an elegant and bomb proof way? I'd like to know
whether any of you know about good general approaches in this area.


Tim Finney

More information about the talk mailing list