5 ms·
> This topic is quite subjective, but could you provide some example? Elixir's pin operator is a good example of unnecessary complexity.
by dxhdr 8y ago
> This topic is quite subjective, but could you provide some example?
Elixir's pin operator is a good example of unnecessary complexity.
- dopamean 8y agoWhy is it unnecessary?
- OvermindDL1 8y agoIt's unnecessary in the 'erlang' ecosystem because erlang doesn't have variable rebinding, Elixir 'does' have variable rebinding so it needs some way to distinguish between rebinding and matching, and it was decided to use `^` to mark matching, when honestly I think it would have been smarter to specify it (or something similar) as rebinding. In quite a few cases rebinding leads to bugs (accidentally rebinding something that you still need an old value of).
- mmartinson 8y agoI think I would also prefer there to be no reminding. On the topic of the pin operator though, it seems more clear to me that it's an assertive component of a match, rather than needing to reference all variables in a scope in the case where there was no rebinding, to determine if something matching has already been assigned.
- dnautics 8y agoA buddy of mine and I were talking at length about this and we came to the consensus that the smartest choice would have been: no rebinding by default, if you want rebinding, make it available, say, using "var", or a sigil
- OvermindDL1 8y agoThis is precisely how I think as well, some declaration like `let` or `var` or so to say "This is a new binding"
- dqv 8y agoI'm okay with this trade off instead of having to do Variable0, Variable1, ..., VariableN. It would be cool to have an option to turn off rebinding for those who don't want it (and then not requiring the pin).
- mononcqc 8y agoElixir already has those rebindable variable, which can be "turned off" by using the ^ prefix on a match variable. Wouldn't that make the |> less useful to you already?
- OvermindDL1 8y ago`|>` would replace the great majority of need for multi-staged named variables. In addition, naming variables like that in Erlang is a mis-design, the names should be more descriptive.
- mercer 8y agoI vaguely recall that this particular choice is one that the language's creator also regrets.