rescript-lang / rescript-lang.org

Official documentation website for the ReScript programming language
https://rescript-lang.org
MIT License
1.85k stars 248 forks source link

"* Argument punning!" #581

Closed d4h0 closed 2 years ago

d4h0 commented 2 years ago

Hi,

English isn't my native language, so I might be wrong, but I believe "Argument pruning" is what the author of the above intended to say... :)

See the footnote at https://rescript-lang.org/docs/manual/latest/overview#jsx

Related:

d4h0 commented 2 years ago

I found some more "punning"... :)

https://rescript-lang.org/docs/manual/latest/function#declaration

I also found out that there is a programming concept called 'Type punning', but that seems unrelated to the above usages of the word 'punning'.

d4h0 commented 2 years ago

Another page with "punning": https://rescript-lang.org/docs/manual/latest/jsx

fhammerschmidt commented 2 years ago

"pruning" is used in computer science as well, for instance when you git prune a repository which deletes local branches that have no remote counterpart. However, that does not really fit what we usually mean by punning.

"punning" is used in a couple of (functional) programming languages for having a syntactic sugar shorthand when labels and values are the same. I am not really sure what the origin is, but in a pun a word may have a second meaning in a specific context, so you can apply that to programming languages for labels and values but IMO also to type punning.

ReScripters or OCamlers are not the only ppl that use this term, btw. https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/record_puns.html

Edit: Found another thread in the Haskell Subreddit about this: https://www.reddit.com/r/haskell/comments/buszoe/namedfieldpuns_what_does_pun_mean/

d4h0 commented 2 years ago

Thanks for the explanation, @fhammerschmidt!

I was pretty sure it was wrong because programming "field punning" has 411 results on Google, and programming "field pruning" has 47,000 results.

But you are clearly right. The Rust RFC that introduced the feature to Rust does also call it punning, once:

This new syntax could significantly improve readability given clear and local field-punning variables, but could also be abused to decrease readability if used with more distant variables.

Maybe it would make sense to use a name that is easier to understand, like Rusts Field init shorthand?

I didn't have troubles understanding the meaning (I knew the concept already), but I don't see any advantage in using such an uncommon word that might confuse people.

Anyway, I'll close this issue because punning isn't actually misspelled.