Why not allow empty code blocks?

Rustom Mody rustompmody at gmail.com
Sat Jul 30 13:48:39 EDT 2016


On Saturday, July 30, 2016 at 10:45:23 PM UTC+5:30, Chris Angelico wrote:
> On Sun, Jul 31, 2016 at 2:58 AM, Rustom Mody wrote:
> >> Where, in any useful production code, is the difference between
> >> functions and procedures actually helpful? Or where, in student code,
> >> would it be useful to distinguish? I've been teaching Python to
> >> students with a variety of backgrounds, and nobody has yet been
> >> bothered by this. Not a single one.
> >>
> >> ChrisA
> >
> > In English — and all Indo-European¹ languages — there are two moods
> > “It is raining” is in declarative mood
> > “Come in!” is in imperative mood
> >
> > Now there is a realm in which they are not distinct
> >
> > “It is raining!” said Harry Potter to Hermione and it started raining
> > “Come in!” said Harry, And the chair walked hoppety-hop into the room
> >
> > So sure if you want to teach magic to your kids, all power to you.
> > Myself, I’ll stick to what I know better than magic — programming
> 
> Answer the question, maybe... when *in programming* is this
> distinction important?


eg 1
We can write am assignment in a loop
Can we write a loop in an assignment like?
x = while x ...

Less interesting answer — No we cannot
More pertinent — In our zany new language we are inventing we are going to allow this.
Ok...
What will it mean?

eg 2
A function can
- return a constant
- a variable
- more generally an expression

How about returning a while loop?

In short you use the imperative-declarative distinction every day all the time 
every line of code that you write.

Some languages reify that as an expression/statement function/procedure
division — Pascal.

But even if your language does not support that reification you would not be
able to write a single line of correct code without it.

Broadly (and simplistically):
- When you ask a question — condition of if or while — you need a declarative 
entity
- When you do an action — assignment, body of if/loop — you need an imperative
entity



More information about the Python-list mailing list