Re: Initializing variables on declarations
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Apr 07, 2007
- 593 views
> > Current syntax: > > > [global] integer x x = 5 > > > > > > Desired syntax: > > > [global] integer x = 5 > FWIW, I'm for this. I think it could be quite fair to say that only short literal integers are allowed, though the special case of {} would be welcome. I am in agreement with most that object x=f(5,g[7]) etc is overkill. I must admit that I wanted to stand back and watch how this thread panned out, and am left with the desire to call for an old Pascal-style ruling that we can (straying off topic a bit here) say eg:
procedure x() constant a=1,b=2 integer x,y
but NOT
procedure x() integer x constant a=1 integer y constant b=2
I must admit though I am in two minds. I see this as a good thing in many ways and also as a possibly open running sore of disappointment and perhaps confusion as to why certain expressions are not allowed. But a firm hand documentationwise could fix that, surely? Rob Craig wrote: >why not privates (inside a routine) as well? Personally, that is mostly where I want it most. There is a minor syntactic sugar with more complex expressions at top level:
<type> var=<expr>
is exactly the same as:
<type> var var=<expr>
in disguise. It is quite natural to me now to key var<Ctrl W><Ctrl V><space><Ctrl V>; however the former is plain easier to read. As above and general consensus K.I.S.S. for for private routine vars tho. Regards, Pete