|
From: Peter S. <st...@we...> - 2017-09-19 13:01:18
|
Hi Joe,
thanks for confirming the issue! I will file a bug report …
Best
Peter
> Am 19.09.2017 um 14:50 schrieb Joe Wicentowski <jo...@gm...>:
>
> Adapting Peter's example to the final XQuery 3.0 spec for constructing map entries (using : instead of :=), the code does work in BaseX and Saxon, returning "Hello World".
>
> ```
> xquery version "3.1";
>
> let $model := function($param) {
> map {
> 'test': function() {
> $param
> }
> }
> }
>
> return $model('Hello World')?test()
> ```
>
> The error in eXide is:
>
> > err:XPDY0002 variable '$param' is not set. [at line 6, column 13]
>
> Peter, I think this counts as a bug. Could you file an issue?
>
> On Tue, Sep 19, 2017 at 6:08 AM, Peter Stadler <st...@we... <mailto:st...@we...>> wrote:
> Hi again,
>
> I just tested against a recent 3.5 snapshot (built from the develop branch) and the mentioned problem still exists. From what I understood about closures, "you can not only access the function parameters, but also any variable which was in scope at the time the inline function was created“[1].
> Yet, something like
> ```
> let $model := function($param) {
> map {
> 'test' := function() {
> $param
> }
> }
> }
>
> return $model('Hello World')?test()
> ```
> does not work anymore. It feels like a regression (introduced in 3.4) but I’m no expert in functional languages …
> Any hints appreciated – if it’s indeed a bug I’m happy to file a bug report and add an appropriate test.
>
> Best
> Peter
>
> [1] http://atomic.exist-db.org/blogs/eXist/HoF <http://atomic.exist-db.org/blogs/eXist/HoF>
>
> > Am 22.08.2017 um 22:24 schrieb Peter Stadler <st...@we... <mailto:st...@we...>>:
> >
> > Hi all,
> >
> > I encounter some problems in my XQuery app which surfaced since eXist-db 3.4.0 and I don’t know whether it’s a regression. Consider the following XQuery 3.0 code:
> >
> > ```
> > let $model := function($param) {
> > let $func := function() {
> > $param
> > }
> > return
> > map {
> > 'foo' := $func,
> > 'bar' := $func()
> > }
> > }
> > ```
> >
> > Now, when I call
> >
> > ```
> > return $model('a')?bar
> > ```
> >
> > it will return ‚a‘ as expected, whereas calling the function reference with
> >
> > ```
> > return $model('a‘)?foo()
> > ```
> >
> > will result in the error "err:XPDY0002 variable '$param' is not set.“
> >
> > Is this a regression or do I have to change my code?
> >
> > Many thanks in advance
> > Peter
> >
> > [eXist Version : 3.4.1]
> > [Git commit : e8996ca]
> > [Operating System : Mac OS X 10.11.6 x86_64]
> > Java 1.8.0_131
> >
> >
> > --
> > Peter Stadler
> > Carl-Maria-von-Weber-Gesamtausgabe
> > Arbeitsstelle Detmold
> > Hornsche Str. 39
> > D-32756 Detmold
> > Tel. +49 5231 975-676
> > Fax: +49 5231 975-668
> > stadler at weber-gesamtausgabe.de <http://weber-gesamtausgabe.de/>
> > www.weber-gesamtausgabe.de <http://www.weber-gesamtausgabe.de/>
> >
> > ------------------------------------------------------------------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________ <http://sdm.link/slashdot_______________________________________________>
> > Exist-open mailing list
> > Exi...@li... <mailto:Exi...@li...>
> > https://lists.sourceforge.net/lists/listinfo/exist-open <https://lists.sourceforge.net/lists/listinfo/exist-open>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot <http://sdm.link/slashdot>
> _______________________________________________
> Exist-open mailing list
> Exi...@li... <mailto:Exi...@li...>
> https://lists.sourceforge.net/lists/listinfo/exist-open <https://lists.sourceforge.net/lists/listinfo/exist-open>
>
>
|