Verifiably better, validated Enum for Python

bartc bc at freeuk.com
Wed May 24 19:34:52 EDT 2017


On 24/05/2017 23:59, 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.

That was quite likely with older Fortrans, where subroutines only used 
pass-by-reference, but which didn't stop you passing references to 
constants that the subroutine could then modify.

I doubt that's still the case. With C, however, I tried this today:

   "abcdef"[3] = 'z';
   puts("abcdef");

Some versions crashed; some printed 'abczef', and some 'abcdef'. (The 
language says this is undefined, but it doesn't try too hard to stop you 
doing it.)


-- 
bartc




More information about the Python-list mailing list