BaseX-Talk Digest, Vol 130, Issue 13
Wednesday, 21 October 2020 · 1 message
RS
Rob Stapper21 Oct 2020 13:08 #
I see that my attachment is missing, so I'll try again. And for extra I'll drop the code her in the mail too. Here we go:
------------------------------------------------------------------------------ [1] "test.xqm"
import module namespace BASE-TYPE = "BASE-TYPE" at "./BASE-TYPE.xqm" ;
let $object := 12
return $object => $BASE-TYPE:method_1( )
--------------------------------------------------------------------------
[2] "BASE-TYPE.xqm"
module namespace BASE-TYPE = "BASE-TYPE" ;
import module namespace SUPER-TYPE = "SUPER-TYPE" at "./SUPER-TYPE.xqm" ;
declare variable $BASE-TYPE:method_1 := BASE-TYPE:method_1#1 ;
declare %private function BASE-TYPE:method_1( $i) { if ( $i > 0) then ( $i,( $i - 1) => $SUPER-TYPE:method_1( )) else () } ;
-----------------------------------------------------------------------
[3] "SUPER-TYPE.xqm"
module namespace BASE-TYPE = "SUPER-TYPE" ;
import module namespace SUPER-TYPE = "SUPER-SUPER-TYPE" at "./SUPER-SUPER-TYPE.xqm" ;
declare variable $BASE-TYPE:method_1 := BASE-TYPE:method_1#1 ;
declare %private function BASE-TYPE:method_1( $i) { if ( $i > 0) then ( $i,( $i - 1) => $SUPER-TYPE:method_1( )) else () } ;
-------------------------------------------------------------------------------------------------------------------------
[4] "SUPER-SUPER-TYPE.xqm"
module namespace BASE-TYPE = "SUPER-SUPER-TYPE" ;
import module namespace SUPER-TYPE = "BASE-TYPE" at "./BASE-TYPE.xqm" ;
declare variable $BASE-TYPE:method_1 := BASE-TYPE:method_1#1 ;
declare %private function BASE-TYPE:method_1( $i) { if ( $i > 0) then ( $i,( $i - 1) => $SUPER-TYPE:method_1( )) else () } ;
--------------------------------------------------------------------------------------------------------------------------Yes, the content of the module-files is identical except for the imported module-file.
Best,
Rob
Quoted text · 65 lines
> Op 21-10-2020 12:00 schreef basex-talk-request at mailman.uni-konstanz.de: > > > Send BaseX-Talk mailing list submissions to > basex-talk at mailman.uni-konstanz.de > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > or, via email, send a message with subject or body 'help' to > basex-talk-request at mailman.uni-konstanz.de > > You can reach the person managing the list at > basex-talk-owner at mailman.uni-konstanz.de > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of BaseX-Talk digest..." > > > Today's Topics: > > 1. recursively used variables (Rob Stapper) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 20 Oct 2020 17:19:36 +0200 > From: Rob Stapper <r.stapper at lijbrandt.nl> > To: "basex-talk at mailman.uni-konstanz.de" > <basex-talk at mailman.uni-konstanz.de> > Subject: [basex-talk] recursively used variables > Message-ID: <aa8b70e7-12e7-11eb-8513-005056998788 at smtp.kpnmail.nl> > Content-Type: text/plain; charset="utf-8" > > Hi, > > For those who follow this discussion and find it an interesting case, hereby an example of the problem I?m facing. > > The example throws an error: Static variable depends on itself: ?? > > The example concerns a 3-step cyclic construct: > ?BASE-TYPE.xqm? -> ?SUPER-TYPE.xqm? -> ?SUPER-SUPER-TYPE.xqm? -> ?BASE-TYPE.xqm?, > starting of from ?test.xq?. > > I need the solution to comply with four rules: > - The module-functions must be %private and may only be addressed from outside the module through a public module-$variable. This way inheritance between modules can simply be implemented by the use of variables. > - The internal structure of a module-function must be completely hidden for use outside the module. So if the module-function calls another function it is not allowed to pass this called upon function or its name in the module-function?s parameterlist. That is why I can?t use Leo solution here. > - The 3-step cycle structure can not be changed. > - I need a generic solution. > > The solution is of course that it just works; Christian is having a look at it, but I thought it an interesting enough case to share and maybe somebody comes up with an solution that does complies to these rules as a temporary ? work around. My solution for the time being is violating my first rule. > > Have fun, > Rob Stapper > > PS for using the example, just extract it and copy the extracted directory in BaseX?s src-directory. Start "test.xq? from within BaseX and it should work > > Sent from Mail for Windows 10 > > > > -- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus >
Written for BaseX 9.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery