[MLton-user] Re: [polyml] Order of evaluation of arguments to a
rda at lemma-one.com
Sat Aug 20 05:58:33 PDT 2011
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)
>> This seems like a natural evaluation order for an eager functional
> I have always understood that the Definition of Standard ML (rule 100) requires this order. The syntax of an application is
> exp ::= atexp
> exp atexp
> and the semantics first evaluates the exp to b, then the atexp to v and then applies b to v.
I think it's rule 101 not 100 (which is the rule for assignment). But read in conjunction with the state and exception conventions that are given before the rules, you are definitely right about this. I think I would be horrified if the call of cond below raised Div rather than CondFailed:
val (cond: ('a -> bool) -> 'a -> ('a -> 'b) -> 'b) = fn test => fn v => (
if test v
then fn f => f v
else raise CondFailed
cond (fn v => v <> 0) 0 (raise Div);
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the MLton-user