From: W.S. H. <ws...@gm...> - 2015-07-06 09:44:36
|
Christophe, I'm wondering what problem you're trying to solve. True reflection would require a kind of metaprogramming (i.e. a way of mutating the program at runtime) that is far removed from xquery. IMO this is more easily achieved by using macros, and you could create some way to write those using util:eval, which isn't part of the spec, but available in eXist. Another way I guess is to run your functions through a general-purpose caller function, where you provide the function as an argument and use xquery's 3.1 fn:apply to handle the call. Consider the following caller function: function (function,$arguments) { apply($function,$arguments) (: do something with $function :) } Thanks. Wouter 2015-07-06 11:06 GMT+02:00 <wol...@ex...>: > My use-case is quite narrow but with functions being XQuery 3.0 > first-class citizens, the scope for sending the current function to other > functions is certainly wider. > > > If you would like to implement something yourself, XQueryContext.callStack > already contains the current call stack. The field is protected right now, > but I don’t see why we shouldn’t expose it to extension modules via an > accessor method. > > For debugging purposes, I actually planned to add a console:stack-trace > function to the console module in monex, which would also require access to > callStack. > > Wolfgang > > > On Sat, Jul 4, 2015 at 1:40 AM, Adam Retter <ad...@ex...> wrote: > >> Ah Sorry... I just reread your question. What you are asking for would >> require some sort of reflection, this is not currently possible in XQuery >> 3.1. We could add an extension to eXist for this, but there is not anything >> yet. >> >> There is a thread on the xquery-talk mailing list about feature requests >> for XQuery 3.2 started by Wouter Hager, perhaps you would like to add this >> to that list? >> >> On 4 July 2015 at 00:38, Adam Retter <ad...@ex...> wrote: >> >>> XQuery 3.1 offers you - >>> >>> fn:function-name and fn:function-arity. >>> >>> >>> >>> On 30 June 2015 at 13:58, Christophe Geiser < >>> chr...@e-...> wrote: >>> >>>> Hi all, >>>> I am wondering if there is a way to get the function name, arity, >>>> signature or function item of the function being currently executed? >>>> something like : >>>> >>>> declare function local:signature($arg) { >>>> let $name := inspect:function-name() (: would return "local:signature" as xs:string :) >>>> let $arity := inspect:function-arity() (: would return 1 as xs:integer :) >>>> let $signature :=inspect:function-signature() (: would return "local:signature#1" as xs:string :) >>>> let $function := inspect:function-item() (: would return local:signature#1 as function :) >>>> return () >>>> }; >>>> >>>> Thanks and wishing the best to the list, >>>> C. >>>> -- >>>> >>>> <https://www.e-smile.org/> >>>> >>>> <https://plus.google.com/+E-smileOrg> >>>> <https://twitter.com/esmileSolution> <https://github.com/e-smile> >>>> >>>> >>>> *Christophe Geiser*Founder of e-smile >>>> >>>> e-smile.org >>>> >>>> Never give up on a dream just because of the time it will take to >>>> accomplish it. The time will pass anyway. >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Don't Limit Your Business. Reach for the Cloud. >>>> GigeNET's Cloud Solutions provide you with the tools and support that >>>> you need to offload your IT needs and focus on growing your business. >>>> Configured For All Businesses. Start Your Cloud Today. >>>> https://www.gigenetcloud.com/ >>>> _______________________________________________ >>>> Exist-open mailing list >>>> Exi...@li... >>>> https://lists.sourceforge.net/lists/listinfo/exist-open >>>> >>>> >>> >>> >>> -- >>> Adam Retter >>> >>> eXist Developer >>> { United Kingdom } >>> ad...@ex... >>> irc://irc.freenode.net/existdb >>> >> >> >> >> -- >> Adam Retter >> >> eXist Developer >> { United Kingdom } >> ad...@ex... >> irc://irc.freenode.net/existdb >> > > > > -- > > <https://www.e-smile.org/> > > <https://plus.google.com/+E-smileOrg> <https://twitter.com/esmileSolution> > <https://github.com/e-smile> > > > *Christophe Geiser*Founder of e-smile > > e-smile.org > > Never give up on a dream just because of the time it will take to > accomplish it. The time will pass anyway. > > ------------------------------------------------------------------------------ > Don't Limit Your Business. Reach for the Cloud. > GigeNET's Cloud Solutions provide you with the tools and support that > you need to offload your IT needs and focus on growing your business. > Configured For All Businesses. Start Your Cloud Today. > > https://www.gigenetcloud.com/_______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > > > > > ------------------------------------------------------------------------------ > Don't Limit Your Business. Reach for the Cloud. > GigeNET's Cloud Solutions provide you with the tools and support that > you need to offload your IT needs and focus on growing your business. > Configured For All Businesses. Start Your Cloud Today. > https://www.gigenetcloud.com/ > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > > -- W.S. Hager Lagua Web Solutions http://lagua.nl |