Should Ludus distinguish between functions and procedures? #98

Open
opened 2025-07-14 14:16:16 +00:00 by scott · 0 comments
Owner

It seems like it's worth playing around with an enforced distinction between procedures and functions.

Functions would be exactly as written, with the exception that a function name cannot end in a bang. They would not be allowed to call procedures.

Procedures would be introduced by the to reserved word, and would be required to have a name that ends in a bang.

This would be enforced as statically as possible; there would definitely be some runtime cost (but we incur that anyway, for most things).

Procedures could call other procedures and functions; functions could only call other functions.

A procedure call would have to come only at the end of a synthetic expression.

Procedure calls could only come: at the toplevel or in procedure definitions. And in those, they can only be bare lines in a block or in a terminal expression (then or else; match or when clauses, etc.).

It seems like it's worth playing around with an enforced distinction between procedures and functions. Functions would be exactly as written, with the exception that a function name _cannot_ end in a bang. They would not be allowed to call procedures. Procedures would be introduced by the `to` reserved word, and would be required to have a name that ends in a bang. This would be enforced as statically as possible; there would definitely be some runtime cost (but we incur that anyway, for most things). Procedures could call other procedures and functions; functions could only call other functions. A procedure call would have to come only at the end of a synthetic expression. Procedure calls could only come: at the toplevel or in procedure definitions. And in those, they can only be bare lines in a block or in a terminal expression (`then` or `else`; `match` or `when` clauses, etc.).
scott added the
design
language
labels 2025-07-14 14:16:16 +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#98
No description provided.