Stream: contributing

Topic: Add warning for non-snake_case idents


view this post on Zulip Sam Mohr (Jan 09 2025 at 01:18):

When updating the tests for the snake_case change, it was really easy to miss a lot of syntax issues because everything was in a string. We might consider moving as many tests into snapshots as possible at some point, but for now, we can still make catching these issues easy by giving warnings for old syntax, including:

Anyone disagree? Otherwise I can do this, probably no issue needed.

view this post on Zulip Luke Boswell (Jan 09 2025 at 01:22):

"my string ${interpolation}" too

view this post on Zulip Sam Mohr (Jan 09 2025 at 01:25):

I keep forgetting that one, good catch

view this post on Zulip Luke Boswell (Jan 09 2025 at 01:28):

The other one mentioned in the Richard's draft blog about functional PI is the ??

view this post on Zulip Luke Boswell (Jan 09 2025 at 01:29):

I'm not sure we're tracking any Issues for that

view this post on Zulip Sam Mohr (Jan 09 2025 at 01:31):

They're mentioned here: https://github.com/roc-lang/roc/issues/7086

view this post on Zulip Luke Boswell (Jan 09 2025 at 01:32):

Nvm.. I just realised it's already implemented. :sweat_smile:

main! = \_args ->

    value = Env.var!("NAME") ?? "LUKE"

    Stdout.line!("Hello, $(value)!")

view this post on Zulip Sam Mohr (Jan 09 2025 at 01:33):

Anthony is a Bull in an Unimplemented Syntax Shop

view this post on Zulip Anthony Bullard (Jan 09 2025 at 02:58):

What did I do now?

view this post on Zulip Anthony Bullard (Jan 09 2025 at 02:59):

Oh ??

view this post on Zulip Anthony Bullard (Jan 09 2025 at 02:59):

Yeah I did that

view this post on Zulip Anthony Bullard (Jan 09 2025 at 03:00):

I’m dragging Roc into the future

view this post on Zulip Anthony Bullard (Jan 09 2025 at 03:00):

Luckily not kicking and screaming. That my four year olds job

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:37):

Can tags have single underscores in them?

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:38):

Normal tags are PascalCase

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:38):

But I've been seeing some SCREAMING_SNAKE_CASE tags recently

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:38):

Though I'm only seeing a single word for these

view this post on Zulip Luke Boswell (Jan 09 2025 at 21:46):

Where have you seen that?

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:46):

GET, POST, DELETE, etc.

view this post on Zulip Luke Boswell (Jan 09 2025 at 21:48):

We had a conversation about those specifically, Richard wanted them UPPERCASE

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:48):

But what should we do if it's two words

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:48):

TWOWORDS or TWO_WORDS?

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:49):

We could allow either SCREAMING_SNAKE_CASE or PascalCase, but you can only have either underscores or lowercase letters

view this post on Zulip Luke Boswell (Jan 09 2025 at 21:52):

I like SCREAMING_CASE for constants, so for tag unions without payloads it kind of feels ok

view this post on Zulip Luke Boswell (Jan 09 2025 at 21:53):

Maybe tag unions with payloads are only PascalCase? (just spitballing here)

view this post on Zulip Luke Boswell (Jan 09 2025 at 21:54):

I don't think we want to be too restrictive. Maybe just allow anything as long as it starts with an Uppercase ASCII letter?

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:55):

For context, I'm trying to write a utility that parses out relevant info for names in one O(n) pass, e.g.

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:57):

This will help with reporting non-snake_case names, in addition to other stuff

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:58):

We definitely want to allow running any code even if we don't like it

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:59):

But I think Roc being opinionated on style makes code more consistent in unfamiliar codebases, which is a really nice feature

view this post on Zulip Sam Mohr (Jan 09 2025 at 21:59):

I don't think we should allow more than one underscore in a row, for example

view this post on Zulip Richard Feldman (Jan 09 2025 at 22:13):

yeah I agree about disallowing (via warning) multiple underscores in a row

view this post on Zulip Sam Mohr (Jan 09 2025 at 22:13):

Should we allow First_Second?

view this post on Zulip Sam Mohr (Jan 09 2025 at 22:14):

I think no

view this post on Zulip Richard Feldman (Jan 09 2025 at 22:14):

I think that's ok. I could imagine a scenario where you're trying to make a tag for each field in a record or something

view this post on Zulip Richard Feldman (Jan 09 2025 at 22:14):

and there might be underscores in there, and you want them to match up

view this post on Zulip Sam Mohr (Jan 09 2025 at 22:15):

fair

view this post on Zulip Anton (Jan 10 2025 at 09:29):

We might consider moving as many tests into snapshots as possible at some point

I'm not a fan of that, I think it's difficult for newcomers to find the snapshot file for a specific test. It requires more effort to see the input for a test for experienced people too.

view this post on Zulip Sam Mohr (Jan 10 2025 at 09:38):

Okay, makes sense. I think the thing I was thinking of was that we should make it easy to update tests with Roc changes, but that should happen if we make add warnings for invalid Roc


Last updated: Jul 06 2025 at 12:14 UTC