Python is DOOMED! Again!
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sun Feb 1 11:31:12 EST 2015
Paul Rubin wrote:
> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
>> Some degree of weakness in a type system is not necessarily bad. Even the
>> strongest of languages usually allow a few exceptions, such as numeric
>> coercions.
>
> Haskell doesn't have automatic coercions of any sort. You have to call
> a conversion function if you want to turn an Int into an Integer.
That's unusual but not unheard of.
>> I've never come across a language that has pointers which insists on
>> having a separate Nil pointer for ever pointer type
>
> Haskell's idiomatic substitute for a null pointer is a Nothing value
> (like Python's None) and there's a separate one for every type. The FFI
> offers actual pointers (Foreign.Ptr) and there is a separate nullPtr
> for every type.
Well, I live and learn.
>> the compiler will allow Nil to be used for any pointer type. Anything
>> else would be impractical.
>
> It's completely practical: polymorphism and type inference get you the
> value you want with usually no effort on your part.
But it's the "usually" that bites you.
If I have an arbitrary pointer, and I want to check if it is safe to
dereference, how do I do it? Surely I'm not expected to write something
like:
if type(ptr) == A:
if ptr != Anil: ...
if type(ptr) == B:
if ptr != Bnil: ...
etc. That would be insane. So how does Haskell do this?
>> What if you add two empty objects?
>> js> {} + {}
>
> OMG, javascript is worse than I thought
>
>> https://www.destroyallsoftware.com/talks/wat
>
> Can't view, needs flash. :(
At the bottom of the page is a link to a .mov version. If you can't
play .mov files either, contact me off list.
> Try this instead (NFSW): https://www.youtube.com/watch?v=FJ7QsEytQq4
--
Steven
More information about the Python-list
mailing list