Statements as expressions [was Re: Undefined behaviour in C]

Rustom Mody rustompmody at gmail.com
Tue Mar 29 23:14:02 EDT 2016


On Tuesday, March 29, 2016 at 12:18:38 AM UTC+5:30, Paul Rubin wrote:
> BartC  writes:
> > With more recent ones I've dropped that model, so that statements and
> > expressions are different, and that is strictly enforced. This makes
> > implementation simpler, and detects lots more errors.
> 
> You should try Haskell, where there are only expressions, but the ones
> that perform actions can be separated from the other ones through the
> type system, so using one in the wrong place raises a compile time type
> error.

When I studied Pascal was mainstream and Lisp (and to smaller extent
Prolog, APL) were hi-faluting.

In retrospect, Pascal got something right that most everyone, both before and 
after got wrong, viz that we need values AND effects.

Philosophically: Is programming about knowing or doing?
Clearly any onesided answer is wrong.
Both columns in the table here need equal weightage
http://blog.languager.org/2016/01/primacy.html#expstat

Pascal → C → Python is a slide down because
Pascal had the clear distinction of procedure and function
C conflated procedure into function with its 'void function'
[Actually the first C had no void]
Python only has None-return
But a None returned to signify a real semantics eg dict.get not finding key
And a None returned because asking for something is meaningless eg print in 
python3 are unfortunately undistinguishable although conceptually totally different

Yeah Haskell's type system carries Pascal's procedure←→function distinction
in great and excruciating detail -- pure and monadic types.
But IMHO monads for distinguishing values and effects is sledgehammer-for-cracking-an-egg



More information about the Python-list mailing list