[erlang-questions] indentation-sensitive erlang

Vlad Balin gaperton@REDACTED
Wed Mar 19 19:32:39 CET 2008


It might be a bit tricky in some cases:

something( L ) ->
   F =
      fun( X, S ) when is_list( X ) ->
         something( X ) + S
      fun( X, S ) ->
         X + S
   lists:foldl( F, 0, L )

fun can be defined with a number of patterns, in this case it should
be formatted differently I guess.

2008/3/19, Vlad Balin <gaperton@REDACTED>:
> Can't you get rid of terminators such as 'end'? Anyway we have a kind
>  of two-dimentional syntax here. So you can use indentation to identify
>  scope. At the same time, we will address complains that it's hard to
>  reorder clauses in erlang because of , . and ;
>
>
>  f(X) ->
>    X+2
>
>  g(X) ->
>    X+4
>
>  h(X) ->
>    Y = case X of
>          a ->
>            {a}
>          b ->
>            {b}
>
>    Y
>
>  And that's it.
>
>  Sincerely,
>  Vlad Balin.
>
>  2008/3/19, Ulf Wiger <ulf@REDACTED>:
>
> > 2008/3/11, Ulf Wiger <ulf@REDACTED>:
>  >  >
>  >  >  - I'd like to try (= see someone else implement) an indentation-sensitive
>  >  >   front-end to the compiler,
>  >
>  >  Ok, so I did try it myself:
>  >
>  >  http://ulf.wiger.net/weblog/2008/03/19/indentation-sensitive-erlang/
>  >
>  >  (Inspired by Chris Okasaki's blog article).
>  >
>  >  Surely someone else could do a better job, but it's a start, at least.
>  >
>  >  The following senseless program compiled:
>  >
>  >  -module(test).
>  >
>  >  -compile(export_all).
>  >  -scan(indentation).
>  >
>  >  f(X) ->
>  >     X+2
>  >  .
>  >
>  >  g(X) ->
>  >     X+4
>  >  .
>  >
>  >  h(X) ->
>  >     Y = case X of
>  >           a ->
>  >             {a}
>  >           b ->
>  >             {b}
>  >     end
>  >     Y
>  >  .
>  >
>  >
>  >  BR,
>  >  Ulf W
>  >  _______________________________________________
>  >  erlang-questions mailing list
>  >  erlang-questions@REDACTED
>  >  http://www.erlang.org/mailman/listinfo/erlang-questions
>  >
>



More information about the erlang-questions mailing list