[erlang-questions] Self referencing records.

Gaspar Chilingarov <>
Wed Jul 18 08:12:55 CEST 2007


Ludovic Coquelle wrote:
> I'm not sure to understand the undelying problem, but I think there is a
> problem of syntax.
> Is the following what you're looking for?
> 
> test() ->
>    T = #object{class='Object', props=dict:new()},
>    NewProps = dict:append("this", T, T#object.props),
>    T#object{props=NewProps}.
> 

Well, it will reference not to itself, but to copy of itself :)


> On 7/18/07, Julio César Carrascal Urquijo (MCTS) <>
> wrote:
>>
>> Hi,
>>
>> Is it possible at all to create a record that references it self? 

IMHO, You can not have "references" in Erlang. All data structures are 
passed by value (at least from programmer's point of view, VM may 
optimize sometimes and pass pointers rather than value).

-- 
Gaspar Chilingarov

System Administrator,
Network security consulting

t +37493 419763 (mob)
i 63174784
e 
w http://zanazan.am/



More information about the erlang-questions mailing list