[xquery-talk] Extend and override
dlee at calldei.com
Wed Aug 10 09:06:04 PDT 2011
I don't believe this can be done using XQuery 1.0.
Maybe function items might accommodate some of this in XQuery 3 ... but not
If I'm wrong I'd love to hear about it!
David A. Lee
dlee at calldei.com
From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf
Of Tim Finney
Sent: Wednesday, August 10, 2011 12:02 PM
To: talk at x-query.com
Subject: [xquery-talk] Extend and override
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.
talk at x-query.com
More information about the talk