Re: Optional "then" and "do"
- Posted by Jason Gade <jaygade at ya?oo.c?m> May 15, 2008
- 986 views
CChris wrote: > > Matt Lewis wrote: > > > > yuku wrote: > > > > > > Salix wrote: > > > > But if I tend to forget "and". The result now is > > > > > > > > }}} <eucode> > > > > if apple=1 bananas=3 then peach=7 end if > > > > </eucode> {{{ > > > > > > > > With optional "then" it would be > > > > > > > > }}} <eucode> > > > > if apple=1 bananas=3 peach=7 end if > > > > </eucode> {{{ > > > > > > > > that is much harder to track down. > > > > > > You can always write the "then" if you want. > > > Especially in such one-line if. > > > > > > Reason of making it optional is that it reduces the mental load of > > > remembering the correct delimiter for every if, for and while statement. > > > > I argue that this mental load is dwarfed by the mental load required for > > maintenance. > > > > Matt > > If using proper indentation to start and end code blocks, you'd get clearer > code with less typing: > }}} <eucode> > if something() > do_stuff() > while true > poll_channel() > -- end of all three blocks > </eucode> {{{ > > Do away with end, do and then in one sweep. > Make code structure visually clear, making maintainance easier. How clear is > a sequence of interspersed "end if", "end for" and "end while"? > > All editors I know, except Notepad, have a detab command. The only drawback > of the above is the stronger need to use it when pasting code from other > files. > > CChris > CChris There's already a language that does this, it's called Python. Mandatory indentation? No thanks. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.