Hi Jason,

Thanks very much for doing that research. If I was there, I would have 
done some researching too.

It would be very useful to know that the [1] special case short circuits 
because of the use case where [1] is a cheap way to do it (e.g. a cached 
item exists) and [2], [3], ..., are expensive.

Best,

Tim Finney

On 04/16/2013 12:46 AM, Jason Hunter wrote:
> I did a little research into this at MarkLogic World (where research is 
> defined as having drinks with the engineer responsible) and found out that he 
> changed the behavior in MarkLogic 6 so that now the comma sequence operator 
> is no longer lazy and this expression no longer short circuits.
>
> He made the change because he found it sped up other expression evaluation 
> because he could use more efficient C++ internal data structures.  I 
> suggested an optimization to recognize [1] as a special case, where maybe 
> lazy evaluation would be good to preserve because internal data structures 
> wouldn't be needed to store the sequence.
>
> Anyway, there you have it.
>
> -jh-
>
> On Apr 10, 2013, at 8:39 PM, Tim Finney <[email protected]> wrote:
>
>> Hi Jason,
>>
>> Thanks for your reply. I have a profiler set up and its timings suggest
>> that the (foo(), bar(args))[1] is not short-circuiting when foo()
>> exists. Different timings occur when I substitute different bar(args)
>> functions and foo() exists.
>>
>> Best,
>>
>> Tim Finney
>>
>> On 04/11/2013 11:08 AM, Jason Hunter 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

Reply via email to