Distinguish between functions and procedures? #26

Open
opened 2024-01-21 04:21:13 +00:00 by scott · 0 comments
Owner

Just chatting with @mynt about Ludus with the upcoming first-demo Playtime, and it occurs to me that rigorously distinguishing between procedures (side effects, no return value) and functions (no side effects, return values) may well be extremely useful pedagogically.

Here's one way we could do that:

  • a to special form, distinct from fn (thanks, Logo!)
  • to names must end with a bang: forward!
  • fn names must not end with a bang
  • procedure names cannot be on the rhs of a let binding
  • at the parser level, we can distinguish between blocks that do and do not allow for procedures in them
  • thus we can enforce, statically, that procedures are to forward! (...) -> ... and functions are fn sin (...) -> ...

I suspect this will be a help, especially in early learning.

Just chatting with @mynt about Ludus with the upcoming first-demo Playtime, and it occurs to me that rigorously distinguishing between procedures (side effects, no return value) and functions (no side effects, return values) may well be _extremely_ useful pedagogically. Here's one way we could do that: * a `to` special form, distinct from `fn` (thanks, Logo!) * `to` names must end with a bang: `forward!` * `fn` names must not end with a bang * procedure names cannot be on the rhs of a `let` binding * at the _parser level_, we can distinguish between blocks that do and do not allow for procedures in them * thus we can enforce, statically, that procedures are `to forward! (...) -> ...` and functions are `fn sin (...) -> ...` I suspect this will be a help, especially in early learning.
scott added the
enhancement
proposal
research
semantics
syntax
ux
labels 2024-01-21 04:21:13 +00:00
scott added the
later
label 2024-05-19 19:34:41 +00:00
scott added this to the Someday milestone 2024-05-19 19:53:10 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: twc/ludus#26
No description provided.