Stream: beginners

Topic: ✔ Partial evaluation at comptime


view this post on Zulip notramo (Oct 18 2026 at 18:19):

Does Roc partially evaluate the parts of function bodies that work with comptime known parameters, or if there is at least one runtime param, the whole function becomes runtime-only?

view this post on Zulip notramo (Oct 18 2026 at 18:22):

For example:

add = |a, b| (a * 5) + b

add(1, getUserInput()?)

Is (a * 5) computed at comptime or runtime?

view this post on Zulip Richard Feldman (Oct 18 2026 at 18:48):

runtime, and it would still be comptime if add were curried...but you could get it to be comptime if you separated the arithmetic expressions like so:

add = |a| {
    captured = a * 5
    |b| captured + b
}

view this post on Zulip Notification Bot (Oct 18 2026 at 18:48):

notramo has marked this topic as resolved.


Last updated: Nov 04 2026 at 18:54 UTC