I use defstruct to define a struct variable. For example:
defstruct(mystruct aaa bbb)
s1 = make_mystruct(?aaa 1 ?bbb 2)
then I use setVarWriteProtect to make s1 write protected:
But when I change s1->aaa = 5, it still can be modified. Seems only s1 is write protected, but no its member variables.
How to write protect the member variable s1->aaa? Is there anyway to do it in Skill if not by function setVarWriteProtect?
In reply to Angeila:
We're not ignoring you. It's just that we don't know the answer or if it is possible. I think it might be a question for a Cadence person.
Why do you want to protect it like this? I can't really think of a good reason.
In reply to eDave:
Thanks for your kindly response:)
I created a structure which will be shared by other team members after I initialize it, and it will be surved as read-only purpose as I don't want it to be changed by other team members by accident.
I am a greenhand to Skill language, when I refer to skill user guide, I found setVarWriteProtect can meet such requirement, but it does not work a defstruct variable.
Could you please share me any feasible way to do so?
Generally variables should be set to be local by including them in a let statement. Local variables cannot be changed by users.
You may have to re-think your code if you want to protect the contents of a global variable. The documentation states that the behavior of this is not specified.
eDaveGenerally variables should be set to be local by including them in a let statement. Local variables cannot be changed by users.You may have to re-think your code if you want to protect the contents of a global variable. The documentation states that the behavior of this is not specified.
Thanks! Actually that is not a global variable, it(the defstruct variable) is passed as a function parameter. it might be Skill limitation to write protect a defstruct variable. Not sure...
Anyway, I will think about other way to protect it.
Another interesting phenomena I found is that a local variable defined in parent function is visible in its child function.
Please look at following example, cellName is visible in function testCell(), it can be printed out as "abc" when call function mytest().
It behaves differently compared with that of C language, and other script language, like Tcl. Is there any special purpose for SKILL to do so?
procedure( mytest() prog( (cellName) cellName = "abc" testCell() ))procedure( testCell() prog( () printf("cell name is %s ...\n" cellName) ))
Yes, I had noticed that behaviour - sometimes it's useful, but I think it's bad practice use it deliberately.