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

Mats Cronqvist <>
Thu Mar 8 14:55:33 CET 2007


Bjorn Gustavsson wrote:
> Unfortunately, -record(a, {b,v,d}) is a function call in the shell
> 
> 1> -record(a, {b,v,d}).
> -42
> 2> 

   MY shell can do this:

28> {hacker,bjorn,1}.
{hacker,bjorn,1}
29> -record(hacker,{name,rank}).
0
30> {hacker,bjorn,1}.
#hacker{name = bjorn,rank = 1}

   mats

p.s. had to add some pure evil to user_default.erl

-export([record/2]).
record(R,Fs) ->
   [ets:insert(T,{R,rec(R,Fs)})||T<-ets:all(),ets:info(T,name)==shell_records],0.
rec(R,Fs)->
   {attribute,1,record,{R,[{record_field,1,{atom,1,F}}||F<-tuple_to_list(Fs)]}}.



More information about the erlang-questions mailing list