Austin Ziegler schrieb:

> On 5/17/07, Daniel Berger <djberg96 / gmail.com> wrote:
>
>> Is there a way to freeze instance variables in Ruby in order to make
>> them single assignment? I'm just wondering if there's a way to
>> simulate Erlang in this regard as a way to avoid side effects.
>
>  class Module
>    def erl_accessor(*names)
>        [...]
>        define_method("#{name}=") { |v|
>          instance_variables.include? var and raise "Cannot change 
> @#{name}."
>          instance_variable_set(var, v)

What about Thread safety here?
I think you would have do lock before the variable is tested.
If another thread were to assign the same variable
just after the test and before the last line is executed,
then other assignment would be lost, wouldn't it?

I stumbled over this, because this issue also came up
with my proposal of a "growth-allowing freeze"-state of objects.

Regards
Sven