[xquery-talk] [xsl] Re: Random number generation : requirements
ghislain.fourny at 28msec.com
Thu May 8 06:34:14 PDT 2014
We had a discussion on monads not so long ago in the context of update
and scripting. I like the elegance of monads. It is my understanding.
though, that monads only defer side effects to until they are applied
-- and then you are back to the need for side effects semantics.
Somehow, side effects and their visibility to subsequent expressions
bring an irreducible amount of complexity to the design of the
language (evaluation order, snapshots, etc). I don' t think there is
an easy way to introduce them -- clean and elegant, maybe, but not
easy, or at least, I believe, not easier than what was done in the
current scripting draft or alternate implementations.
That said, I think it is an important point that non-determinism is
distinct from side effects. You can have deterministic side effects,
and you can have non-determinism without side effects (as I tried to
illustrate in my former e-mail). So far, I am not convinced that
introducing side effects would address non-determinism.
Does it make sense?
On Wed, May 7, 2014 at 10:29 PM, Benito van der Zander
<benito at benibela.de> wrote:
> Hi Michael,
> perhaps it is time to add monads to XPath?
> They should solve this issue and all related ones
> On 05/07/2014 12:58 AM, Michael Kay wrote:
> 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
> On 6 May 2014, at 23:48, Michael Sokolov <msokolov at safaribooksonline.com>
> On 5/6/2014 6:41 PM, Michael Kay mike at saxonica.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
> 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.
> talk at x-query.com
> talk at x-query.com
More information about the talk