pnwamk
2018-8-22 14:16:24

@notjack you can have duplicate identifiers today already, so I think that we cannot add a constraint disallowing that. As for adding a note in the docs, IMHO I think people (should) know what they’re doing when they’re choosing names. Shadowing can be nice, and it can also bite you in the ass. Use at your own risk. Unless we’re going to add warnings everywhere about it, I don’t think for/fold should get one.


pnwamk
2018-8-22 14:17:15

If we add the aforementioned feature, however, the docs should be crystal clear about how scope/binding works for the #:result clause.


greg
2018-8-22 14:22:28

smiles thinking about a #lang common-lisp-loop-macro


soegaard2
2018-8-22 14:23:35

@greg Loops ehh? Seen Shiver’s paper on loops?



notjack
2018-8-22 17:24:38

@pnwamk it doesn’t feel like shadowing to me, it feels like (lambda (a b b c) body ...)


notjack
2018-8-22 17:26:19

Which a language could allow by saying that later variables shadow earlier ones… but doing so is almost surely a mistake so it’s better to just error


notjack
2018-8-22 17:28:27

Come to think of it, do regular for clauses allow duplicate loop variables?


pnwamk
2018-8-22 17:28:44

well, it is what it is — right now you can have the same identifier as an accumulator and sequencing id. I see it as shadowing with the way the for/fold syntax is set up (one set of binders syntactically following another)… but that view is also possibly biased from looking at the expansion of the for macros many times.


pnwamk
2018-8-22 17:29:38

If you’re asking if this works, it does not:


pnwamk
2018-8-22 17:29:43
(for ([x (in-naturals)]
      [x (in-naturals)])
  (display x))

notjack
2018-8-22 17:29:57

I’m curious if any packages would break with this restriction added to for/fold


pnwamk
2018-8-22 17:30:07

error message: “unsaved editor:4:7: let-values: duplicate binding name at: x in: …”