Scala considering significant indentation like Python

bartc bc at freeuk.com
Mon May 22 10:14:22 EDT 2017


On 22/05/2017 14:59, Jussi Piitulainen wrote:
> Cholo Lennon writes:
>

>> I am a huge python fan (but also a C++ and Java fan) and I agree with
>> Scala creator, sometimes the readability is complicated. So, more
>> often than I would like to, I end up missing the braces :-O
>
> I am the inventor of multiple ends on the same line. This way, in a
> language where all of several nested constructs end with an end - not
> going to name the language but it's Julia - instead of
>
>                 end
>             end
>         end
>     end
> end,
>
> one combines the uninformative lines into one by writing
>
> end end end end end,
>
> and with four-space indentation the ends align neatly with the starts.
> Technically, the ends on the remaining line of ends are backwards.
>

I think 'end' can be used in Python too:

  if (cond):
      stmts
  end

But:

- You need to define a dummy variable 'end'

- It's not enforced nor checked by the language, it's only to aid
   readability, so ends may be placed incorrectly or left out

- Multple ends on one line need a comma separator:

   end, end, end

- No one actually does this so it can't solve any of the problems
   people might have with indentation


-- 
Bartc



More information about the Python-list mailing list