dynamic built fun and records

Raimo Niskanen <>
Mon Oct 11 09:20:44 CEST 2004


Sorry, it is not possible. It is only the compiler that handles
record definitions. The syntactical form of record definitions
is, in fact, compiler directives.

erl_eval cannot handle records and therefore says 'undef_record'
for every record syntacs thingie that arrives to it. Records
should have been converted to tuples, it thinks.

Write to a file and compile, or use an expanded record from the
module that knows about #rec and makes the fun.

Oh, in R10B the shell can handle record definitions. 
It is brand new. But erl_eval can still not.



 (Knut Bakke) writes:

> Hi,
> I'm building funs runtime on R9B from pure text
> strings using the following approach:
> 
> {ok,Tokens,Start}=
>     erl_scan:string("fun()->testing, A=#rec{} end."), 
> {ok,ExprList}=erl_parse:parse_exprs(Tokens),
> {value,Fun,_}=erl_eval:exprs(ExprList,[]}.
> 
> Fun(). resuts in 'undef_record', If I remove the
> record
> the fun it works works.
> 
> I'm making the fun in a module that knows about #rec.
> 
> Any idea?
> 
> knut Bakke.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list