Re: A question about certain language features
>Call-by-reference isn't used much, but when it is, it makes code
>both simpler and clearer:
I spent 12 years coding with everything being call by reference.
I never understood the problem eg:
proc square(k)
k=k*k
end proc
z=2
square(z)
print(z)
===> just bizarre to me to see that print 2. I'll live though.
(And yes, in this case I do know to use function & z=square(z) ok)
>> > Local constants are really not needed.
And the same 12 years with no such concept as constants, just
variables you didn't alter.
>
>The alternative, which we have now, is to declare them as variables,
>assign to them, then hope we don't accidently change the value somewhere >in
>the routine.
Hope? yuk. who taught you to code?
> And the only way to know whether that variable is used as
>a variable or as a constant is to read the entire routine.
I find that commenting my code with trivia like what a variable is
used for and things like whether it should be modified or not quite
helpful. Mind you I am that rare beast that spends a lot more time
writing comments than code and feel very strongly that is the right
way to go about it. I try to write stuff that you can read the
comments and know what it is (trying) to do, then, and only then, if
you need to, you can look at the code.
For what it's worth, the only time I ever felt i *needed* a goto was
to do something really horrid like jump _into_ the middle of a loop
or another routine. To extricate myself from a tricky (aka nested)
situation is (usually) trivial: just move the code to new procedure(s)
and plonk return(s) in it. Trying to get in half way through on the
other hand without using goto can create a godawful mess. Needless to
say such use of goto tends to do that anyway, only quicker.
Pete
|
Not Categorized, Please Help
|
|