I enjoyed reading "[elixir-core:8881] [Proposal] identity function" and the
ensuing discussion.  It strikes me that some simple extensions to Elixir's
function capture syntax might:

- clean up the appearance of function captures
- make existing functions more generally useful
- reduce the need for special-purpose lambdas

When a captured function is being used as an argument, it may be possible
to infer its arity.  So, maybe we can leave this out:

  Enum.map(&id)
  Enum.sort_by(&String.downcase)

Many named functions take multiple arguments, so they can't be used in
function captures.  Allowing arguments could extend their reach:

  Enum.sort_by(&elem(1))      # sort by the 2nd element
  Enum.map(&Tuple.append(42)) # append 42 to each tuple

On a loosely related note, Clojure gets a lot of mileage out of some
higher-order abstractions (eg, seqs).  There may be opportunities for
Elixir to follow their lead.  For example, some Enum and List functions
might be applicable to Tuples.  Similarly, String functions such as
downcase/1 could be extended to accept atoms, etc.

(ducks)

-r

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/3A20E4BD-9648-4872-852A-C5FFDD0A31D5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to