[erlang-questions] Matthew Sackman's "cut" proposal

Jachym Holecek freza@REDACTED
Mon Jul 11 23:22:11 CEST 2011

# Tim Watson 2011-07-11:
> The other point about Mathew's work, is that it provides a means to
> eliminate trillions (ahem) of intermediate (state) variables in a
> section of code such as:
> doodle(X) ->
>     Result1 = do_thing(X),
>     Result2 = calculate_next_thing(Result1),
>     Result3 = get_bored_of_typing_result_x(Result2),
>     Result4 = start_getting_annoyed(Result3),
>     %% etc, etc, etc
>     {ok, Result23}.

Right, that's pretty silly indeed, so why not write:

  doodle(X) ->
      {ok, compose([fun do_thing/1,
                    fun calculate_next_thing/1,
                    fun get_bored_of_typing_result_x/1,
                    fun start_getting_annoyed/1],

instead (where compose/2 has the obvious definition). Except the only really
silly thing here is the unreasonable function names, because otherwise you'd
just write something like:

  doodle(X) ->
      {ok, foo(bar(baz(bam(qux(X)))))}.

What was the problem again? Do you have a more substantial example?

	-- Jachym

More information about the erlang-questions mailing list