stz statement end

stz statement end
Photo by Kat Combs / Unsplash

A controversial topic in the programming world - how do you end a statement?

In Smalltalk you do it with a fullstop .
In C you do it with a ;
In Javascript you do it with a ; unless you don't because sometimes it knows what you mean.
In Python you do it with a newline because subexpressions are indented with more whitespace.
In Odin you do it with a newline

So far I've been using newline and that works for everything except multi-keyword method signatures spread across multiple lines. Let's look at an example:

1: people when: mood happy do: [ stdout print: 'happy!' ]

2: people
3:   when: mood happy
4:   do: [ stdout print: 'happy!' ]
  1. Everything is okay. This statement is completely understandable
  2. Is this the whole statement? Just people? it's certainly valid
  3. Is this a whole statement? are we sending when: to the compilation scope?
  4. How about this one, is this the whole statement sending do: to the compilation scope?

The Smalltalk approach is to pretend you're writing a sentence. You end sentences with a full stop. I'm honestly not sure what the logic was behind picking ; semi-colon for the C family of languages. I admit I prefer the approach of 'less noise is best' when writing code. I'm very used to writing full stop and semi-colon but I like it better when I don't have to.

In the last blog post I proposed using \ on the next line to indicate it's part of the previous line. this is like \ at the end of a line in a shell script. It's ugly. It's slightly less ugly on the next line instead of the end of the previous line. But it's still ugly.

Do we commit the Python blasphemy and require indented whitespace to indicate it's continued from the previous line? It's not the worst answer in the world:

people
  when: mood happy
  do: [ stdout print: 'happy!' ]

people when: mood happy
       do: [ stdout print: 'happy!' ]

We'd not require a specific amount of extra whitespace - just some would be enough to make it clear that it's part of the previous line. This is simple enough that it's what we're going with for now.