When I was watching an Elixir video the person kept calling this ‘destructuring’ (which I think is what they say in the JS world?) but Joe Armstrong, in his book Programming Erlang, calls this ‘unpacking’ - so I am curious, how do you refer to it when using a BEAM language?
Use the terms interchangeably depending on the language
This quote shows us that equivalent/similar data types across languages are implemented and therefore grouped differently which means that we can’t use exactly same naming. Different naming forces new developer to think: Why it's named like that? and that ends up with looking for it’s definition.
Having in mind that both destructure and unpack are used only for arrays and objects it’s confusing to use them in Elixir for other data types like for example string. Destructure naming could also be confusing for newbies as we have structs.
Destructure and unpack antonyms suggest that we have something structured or packed which is not always true. While it’s common to say that we are unpacking bits from string still we can’t say that we are unpacking something from literal like for example: 5 = variable.
Generally i.e. for all data types I prefer to think about some connection of assignment, fetch, pattern and take words (which are most common) like taking by pattern or something like that.
@AstonJ Considering your Erlang code we can say that we are taking items: rectangle, Width and Height by 3-element tuple pattern of Rectangle variable. What do you think about it?
I think both terms (or how you said it) work fine, but was interested in hearing what those using BEAM languages say as I was curious why the person in that Elixir video was saying destructuring, whereas Joe says unpacking.
In terms of onboarding people, I think sticking to one is usually best, perhaps also mention that people say X in language Y too, in case they are familiar with that language.
For me I quite like the term unpacking, as generally you are trying to access some value that is ‘packed’ together into something like a Tuple - but what you said is basically what we’re doing - taking something from inside something else