Hi Christian<
* What is $data-item-...? Are these variables references to variables from the outer scope?
Yes. These variables from the outer scope are bundled and wrapped into a closure-function which then acts as a new data-item.
Let myComplexDataStructure := function( $f) $f( $data-item-1, $data-Item-2, ..... )
I actually use constructor-function for this but it's the same principle.
Declare function mySpaceName:constructor ( $data-item-1, $data-Item-2, ......) { function( $f) $f( $data-item-1, $data-Item-2, ..... ) } ;
Let myComplexDataStructure := mySpaceName:constructor( $outer-scope-var-1, ........)
* You are writing that the annotations could be used to "Trace back to its source for extra information about the closure-function if necessary." What kind of extra information do you have in mind?
Since everything is programmed in xquery itself this information consists of a few functions that are needed to simulate generic data processing such as: a "type" check-, a atomize- and a serialize-function. I can imagen that if I could retrieve proper information about the data-items these function could be replaced by real generic ones. Hence my referring to these functions as 'information'.
* The following query is a valid XQuery 3.0 expression. Could you potentially revise it to illustrate your idea?
declare namespace UDT = 'http://basex.org/modules/udt'; let $data-item-1 := 'STRING' let $data-item-2 := 2 let $f := fn:substring#2 return %UDT:datatype("myType") function( $f) { $f($data-item-1, $data-item-2) }($f)
Sure. As I said: it is a whole mechanism. But to give you an idea.
File: http://basex.org/modules/udt.xqm module namespace UDT = 'http://basex.org/modules/udt' ; import module namespace myDT-1 = 'myLocalDataTypes/datatype-1'; declare function UDT:serialize ( $UDI as function(*) ) { switch( UDT:dataType( $UDI)) case $ myDT-1:dataType return myDT-1:serialize( $UDI) ........... (: if only I could load these darn modules dynamicly:-))) default return serialize( inspect:function( $UDI)) } ;
File: myLocalDataTypes/datatype-1.xqm Module namespace myDT-1 = 'myLocalDataTypes/datatype-1'; Declare function myDT-1:new( $var-1 as xs:string, $var-2 as xs:integer, $var-3 as function(*)*) as function(*) { function( $f) { $f( $var-1, $var-2, $var-3)}}; ...more struct-1 specific-functions such as: an atomizer, a serializer and a typecheck-function.
File::myProgram.xq import namespace mySpecificDataStruct-1 = 'myLocalDataTypes/datatype-1'; let $data-item-1 := 'STRING' let $data-item-2 := 2 let $f := fn:substring#2 let $myDataStruct-1 := mySpecificDataStruct-1.new( $data-item-1, $data-item-1, $f) return do all kind of neat things with $myDataStruct-1, for example using it in a fold-function.
It is not the complete story by far and too much to discuss by mail. If you are interested in the whole story, please let me know. Then we can figure something out.
You're more than welcome,
Rob
-----Oorspronkelijk bericht----- Van: Christian Grün [mailto:christian.gruen@gmail.com] Verzonden: maandag 23 november 2015 9:23 Aan: Rob Stapper CC: BaseX Onderwerp: Re: [basex-talk] issue with the latest snapshot
Hi Rob,
Thanks for the PDF, I had a first look at it.
I saw your proposal for how the syntax of closure functions could look like…
%UDT:datatype( ‘myDataTypeName’) function( $f) { $f( $data-item-1, $data-item-2, ……) }
…but I am not sure what it is exactly supposed to do:
* What is $data-item-...? Are these variables references to variables from the outer scope?
* You are writing that the annotations could be used to "Trace back to its source for extra information about the closure-function if necessary." What kind of extra information do you have in mind?
* The following query is a valid XQuery 3.0 expression. Could you potentially revise it to illustrate your idea?
declare namespace UDT = 'http://basex.org/modules/udt'; let $data-item-1 := 'STRING' let $data-item-2 := 2 let $f := fn:substring#2 return %UDT:datatype("myType") function( $f) { $f($data-item-1, $data-item-2) }($f)
Thanks in advance, Christian
On Sat, Nov 21, 2015 at 4:09 PM, Rob Stapper r.stapper@lijbrandt.nl wrote:
Hi Christian,
I made you a draft. If you need more info, just ask. I've made a whole framework in Xquery for this, including a generic data type mechanism. So if needed I could share this with you.
Awaiting your response, Rob
-----Oorspronkelijk bericht----- Van: Christian Grün [mailto:christian.gruen@gmail.com] Verzonden: vrijdag 20 november 2015 12:25 Aan: Rob Stapper CC: BaseX Onderwerp: Re: [basex-talk] issue with the latest snapshot
PS.The only thing left for me to wish for now is serialization of (annotated) closure-functions with fn:serialize ;-))))))))))))
Proposals are welcome ;)
-----Oorspronkelijk bericht----- Van: Christian Grün [mailto:christian.gruen@gmail.com] Verzonden: vrijdag 20 november 2015 11:23 Aan: Rob Stapper CC: BaseX Onderwerp: Re: [basex-talk] issue with the latest snapshot
I see… array:serialize and map:serialize have been removed, because fn:serialize can now be used to output maps and arrays. I have just updated the Array Module and Map Module documentation.
Thanks, Christian
On Fri, Nov 20, 2015 at 10:10 AM, Rob Stapper r.stapper@lijbrandt.nl wrote:
Hi Christian,
Here is a little example. The file must be placed in the root of the repo-directory. The situation is a little different than I described: it concerns a call to Basex's own array:serialize-function that can't be resolved.
Succes,
Rob
PS, the error-message occurs when editing the file in the GUI. When it starts up it looks fine.
-----Oorspronkelijk bericht----- Van: Christian Grün [mailto:christian.gruen@gmail.com] Verzonden: vrijdag 20 november 2015 9:31 Aan: Rob Stapper CC: BaseX Onderwerp: Re: [basex-talk] issue with the latest snapshot
Guten Morgen Rob,
thanks for the hint. We have revised the serialization concept in the latest version of BaseX. The main difference will be that binary data will be output in their native representation [1] . However, all this shouldn’t affect things like function calls (and all our test cases are working as expected). Could you please give us a little example for a query that is now rejected?
Cheers Christian
[1] http://docs.basex.org/wiki/Serialization
On Fri, Nov 20, 2015 at 7:48 AM, Rob Stapper r.stapper@lijbrandt.nl wrote:
Gute Morgen,
After installing the latest Basex snaphot (8.4) this morning, the new version couldn’t resolved function calls to function that are located in imported modules while compiling.
I get an error messages: “Unknown function ‘…….’; similar: ‘…..’ .”
After installing the previous version (8.3) everything worked fine again.
I’m using windows 7 and basex is installed on my L:-drive.
Hope this is enough information.
Rob Stapper
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. www.avast.com
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
--- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus