#Floor generator cannot assign read only variable code
That works, and the change is seen by any code that also imports container. I should note that although you can't modify the binding ( TimeZone in your example), if you export an object, that object's state can be modified. "imp2: Failed to directly set counter to 127" So if Modules A and B both import Module C, you don't want Module A modifying what Module B sees (even if Module C can, because it's a variable, not a constant).įWIW, here's an example ( live copy on plunker): The variable is write-protected and can only be read. Remember that modules are shared across the various modules importing them. Nevertheless, discrepancies cannot be precluded, for which reason we are not able to. In non-strict code, the assignment is silently ignored. specify a new variable in an ATTRIB statement. specify a new variable in a FORMAT or INFORMAT statement. read data with the INPUT statement in a DATA step. (Technically, it is a non-writable data property.) This error happens only in strict mode code. These are some of the most common ways that you can create variables in a DATA step: use an assignment statement. Read-only contexts include foreach iteration variables, using variables, and fixed variables. This error occurs when an assignment to variable occurs in a read-only context. (Or expose an object with mutable properties.) The global variable or object property that was assigned to is a read-only property. Cannot assign to variable because it is a read-only variable type. If the source module wants to make it possible for modules using it to change the value of the exported variable, it can expose a function to do that. Why? Because one module importing the variable shouldn't be able to reach into the source module and change the variable's value. Only the module exporting it can modify it. Even if the source binding is mutable (as in your example), you can't use the imported view of it to modify it.
Imports are a read-only view of the exported binding in the source module's environment.