Skip to content

Should capture lists on imperative blocks be optional? #33

Open

Description

@pboyer
No description provided.

Activity

  1. ke-yu commented on Nov 15, 2016

    @ke-yu
    Contributor

    My initial thought was, imperative block could be removed - code in {} in imperative control flow would be in non-imperative context (let's not use associative anymore), but realise that besides sequential execution in imperative code, multi assignment is OK in imperative context, e.g.,

    [Imperative]
    {
        x = 0;
        cond = ...
        while (x < 100) {
            if (cond)
                x = x + 1;
            else
                x = x + 2;
        }
    }
    

    So if capture list is optional, we have to check (in usage and in compiler implementation) a variable is defined in this imperative block scope or not. If it is defined outside, it shouldn't be modified. To me it is inconvenient.

    x = 1;
    [Imperative]
    {
        y = 2;
        x = 2;   // Invalid
        y = 3;   // OK
    }
    

    If capture list is not optional, it is clear that the value is "copied" to the imperative block:

    x = 1;
    [Imperative](x)
    {
         while (x < 100) {
            x = x + 1;  // OK to assign new value to "x"
        }
    }
    // here x is still 1
    

    The other benefit is to support replication on imperative language block.

    The downside is some current workflows will be broken. To mitigate that, if there is an error in code block node, we won't delete all connectors until error gets fixed.

    @pboyer what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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