xsl-list
[Top] [All Lists]

Re: [xquery-talk] [xsl] Re: Random number generation : requirements

2014-05-06 17:59:08

The big problem with a nondeterministic random() function is not defining the 
order of execution, but preventing it being optimised out of a loop. For 
example, how do we ensure that

$xxx[random() gt 0.5]

doesn't select either all the values or none?

Anyway, we're not planning to do non-determinism. This exercise is about 
designing a deterministic way to meet the requirement.

Michael Kay
Saxonica

On 6 May 2014, at 23:48, Michael Sokolov 
<msokolov(_at_)safaribooksonline(_dot_)com> wrote:

On 5/6/2014 6:41 PM, Michael Kay mike(_at_)saxonica(_dot_)com wrote:
My policy on side effects is: all expressions containing side effects are 
going to be evaluated in order

I do something like that in Saxon as well. But I don't attempt to define 
what "in order" means; for example, the order in which different global 
variables are evaluated. Doing this in the spec would be much more 
problematic.

You don't think it would be reasonable to say something to the effect that 
the order in which non-deterministic expressions are evaluated is 
non-deterministic (ie implementation-defined)? Certainly it would be 
reasonable enough in the case of a random number generator.  Although I 
suppose if you are going to seed it, you would like the seed to effect the 
random numbers that are generated.

-Mike
_______________________________________________
talk(_at_)x-query(_dot_)com
http://x-query.com/mailman/listinfo/talk
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>