Hi,

What do you think about adding map deconstruction syntax similar to 
JavaScript. It would remove the need to declare the key and binding 
variable when they are identical names.

Often the map keys and binding var use the same name:

# without deconstruction
%{name: name, email: email} = user

vs

# with deconstruction (identical)
%{name, email} = user

This would work too for function definitions `def send_email(%{name, 
email}) do ...`, pattern matching ` case user, do: %{name, email} -> ....` 
as well as updates `%{user | email, name}`.

It would also require updating `mix format` to replace `%{key: key}` with 
`%{key}`

Here is a prototype of the changes required to the compiler:

https://github.com/elixir-lang/elixir/compare/master...joshnuss:map-destructure

Best,
Josh

 

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/58b222f5-b5cb-4d09-a3da-23ba79a0de07%40googlegroups.com.

Reply via email to