Eliminating assignments and variable syntax (accessors)
Lex Spoon
lex at cc.gatech.edu
Wed Aug 11 05:08:17 UTC 1999
Stefan Matthias Aust <sma at netsurf.de> wrote:
> [Indentation as statement continuation]
>
> >There is the remaining problem of blocks. Maybe allow blocks with
> >one statement to be inlined, and force blocks with multiple statements
> >to have a line per statement?
>
> I don't see problems for a parser here. When it detects a [, it knows that
> it has to look for a ]. You can both write the block in one line or in the
> next line - even not indented as the parser knows that there's still
> something missing. Now if the block contains more than one statement, you
> have to insert new lines.
>
> A statement like
>
> true ifTrue: [false]
>
> would be possible as for example
>
> true
> ifTrue: [false]
>
> or even
>
> true
> ifTrue:
> [false]
>
Okay, but it doesn't seem fully in the spirit of syntax-via-indentation. After all, one of the main places python uses indentation is to note the start and end of a block, right?
So it might be cool to be able to do something like this:
x<3
ifTrue:
y := y + 1
ifFalse:
z := z + 1
But this doesn't look perfect, either--it takes 5 lines when 3 or even 1 would do. So, maybe allow the [ ] syntax for blocks that are only one statement long?
x < 3
ifTrue: [ y := y + 1 ]
ifFalse:
z := z + 1.
m := m * m.
Lex
More information about the Squeak-dev
mailing list
|