After tweeting all week so much, I miss the Favorite button in my mail
client.. ;-)



*Van:* [email protected] [mailto:
[email protected]] *Namens *Jakob Fix
*Verzonden:* donderdag 11 april 2013 9:07
*Aan:* MarkLogic Developer Discussion
*Onderwerp:* Re: [MarkLogic Dev General] (foo(), bar())[1]: is bar()
evaluated if foo() exists?



Hi, I was kind of hoping that this might be an occasion to use xdmp:eager()
but wrapping Michael's test case in it doesn't change the time spent at
all.

BTW, what's the use case for xdmp:eager(), the documentation is a bit
"xdmp:lazy()" about it ;-)


cheers,
Jakob.



On Wed, Apr 10, 2013 at 11:40 PM, Geert Josten <[email protected]>
wrote:

Hi Tim,

I think it is like it is, because MarkLogic will probably attempt to
evaluate both functions in parallel, which makes short circuiting
difficult. But I would think that the optimizer should be able to detect
such (.., ..)[1] tricks very easily, and be able to prevent that. Perhaps
file an RFE at support?

Cheers from Vegas,
Geert

> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:general-
> [email protected]] Namens Tim Finney
> Verzonden: donderdag 11 april 2013 5:42
> Aan: MarkLogic Developer Discussion
> Onderwerp: Re: [MarkLogic Dev General] (foo(), bar())[1]: is bar()
evaluated
> if foo() exists?

>
> Hi Michael,
>
> Thanks for that succinct demonstration.
>
> It would be a Good Thing if we could use the [1] trick knowing that it
> would shortcircuit.
>
> Best,
>
> Tim Finney
>
> On 04/11/2013 11:38 AM, Michael Blakeley wrote:
> > Not in my 6.0-2.3 environment.
> >
> > declare function local:foo() {
> >    1
> > };
> >
> > declare function local:bar() {
> >    xdmp:sleep(1000),
> >    2
> > };
> >
> > (local:foo(), local:bar())[1],
> > xdmp:elapsed-time()
> > =>
> > 1
> > PT1.001195S
> >
> > The profiler shows the xdmp:sleep too. So I only use the [1] trick
when I
> don't care about performance.
> >
> > -- Mike
> >
> > On 10 Apr 2013, at 20:08 , Jason Hunter <[email protected]>
> wrote:
> >
> >> It shortcuts out like you want.
> >>
> >> Sent from my iPhone
> >>
> >> On Apr 10, 2013, at 7:53 PM, Tim Finney <[email protected]> wrote:
> >>
> >>> Hi All,
> >>>
> >>> (foo(), bar())[1]
> >>>
> >>> can be used instead of
> >>>
> >>> if (exists(foo())) then foo() else bar().
> >>>
> >>> But does MarkLogic evaluate bar() if I use the (foo(), bar())[1]
> >>> construct and foo() exists? I'm interested to know because bar()
could
> >>> take a long time to evaluate.
> >>>
> >>> Best,
> >>>
> >>> Tim Finney
> >>> _______________________________________________
> >>> General mailing list
> >>> [email protected]
> >>> http://developer.marklogic.com/mailman/listinfo/general
> >> _______________________________________________
> >> General mailing list
> >> [email protected]
> >> http://developer.marklogic.com/mailman/listinfo/general
> >>
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to