2 ms·
Pretty trivial to do with proper macros in a language. Julia has macros for printing variables and values, like `@debug(var)`. There's an Elixir library with m
by elcritch 7y ago
Pretty trivial to do with proper macros in a language. Julia has macros for printing variables and values, like `@debug(var)`.
There's an Elixir library with macros to make a map (dictionary) using the variable names passed in [1]:
iex> import ShorterMaps
...> name = "Chris"
...> id = 6
...> ~M{name, id}
%{name: "Chris", id: 6}
Though wether its a good idea or not is another question. ;) If you want to do the type of programming you're talking about you should try Elixir/Julia/Clojure(/Rust?)... or any number of other languages with macros.
1: https://github.com/meyercm/shorter_maps https://github.com/meyercm/shorter_maps