recursively used variables
Thursday, 8 October 2020 · 10 messages · last reply 12 Aug 2024
RS
Rob Stapper8 Oct 2020 14:17 #
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}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 for Windows 10
--
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
CG
Christian Grün18 Oct 2020 16:08 #
Hi Rob, sorry, I’ve just discovered your mail in the basex-talk archive. I believe that the given query should not raise an error as the variable does only reference your function. Let’s see what we can do. – Best, Christian
Quoted text · Rob Stapper · 53 lines
On Thu, Oct 8, 2020 at 2:17 PM Rob Stapper <r.stapper at 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}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> > <#m_1823454217451684430_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
RS
Rob Stapper19 Oct 2020 10:34 #
Quoted text · Christian Grün · 82 lines
> ---------- Oorspronkelijk Bericht ---------- > Van: Rob Stapper <r.stapper at lijbrandt.nl> > Aan: Christian Grün <christian.gruen at gmail.com> > Datum: 19-10-2020 10:01 > Onderwerp: RE: [basex-talk] recursively used variables > > > > Good Morning Christian, > > > Yes, I was wondering if you had received my mail. This time lapse is so not like you. > > Thanx for having a look. It would be great if this worked, implementing inheritance-like structures would be so much more transparent. > > Have a look at the attachment if you like. Recursion here does not work and a work-around would brake down the systematic approach. > > > Best, > > Rob > > > Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10 > > > From: Christian Grün mailto:christian.gruen at gmail.com > Sent: Sunday, October 18, 2020 4:08 PM > To: Rob Stapper mailto:r.stapper at lijbrandt.nl > Cc: basex-talk at mailman.uni-konstanz.de mailto:basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] recursively used variables > > > Hi Rob, sorry, I’ve just discovered your mail in the basex-talk archive. I believe that the given query should not raise an error as the variable does only reference your function. Let’s see what we can do. – Best, Christian > > > > > > > On Thu, Oct 8, 2020 at 2:17 PM Rob Stapper <r.stapper at lijbrandt.nl mailto:r.stapper at 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}test http://www.w3.org/2005/xquery-local-functions%7Dtest ”. > > > > 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 > > > > > > >
mvgr.
Rob Stapper
LS
Hi all
Here how I call a function recursively
declare %private function local:test( $i, $recursiveFunction) {
if ( $i > 0)
then ($i, $recursiveFunction( $i - 1, $recursiveFunction))
else()
} ;
local:test( 10, local:test#2)Always
Leo
Quoted text · Rob Stapper · 24 lines
> On 8 Oct 2020, at 14:17, Rob Stapper <r.stapper at 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> <x-msg://1/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2><test.xq>
LS
… or a xPath function in a variable
declare %private variable $recursiveFunction:= function( $i, $recursiveFunction) {
if ( $i > 0) then ($i, $recursiveFunction( $i - 1, $recursiveFunction)) else()
} ;
$recursiveFunction( 10, $recursiveFunction)Quoted text · Rob Stapper · 24 lines
> On 8 Oct 2020, at 14:17, Rob Stapper <r.stapper at lijbrandt.nl <mailto:r.stapper at 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> <x-msg://1/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2><test.xq>
RS
Rob Stapper20 Oct 2020 10:31 #
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
Quoted text · Leo Studer · 27 lines
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 at 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}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 for Windows 10 Virus-free. www.avast.com <test.xq> -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
LS
Leo Studer20 Oct 2020 10:43 #
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)Quoted text · Rob Stapper · 62 lines
> On 20 Oct 2020, at 10:31, Rob Stapper <r.stapper at 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 at varioweb.ch> > Sent: Monday, October 19, 2020 7:19 PM > To: Rob Stapper <mailto:r.stapper at 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 at lijbrandt.nl <mailto:r.stapper at 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>
CG
I noticed there is an open issue that relates to your observation:
https://github.com/BaseXdb/basex/issues/1095
Lots to do right now, let’s see when we can tackle it.
Quoted text · Rob Stapper · 53 lines
On Thu, Oct 8, 2020 at 2:17 PM Rob Stapper <r.stapper at 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}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> > <#m_9175477539326496683_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
CG
Hi Rob, hi all,
We’ve recently added some ancient bugs regarding self dependencies in variable declarations [1,2]. BaseX 11.2 will be out soon.
Best,
Christian
[1] https://github.com/BaseXdb/basex/issues/1095
[2] https://files.basex.org/releases/latest/
Quoted text · Rob Stapper · 53 lines
On Thu, Oct 8, 2020 at 2:17 PM Rob Stapper <r.stapper at 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}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> > <#m_-3413609695658352816_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
R
r.stapper12 Aug 2024 18:00 #
Yes 😄😄😄.
Might make me try again to port my application to version 11.
I'm still using 10.7
Cheers, Rob.
Verzonden vanaf mijn Galaxy
-------- Oorspronkelijk bericht --------
Quoted text · Christian Grün · 43 lines
Van: Christian Grün <christian.gruen at gmail.com> Datum: 12-08-2024 16:29 (GMT+01:00) Aan: Rob Stapper <r.stapper at lijbrandt.nl> Cc: basex-talk at mailman.uni-konstanz.de Onderwerp: Re: [basex-talk] recursively used variables Hi Rob, hi all, We’ve recently added some ancient bugs regarding self dependencies in variable declarations [1,2]. BaseX 11.2 will be out soon. Best, Christian [1] https://github.com/BaseXdb/basex/issues/1095 [2] https://files.basex.org/releases/latest/ On Thu, Oct 8, 2020 at 2:17 PM Rob Stapper <r.stapper at 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}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 for Windows 10 > > > > > > > > Virus-free. www.avast.com > > > >
Written for BaseX 9.4, 11.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery