Re: [polyml] Order of evaluation of arguments to a function

2011-08-20 Thread Rob Arthan
On 18 Aug 2011, at 17:50, David Matthews wrote: > On 18/08/2011 17:02, Alex Merry wrote: >> On 18/08/11 16:08, Ramana Kumar wrote: >>> what about evaluating f? >> So the order of evaluation of (f x y) is >> f >> x >> (f x) >> y >> ((f x) y) >> >> This seems like a natural evaluation order for an

Re: [polyml] Order of evaluation of arguments to a function

2011-08-18 Thread Jeremy Dawson
I recall reading somewhere (can't find it now) that Moscow ML is incorrect, but that it was done deliberately for efficiency reasons, the thinking being that it would be unlikely to be an issue in practice. That is (as I recall), in f x1 x2 x3 (f not an application) it will evaluate _all_ the a

Re: [polyml] Order of evaluation of arguments to a function

2011-08-18 Thread David Matthews
On 18/08/2011 17:02, Alex Merry wrote: On 18/08/11 16:08, Ramana Kumar wrote: what about evaluating f? So the order of evaluation of (f x y) is f x (f x) y ((f x) y) This seems like a natural evaluation order for an eager functional language. I have always understood that the Definition of S

Re: [polyml] Order of evaluation of arguments to a function

2011-08-18 Thread Alex Merry
On 18/08/11 16:08, Ramana Kumar wrote: what about evaluating f? More testing required. In Poly/ML, the following test produces the output "14253": (print "1"; (fn () => (print "2"; fn x => (print "3"; x (print "4") (print "5"); So the order of evaluation of (f x y) is f x (f x) y ((f x

Re: [polyml] Order of evaluation of arguments to a function

2011-08-18 Thread Ramana Kumar
On Thu, Aug 18, 2011 at 4:00 PM, Alex Merry wrote: > On 18/08/11 15:06, Ivan Tomac wrote: >> >> It seems to me like SML/NJ, MLton and PolyML evaluate all function >> arguments left to right, OCaml evaluates them right to left, and >> Moscow ML seems inconsistent. > > I'd say that it seems like, gi

Re: [polyml] Order of evaluation of arguments to a function

2011-08-18 Thread Alex Merry
On 18/08/11 15:06, Ivan Tomac wrote: It seems to me like SML/NJ, MLton and PolyML evaluate all function arguments left to right, OCaml evaluates them right to left, and Moscow ML seems inconsistent. I'd say that it seems like, given an expression (f x y), SML/NJ, MLton and PolyML evalute x, th

[polyml] Order of evaluation of arguments to a function

2011-08-18 Thread Ivan Tomac
Is the following code supposed to print 1 followed by 2 or 2 followed by 1? val _ = (fn () => (print "1\n"; fn x => x)) () (print "2\n"; ()) In SML/NJ, MLton and PolyML it does the former, while in Moscow ML it does the latter. Is this specified somewhere in the standard? I noticed equivalent cod