Assignment versus binding

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Oct 6 04:15:17 EDT 2016


Chris Angelico wrote:
> There's one other consideration. With Python functions, you often want
> to run a function for its side effects and ignore its return value.

You can't just ignore a return value in Haskell. The
return value is always going *somewhere*. If you leave
off an argument, the result is going to be a function
instead of whatever type the function was meant to
return. Since Haskell is statically-typed, this will
give you a type error at some point.

> print("Heading")
> print("=======")
> print

You're talking about I/O here, which complicates things
somewhat. Essentially, the equivalent of 'print' is
going to be a function that takes the value to be
printed and returns another function of a specific
type. If it's not the right type, it won't fit into
the machinery that executes I/O operations. So leaving
the argument off the print would lead to a type error,
because you'd be trying to plug the print function
itself into the I/O machine, and it's not the right
type.

-- 
Greg



More information about the Python-list mailing list