[erlang-questions] Changing the shell and module syntax and semantics

Bjorn Gustavsson bjorn@REDACTED
Thu Mar 8 10:06:23 CET 2007


Unfortunately, -record(a, {b,v,d}) is a function call in the shell

1> -record(a, {b,v,d}).
-42
2> 

/Bjorn

P.S. I've added the following definition to my user_default.erl.

record(_, _) ->
    42.

"Joe Armstrong" <erlang@REDACTED> writes:

>  Something to think about ...
> 
> In the book beta, many people are reporting errors when they type things
> like
> 
> -record(a, {b,v,d}).
> 
> 
> fac(0) -> 1;
> fac(N) -> N*fac(N-1)
> 
> into the shell.
> 
> They don't understand that some things are for the shell, others for modules.
> 
> I Talked to Dave Thomas (Prag P) - he said "why can't you type
> everything into the shell"
> 
> I said bla bla bla .., any explained how it is
> 
> He said - but it must be easy to implement ....
> 
> Having slept on it I think he's right.
> 
> Why not?
> 
> all we need to do is add an invisible "-module(shell)" to
> the session, remember all the stuff that's typed in and
> as new functions come either compile the complete module (so far)
> or interpret the code.
> 
> Variable bindings could occur as in parameterized modules.
> 
> In fact these is no good reason not to allow this in modules as well ...
> 
> -module(mmm).
> 
> X = 12 + lists:sqrt(23).
> 
> foo(A) ->
>      A + X.
> 
> .... etc....
> 
> This would *greatly* increase the power of Erlang and make things
> nicely symmetric
> we can pipe modules into the shell and vice versa, no change. We can
> have a shell
> session and save it as a module ...
> 
> 
> /Joe
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB




More information about the erlang-questions mailing list