Stream: show and tell

Topic: `roc dev`


view this post on Zulip Richard Feldman (Aug 22 2022 at 03:34):

PSA: now if you run roc dev, it works like roc check except that if the check finds 0 errors, it then runs the program

view this post on Zulip Richard Feldman (Aug 22 2022 at 03:35):

previously roc (with no subcommand) almost did this, except that it would still try to monomorphize the program even if it found type mismatches, which often led to crashes (which it should not in the long-term, but it does for now because there are still some bugs in the "didn't type check but let's monomorphize anyway" code path)

view this post on Zulip Richard Feldman (Aug 22 2022 at 03:37):

the plan is to repurpose roc-with-no-subcommand exclusively for running hashbang scripts (e.g. the .roc file starts with #!/usr/bin/env roc), because that's the most compatible command to use for that purpose; some env implementations don't accept multiple arguments, so #!/usr/bin/env roc run (for example) wouldn't be supported in those environments

view this post on Zulip Richard Feldman (Aug 22 2022 at 03:37):

so if you want the "type-check and then immediately run if there were 0 errors" behavior, roc dev is now the way to do that!

view this post on Zulip Richard Feldman (Aug 22 2022 at 03:39):

also, shout-out to @Ayaz Hafiz for fixing the old approach to this feature which frequently did unnecessary work and then crashed :big_smile:

view this post on Zulip Richard Feldman (Aug 22 2022 at 03:39):

it's much nicer now!

view this post on Zulip Arya Elfren (Aug 22 2022 at 12:59):

Will there be a way of doing the same but with build instead of run?

view this post on Zulip Richard Feldman (Aug 22 2022 at 14:57):

hm, what would the use case be? :thinking:

view this post on Zulip Richard Feldman (Aug 22 2022 at 14:57):

so right now if you say build, it reports the errors and then builds the executable anyway

view this post on Zulip Richard Feldman (Aug 22 2022 at 14:59):

the idea behind not running if there are errors is to save the time of killing the program after it starts running

view this post on Zulip Richard Feldman (Aug 22 2022 at 14:59):

but when doing a build it just creates an executable but doesn't run it, so that advantage wouldn't really apply!


Last updated: Jul 06 2025 at 12:14 UTC