Aku's wish list:
Aku writes:
<snip>
> 1. thirdParam=command_line()[3]
> 2. writePos( -5 ) -- no return value
> 3. We can use undeclared variable, eg:
#1 might be better implemented in the core language (cleaner syntax, faster
execution) but here are two good workarounds:
global function subscript(sequence Param,sequence subsc)
object returnValue
returnValue=Param
for i=1 to length(subsc) do
returnValue=returnValue[subsc[i]]
end for
return returnValue
end function
global function slice(sequence Param,sequence subsc,atom Min,atom Max)
Param=subscript(Param,subsc)
return Param[Min..Max]
end function
So thirdParam=command_line()[3] becomes:
thirdParam=subscript(command_line(),{3})
The workaround for #2 is much simpler and implementation in the core
language would gain little or nothing
global object VOID
VOID=writePos( -5 )
Just define a global object variable when you want to ignore a return value
from a function. "VOID" is my personal preference (by analogy to C's void
return type). but any name will do--"junk" and "dummy" are both popular.
As for #3, I agree with Rob 100%. I program professionaly in Visual Basic.
By default, VB silently initializes variables. You can turn off this
feature by using option explicit--and all good VB programmers do so. I had
to do maintainence on someone else's code who didn't use option explicit and
it took three days to run down an error
caused by a silently initialized variable. I hope Microsoft makes explicit
mandatory rather than an option in VB 7.
I would demand that Rob never permit silent initialization, except that it
is clearly unneccessary to demand since he will never permit it anyway.
-- Mike Nelson
|
Not Categorized, Please Help
|
|