Hi Leo,
Thank you for your reply. I’m aware of these kind of solutions, I use them frequently allthough I have to admit that these slipped my mind here. Great solutions by the way.
But getting the code working is not my problem. What I’m looking for is a generic solution for some sort of inheritance mechanism( see attachment for an example). The code-snippet is just meant to supply the BaseX-team with an basic executable example of the bare issue. I’m not even sure if it is a bug because I don’t know if it is behavior by design. But now the BaseX-team is aware of the situation.
Probably I should have said that the functions can be activated cyclically in stead of just recursively. Where cyclical can be interpret as indirect recursive. And in that case the solution doesn’t hold.
Best, Rob
Sent from Mail for Windows 10
From: Leo Studer Sent: Monday, October 19, 2020 7:19 PM To: Rob Stapper Subject: Re: [basex-talk] recursively used variables
… and you do not even need the variable
declare %private function local:test( $i, $test) { if ( $i > 0) then ($i, $test( $i - 1, $test)) else() } ;
local:test( 10, local:test#2)
Cheers Leo
On 8 Oct 2020, at 14:17, Rob Stapper r.stapper@lijbrandt.nl wrote:
Hi, The code[1] below and send as attachment generates a error message: “Static variable depends on itself: $Q{http://www.w3.org/2005/xquery-local-functions%7Dtest%E2%80%9D. I use these variables to refer to my private functions in my modules so I can easyly refer to them in a inheritance situation. It’s not a big problem for me but I was wondering if the error-triggering is justified or that it should work. [1]=========================================== declare variable $local:test := local:test#1 ; declare %private function local:test( $i) { if ( $i > 0) then $local:test( $i - 1) } ; $local:test( 10) =========================================== Kind regards, Rob Stapper Sent from Mail for Windows 10
Virus-free. www.avast.com <test.xq>
I think you have to pass the variable to your function
declare variable $local:test := local:test#2 ; declare %private function local:test( $i, $test) { if ( $i > 0) then ($i, $test( $i - 1, $test)) else() } ;
local:test( 10, $local:test)
On 20 Oct 2020, at 10:31, Rob Stapper r.stapper@lijbrandt.nl wrote:
Hi Leo,
Thank you for your reply. I’m aware of these kind of solutions, I use them frequently allthough I have to admit that these slipped my mind here. Great solutions by the way.
But getting the code working is not my problem. What I’m looking for is a generic solution for some sort of inheritance mechanism( see attachment for an example). The code-snippet is just meant to supply the BaseX-team with an basic executable example of the bare issue. I’m not even sure if it is a bug because I don’t know if it is behavior by design. But now the BaseX-team is aware of the situation.
Probably I should have said that the functions can be activated cyclically in stead of just recursively. Where cyclical can be interpret as indirect recursive. And in that case the solution doesn’t hold.
Best, Rob
Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Leo Studer mailto:leo.studer@varioweb.ch Sent: Monday, October 19, 2020 7:19 PM To: Rob Stapper mailto:r.stapper@lijbrandt.nl Subject: Re: [basex-talk] recursively used variables
… and you do not even need the variable
declare %private function local:test( $i, $test) { if ( $i > 0) then ($i, $test( $i - 1, $test)) else() } ;
local:test( 10, local:test#2)
Cheers Leo
On 8 Oct 2020, at 14:17, Rob Stapper <r.stapper@lijbrandt.nl mailto:r.stapper@lijbrandt.nl> wrote:
Hi,
The code[1] below and send as attachment generates a error message: “Static variable depends on itself: $Q{http://www.w3.org/2005/xquery-local-functions http://www.w3.org/2005/xquery-local-functions}test”. I use these variables to refer to my private functions in my modules so I can easyly refer to them in a inheritance situation. It’s not a big problem for me but I was wondering if the error-triggering is justified or that it should work.
[1]=========================================== declare variable $local:test := local:test#1 ; declare %private function local:test( $i) { if ( $i > 0) then $local:test( $i - 1) } ;
$local:test( 10)
Kind regards,
Rob Stapper
Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link <test.xq>
<inheritance.zip>
basex-talk@mailman.uni-konstanz.de