Verifiably better, validated Enum for Python

Steven D'Aprano steve at pearwood.info
Thu May 25 02:28:50 EDT 2017


On Thu, 25 May 2017 10:59:55 +1200, Gregory Ewing wrote:

> bartc wrote:
> 
>> Yet the language will stop you assigning to 672, or "abc".
>>
>> Maybe the language could have been made even smaller if that was not
>> checked; after all the developer ought to be trusted not to assign to
>> them!
> 
> I'm told that some Fortran implementations experimented with something
> akin to that, with "interesting" results.


It wasn't intentional -- it was an accident due to the way they 
implemented pass-by-reference semantics. If you passed a constant to a 
function expecting a variable passed by reference, and then assigned to 
the parameter, the compiler would change the value of the constant.

Pascal solved that problem by prohibiting you from passing constants or 
expressions to functions or procedures as pass-by-reference parameters.



-- 
Steve



More information about the Python-list mailing list