programming a statefull xquery-module

Friday, 1 May 2015 · 2 messages · last reply 3 May 2015
RS
Rob Stapper1 May 2015 16:49 #
Hi Christian, To support debugging my code I'm writing a module with debugging-functions in xquery. To reduce the impact of the debug-functions on my code I want this debug-module to be statefull. So every time a debug-function is called it remembers it's previous debug state. This way I don't have to carry this debug state all throughout my already complex code. I've tried several options but without success. My latest attempt uses file-read and -write( see attached file), but I don't understand how these functions behave. Can you give me a hint how to approach this? Thanx in advance, Rob Stapper PS. This debug-state could look something like:
<debugState functionName 'child-child-function-name' level='3'>

    <debugState functionName 'child-function-name' level='2'>

        <debugState functionName 'parent-function-name' level='1'/>

    </ debugState>

</ debugState>
--- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. http://www.avast.com
CG
Christian Grün3 May 2015 20:23 #
Hi Rob, One way to do this is to use Java data structures:
  declare namespace map = 'java.util.HashSet';
  let $map := map:new()
  return (
    map:add($map, 'abc'),
    map:size($map),
    map:add($map, 'def'),
    map:size($map)
  )
From a functional programming perspective, this is of course not the recommendable way to go, but otherwise you would need to pass on the current debugging state to all functions. Best, Christian
Quoted text · Rob Stapper · 58 lines
On Fri, May 1, 2015 at 4:49 PM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Hi Christian, > > > > To support debugging my code I’m writing a module with debugging-functions > in xquery. > > To reduce the impact of the debug-functions on my code I want this > debug-module to be statefull. > > So every time a debug-function is called it remembers it’s previous debug > state. > > This way I don’t have to carry this debug state all throughout my already > complex code. > > I’ve tried several options but without success. My latest attempt uses > file-read and –write( see attached file), but I don’t understand how these > functions behave. > > > > Can you give me a hint how to approach this? > > > > Thanx in advance, > > Rob Stapper > > > > PS. This debug-state could look something like: > > > > <debugState functionName ‘child-child-function-name’ level=’3’> > > <debugState functionName ‘child-function-name’ level=’2’> > > <debugState functionName ‘parent-function-name’ level=’1’/> > > </ debugState> > > </ debugState> > > > > > ------------------------------ > [image: Avast logo] <http://www.avast.com/> > > Dit e-mailbericht is gecontroleerd op virussen met Avast > antivirussoftware. > www.avast.com > >

⚡Generated with XQuery