Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Clarify evaluation order in language ref #296

Open
@pchiusano

Description

Aaron Sikes brought this up in Slack:

The evaluation semantics of function application is applicative order Call-by-Value. In the expression f x y, x and y are fully evaluated in left-to-right order, then f is fully evaluated, then x and y are substituted into the body of f, and lastly the body is evaluated

Originally I was thinking this should be changed to:

The evaluation semantics of function application is applicative order Call-by-Value. In the expression f x: f is fully evaluated, then x, then x is substituted into the body of f, and lastly the body is evaluated. This rule also covers expressions like g a b, which are parsed as (g a) b.

But I don't think we want to guarantee one at a time evaluation order like this. For instance, consider:

g x = 
  Stream.emit 1
  (y -> 12)

> Stream.toList 'let g (Stream.emit 0) (Stream.emit 2)

This currently will produce [0,2,1] - it evaluates left to right all the arguments being supplied, and then does substitutions and evaluation of the body. And this is what you want, since the one at a time order is crazy inefficient and would involve building N temporary closures just to pass N args to a function. I don't think any real language uses this.

So I think maybe the current description is not bad.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions