[erlang-questions] The Beauty of Erlang Syntax

Robert Virding rvirding@REDACTED
Thu Feb 26 21:21:39 CET 2009

What I find I do if I want to use more complicated expressions in the shell
is to define a small module containing the functions I need at the moment
and then throw it away when done. Sometimes I even bung them somewhere in
the modules I am testing and delete them when done.

One thing to remember is that there is no support in the erlang VM for
interpreted code. All functions exist in compiled modules. So it is
impossible to mix interpreted and compiled functions and in many lisp
systems, there are no interpreted functions. There is an interpreter written
in Erlang, erl_eval, which is used by the shell but it has no special status
in the system.


2009/2/26 Zvi <exta7@REDACTED>

> This is very real *practical* example of repeating multiple times
> measurement
> from the shell.
> You can't define your _times function from the shell and it's not in
> standard library, the closest is lists:foreach/2 .
> So one need to define Times fun from the shell using Y-combinator, before
> doing time measurement?
> The second also, very practical. It's hard to work from shell in recursive
> language, when you can't define recursive fun from the shell.
> You can't use macros from the shell either.
> I'd like to define loop funs and spawn processes from the shell, but the
> only way is to use uggly Y-combinator trick.
> The practical solution for this is to add times/1 and loop/1 to the
> user_defaults.erl or something like this (and make sure that every Erlang
> VM
> installation have this file ...).
> Zvi
> Why not tailor your own function
> times(F, N) when is_function(F,0), is_integer(N), N>=0 -> _times(F, N).
> _times(_, 0) -> ok;
> _times(F, N) -> F(), _times(F, N-1).
> and than you can easily do times(fun()->io:format("hi~n"), 10).
> But anyway, how often you need do something N times without take care for
> result for *practical* purpose? I think you choose wrong example ;-)
> --
> View this message in context:
> http://www.nabble.com/The-Beauty-of-Erlang-Syntax-tp22179816p22231875.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090226/5af8e1e6/attachment.htm>

More information about the erlang-questions mailing list