No quick way to suppress the unused variable warnings, this may be a good thing
If I’m using some API that takes a function with a lot of arguments that I don’t need, how would this look? For instance I have some code that looks like this:
Not friendly for newcomers reading ReScript code, it’s not intuitive what its purpose is.
Not all JS devs follow this convention for private.
Hard to search for this kind of syntax in documentation.
Not friendly for newcomers writing ReScript code, the underscore prefix may be used for other purposes, so a newcomer using it will have a frustrating surprise that behaviour is different from JS, and may have difficulty discovering why the behaviour is happening (due to previous point).
Making it part of ReScript is opinionated considering in JS it’s only a convention.
Overall, I’d propose that making this part of the language syntax moves ReScript away from JS, when ReScript’s strength is that it aims to align with JS.
I use leading underscore as an intuitive way of ignoring values (kind of documentation of what is this ignored value).
another thing I’ve to mention is from what I see leading underscore convention (for hiding stuff) is not that common in js community these days.
so although interfaces are enough for me I prefer having a keyword or attribute as an easier way to hide implementation rathar than leading underscore.
IMO whitelisting is better than blacklisting. It’s easier to accidentally leak a private thing (hard to notice) than accidentally forget to export a public thing (hard to miss as build would fail due to missing public item). That being said, pub > pri.
I like this proposal mostly because it is very easy to implement compared with using a keyword like private, and the implementation should be very efficient.
So if we want to get a lightweight private mechanism, this seems to be the most realistic solution, I guess Go adopts this approach might because of similar reasons.
I have lots of to do so this is not a high priority, just to let you know all the tradeoffs.
An explicit decorator or keyword is the best solution though IMO. It’s explicit, obvious, and without footguns.
Ideally I would want everything private by default and sprinkle %%public on bindings I want to expose (like Rust), but I get that this kind of breaking change may not be feasible. Given that, I prefer just having %%private (and fixing any issues that exist with it) instead of adding multiple ways to do something as critical as privacy.
Was this proposal abandoned? It would pretty much solve all React Fast Refresh issues, we wouldn’t need interface files just to ensure fast refresh works correctly.