Arc Forumnew | comments | leaders | submitlogin
4 points by yariv 6137 days ago | link | parent

In Erlang, using a hypothetical Arc-like web framework:

said(_Req) -> form(fun(Data) -> link(["you said: ", arg(Data, "foo")], "click here") end, input("foo"), submit()).

The main different is that Erlang doesn't have syntactic sugar for a single-variable lambda function. However, the total number of tokens is almost the same.

Maybe I'll take some ideas from Arc and use them in ErlyWeb :) Thanks for the illuminating example -- I've never seen this kind of programming style before.



1 point by partdavid 6135 days ago | link

Thanks, I was scanning this for Erlang and took a look at ErlyWeb to see if it could help me approach it, actually.

-----

1 point by yariv 6134 days ago | link

Typo: different -> difference.

Also, the last two parameters should be in a list, i.e.

said(_Req) -> form(fun(Data) -> link(["you said: ", arg(Data, "foo")], "click here") end, [input("foo"), submit()]).

-----

1 point by partdavid 6132 days ago | link

I've been thinking about this challenge in terms of Erlang idioms and worked up a (very) minimal web framework using yaws. With SPEWF < http://code.google.com/p/spewf/ > this might look like:

   handle(_, [{said, Value}|_]) ->
        {Value, {ehtml, {a, [{href, self}], "click me"}}};
   handle(S, [_|R]) ->
        handle(S, R);
   handle([], []) ->
        {[], {ehtml, {form, [{action, self}],
                            [{input, [{type, "text"},
                                      {name, "said"}, {size, 50}], []},
                             {input, [{type, "submit"}]}]}}};
   handle(S, []) ->
        {S, {ehtml, {p, [], io_lib:format("you said: ~s", [S])}}}.
Like many of the other examples, it's lacking the clever HTML generation.

-----