Skip to content

An imperative block without a return statement returns null #2

Open

Description

@pboyer
No description provided.

Activity

  1. lukechurch commented on May 31, 2016

    @lukechurch
    Contributor

    (Let me know if me answering these ever gets unhelpful)

    The design was that it should return null.

    Whilst this is a little bit annoying and slightly harms exploration, it does mean that it's less fragile to changes in the ordering of the code and makes it slightly more predictable.

    It's tangled to a broader issue that I now consider a mistake that DesignScript has statements at all rather than everything being an expression. Consequently if we had it return the last expression there'd be all sorts of ugly things to deal with:

    r = [Imperative]  {
    a = 2;
    if (false) { print ("Woof"); } else { print "Meow"; )
    }
    

    Which is the 'last expression'? I think valid arguments could be made for '2', 'false' and "Meow".
    "Last assigned variable" might be a workable alternative, and then you only have to decide what happens with scoping etc.

    This all got far too messy, so we went with null.

  2. pboyer commented on Jun 1, 2016

    @pboyer
    ContributorAuthor

    That sounds very reasonable. Thanks @lukechurch!

  3. changed the title [-]What happens when an imperative block lacks a return? Return last expr?[/-] [+]What happens when an imperative block lacks a return?[/+] on Jun 1, 2016
  4. reopened this on Oct 31, 2016
  5. changed the title [-]What happens when an imperative block lacks a return?[/-] [+]An imperative block without a return statement returns null[/+] on Oct 31, 2016
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