>>>>> "M" == Mathieu Bouchard <matju / cam.org> writes:

M> Why there is a need for a distinction between "local" and "dynamic"
M> variables?... couldn't they all be "dynamic"? what would be the impact?

 Probably there are many reasons, but at least a performance penality :

 local variable :

      case NODE_LVAR:
	if (ruby_scope->local_vars == 0) {
	    rb_bug("unexpected local variable");
	}
	result = ruby_scope->local_vars[node->nd_cnt];
	break;

 dynamic variable :

      case NODE_DVAR:
	result = rb_dvar_ref(node->nd_vid);
	break;

    VALUE
    rb_dvar_ref(id)
        ID id;
    {
        struct RVarmap *vars = ruby_dyna_vars;
    
        while (vars) {
            if (vars->id == id) {
    	        return vars->val;
            }
            vars = vars->next;
        }
        return Qnil;
    }

 Same for allocation : local variables are allocated when the def begin
 (ruby know the number of local variables in a def), dynamic variables when
 it find a node DASGN_CURR


Guy Decoux