preprocessor instructions for BaseX XQUERY interpreters ?
Hello, I have some questions about BaseX interpreter. 1) Is there a way to send preprocessor instructions to BaseX interpreter ? I am looking to a way to tell the interpreter to skip code based on external instructions, mainly to distinguish the behavior between debug / release modes. This is achieved in C++ with the macro set of instructions #define, #if, #endif etc... I was wondering whether there exists such a mechanism in XQUERY. Note : processor instructions might not be relevant for XQuery, since interpreters are heavily optimized. 2) Could you confirm that BaseX interpreter will not try to interpret "dead" code ? To emulate processor instructions with XQUERY, I am presently using dynamic local variable declarations as (declare function debug(){true()/false()}), and encapsulating my code with a lot of "if (debug()) then (.1.) else (.2.)". Can you confirm that BaseX interpreter skip looking at (.1.) or (.2.) accordingly to the debug function return value ? Cheers Jean-Marc
Hi Jean-Marc,
Note : processor instructions might not be relevant for XQuery, since interpreters are heavily optimized.
Dito.
2) Could you confirm that BaseX interpreter will not try to interpret "dead" code ?
If you want to see what’s going on under the hood, simply check out the output from the InfoView panel (or the query info with -V on command line). The following query… declare variable $DEBUG := true(); if($DEBUG) then <A/> else <B/> will e. g. be simplified to <A/>. This means that all constants will indeed be pre-evaluated at compile time. Hope this helps, Christian
participants (2)
-
Christian Grün -
jean-marc Mercier