let
form has surprising scope
#1325
sabjohnso
started this conversation in
Ideas and Proposals
Replies: 1 comment
-
I agree fully this is surprising behavior and ought to either be much better documented or changed altogether. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
let
form incoalton
has mutually recursive binding semantics, which I believe will be surprising to most new users as the name is typically associated with sequential and parallel binding, whileletrec
see greater use for mutually recursive binding. I think adopting more common naming convention would be advantageous.tl;dr: Below should illustrate my expectations.
The inline documentation for
let
forms does not give sufficient information to understand the scoping rules for the form:produces the output
which does not specify whether it is sequential or parallel binding. Prodding with some code reveals a probable bug:
leads to the following error:
Further prodding leads to more information, but the unexpected result that scoping rules are neither the anticipated parallel or sequential bind but the mutual recursive binding:
produces the following error:
Namely, the following code would be more suitable to understand the scope:
This binding bears more in common with CL's
labels
, Scheme or Racket'sletrec
or OCamlslet rec
and ought to named accordingly.Finally, better documentation of the the form is provided by the ast node
node-let
, which states:but that is not very accessible for
coalton
users.Beta Was this translation helpful? Give feedback.
All reactions