Stream: ideas

Topic: Dbg expression


view this post on Zulip Luke Boswell (Dec 01 2023 at 22:52):

I've noticed the below enables the use of dbg inline. Is this something we could add as syntax sugar or as a builtin maybe?

I'm not sure what the longer term plan is to support this use-case, maybe this is too hacky or sets us up for a bad time later?

debug = \v ->
    dbg v
    v

view this post on Zulip Agus Zubiaga (Dec 01 2023 at 22:58):

I think that’s already the plan: https://roc.zulipchat.com/#narrow/stream/316715-contributing/topic/auto-derived.20Inspect/near/404760322

view this post on Zulip Agus Zubiaga (Dec 01 2023 at 22:59):

Basically making dbg both a statement and valid expression

view this post on Zulip Richard Feldman (Dec 01 2023 at 23:02):

yeah the code gen is easy; I think the only thing that needs to happen is to look for the dbg keyword both in the statement position and also in the expression position, and make sure it generates code differently depending on which one it was parsed as

view this post on Zulip Richard Feldman (Dec 01 2023 at 23:03):

if anyone wants to implement that lmk! I'd be happy to mentor :smiley:

view this post on Zulip Elias Mulhall (Dec 01 2023 at 23:26):

I'm interested in implementing but my time is still spotty so if someone else wants it done in the next couple weeks they should go for it

view this post on Zulip Anton (Dec 02 2023 at 09:44):

and make sure it generates code differently depending on which one it was parsed as

I'm not sure how difficult the above task is, but something I've proposed before in the related issue is to start with dbge for the expression case and merge dbg and dbge later.


Last updated: Jun 16 2026 at 16:19 UTC