Re: mainly syntax

new topic     » goto parent     » topic index » view thread      » older message » newer message

I disagree with everyting (!!!) that BABOR, JIRI jsut wrote:

> we would have
>
>     if x then
>         for i=1 to x do
>             do_something() ..

> Neat,eh?! The first dot for 'end for', and the second one for 'end if'.
> And the compiler/interpreter can tell us anyway, if and why the dots
> do not match.

Yuck, shades of LISP and its onion peels )))))))))) !
My eyes water peeling those parentheses. Not only mine:
later implementations allowed ] as a shorthand for any
number of )))))))

> And while I am raving about syntax, I cannot understand this
> completely artificial distinction between procedures and functions.
> After all, functions are merely routines that return a value while
> procedures do not. So why a different mechanism? The so called
> 'safety' argument is even weaker here than for the crutches above.

I was surprised too, and I did say it here, because it broke all my
ingrained habits. However, I remembered an article from way back in
which some big shot in computer science was arguing that a procedure
should be allowed only two parameters: input, passed by value (i.e.
read-only) and output. Euphoria implements it partly in its own way,
and I have no bones about it.


> Perhaps one more syntactic niggle: I seem to be writing about thousand
> times a day something like x = s[length(s)], or s1 = s2[m..length(s2)]

Me, only dozens.

> This could easily be replaced by, say, x = s[-1], or s1 = s2[m..-1],
> which is more elegant and saves the function call overhead as well.

That is strange, not syntax, but semantics. This use of -1 is an
exception
worthy of C's "->" which really stands for "*.", is not easier to type,
and adds one more thing to remember which could be dispensed with very
nicely. Rather than seeing it implemented in the language, I'd rather
see programmers who want it implement it themselves, like this for
instance:

function sub(sequence s, atom start, atom stop)
 if stop=-1 then stop=length(s)
 end if
 return s[start..stop]
end function

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu