New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if-blocks (and other flow control blocks) always override $args with an empty list #397

Closed
xiaq opened this Issue Jul 7, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@xiaq
Member

xiaq commented Jul 7, 2017

The fact that if-blocks and other control flow blocks are full lambdas mean that they also have an argument list. However, they never get any arguments, which is a bit useless and annoying:

fn f {
  if (= (count $args) 2) {
    # doesn't work, since $args is not the arguments to f
    put $args[1]
  }
}

There are several possible solutions:

  • Document and live with this.

  • Introduce a special "flavor" of lambda for flow control blocks that don't have $args.

  • Remove support for $args because implicit things are confusing. This also means that variables like $0, $1, ... are also lost.

    Alternatively, come up with a restricted design for $args that is useful is simple cases, but doesn't get confusing in more complex cases.

@xiaq xiaq added this to the 0.10 milestone Jul 8, 2017

@xiaq xiaq closed this in 01220cf Aug 5, 2017

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