[GAP Forum] protecting variables ( MakeImmutable )
    kroeker 
    kroeker at uni-math.gwdg.de
       
    Fri Mar  2 17:43:37 GMT 2012
    
    
  
Dear GAP-Forum,
I am a little bit confused about protecting variables.
Is it possible in all cases, and if not, will this be possible in future 
versions of GAP?
For example, I failed to protect a 'Property':
######################################
exampleRec := rec();
exampleRec.IsShape := NewProperty("IsShape",IsObject);
InstallMethod(exampleRec.IsShape , "" ,[IsObject],
function(obj)
     return false;
end
);
exampleRec.IsShape := MakeImmutable(exampleRec.IsShape);
exampleRec := MakeImmutable(exampleRec);
IsMutable(exampleRec);
IsMutable(exampleRec.IsShape);
InstallMethod(exampleRec.IsShape , "" ,[IsObject],
function(obj)
     return true;
end
);
# I would expect an error , but there is none!
exampleRec.IsShape(4);
######################################
My second question is, how to define  local constants?
For example, I would like to protect  'constantInt':
######################################
     local constantInt;
     constantInt := 5;
     # how to protect  constantInt?
######################################
Thanks,
Jakob
    
    
More information about the Forum
mailing list