elixir icon indicating copy to clipboard operation
elixir copied to clipboard

Record field punning would be nice

Open pminten opened this issue 13 years ago • 2 comments

It would be nice to write something like CodepointInfo[codepoint: cp, upper, lower, title] instead of CodepointInfo[codepoint: cp, upper: upper, lower: lower, title: title]. OCaml has a mechanism for this called field punning, Haskell has something similar.

In Elixir it would be possible to alter Record.access so that CodepointInfo[upper, lower, title, codepoint: cp] is allowed (note that punned arguments have to go before unpunned arguments due to the usual syntax rules).

This is a bit of a discussion ticket: is field punning desirable (enough) and would this be the right way to go about it?

pminten avatar Nov 19 '13 14:11 pminten

It would make a lot of my code easier on the eyes for sure.

meh avatar Nov 19 '13 14:11 meh

Hey @pminten, can you please move this discussion to the core mailing list? It will spark a better discussion for sure. Also, can you please include examples from Haskell and Ocaml and go over the list of upsides/downsides? Thanks!

josevalim avatar Nov 19 '13 14:11 josevalim