Stream: compiler development

Topic: Defs in arbitrary expressions


view this post on Zulip Richard Feldman (Nov 18 2024 at 03:50):

in general if I indent and do x = 1, doesn't that always begin a def?

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:52):

That was one of the things that changed with the introduction of "blocks/statements" a while back

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:53):

Prior to that, it worked _inconsistently_

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:53):

That's something we can bring back in the future, but I'd want to figure out some of the oddities with that first

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:56):

e.g. I'm having a hard time understanding why someone would ever want to do:

x +
   y = 1
   y*2

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:56):

I would have to go back in the git history and check - but I _think_ that was one of the cases that never worked

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:57):

I forget whether that worked in the context of an argument to a function

view this post on Zulip Joshua Warner (Nov 18 2024 at 03:58):

(this probably deserves a separate thread...)

view this post on Zulip Notification Bot (Nov 18 2024 at 04:02):

8 messages were moved here from #compiler development > Weird fuzzing bug of the day by Joshua Warner.

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:05):

Joshua Warner said:

e.g. I'm having a hard time understanding why someone would ever want to do:

x +
   y = 1
   y*2

that's a very fair point!

view this post on Zulip Joshua Warner (Nov 18 2024 at 04:06):

From a parsing perspective, I think the biggest question in bringing this back would be how this interacts with arguments in an apply. Can you _only_ do this on the last argument in an apply? How would you separate more arguments to the outer apply, from arguments to the last expr of the defs sequence?

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:06):

I guess the real critical thing is that defs work inside function bodies, constants, expects, and if and where branches

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:06):

everything else feels non-essential

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:06):

and more of an "ease of teaching how it works" thing

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:07):

but seems fine overall to not support it imo

view this post on Zulip Joshua Warner (Nov 18 2024 at 04:07):

ease of teaching how it works

Yeah, that's a fair point

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:07):

like we could always consider adding support for it someday if we think it's worth it

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:07):

but for right now I would rather prioritize correctness

view this post on Zulip Richard Feldman (Nov 18 2024 at 04:07):

of the compiler


Last updated: Jul 06 2025 at 12:14 UTC