Re: Namespaces
> The reason for *having* to return a result have to do with the parser not
> having more than 1 token look ahead. Jiri suggested using (), like so:
>
> return ( expr ) -- return expr
> return -- no explicit return value
>
> but that would require, on average, more work for the coder, and more
> chances for typos. So for now, I'm opting for a required value.
David, why not go for the ICON style returning of values:
def match (x, s)
for index = 1 to length(x) - length(x) do
if equal (x, s[index..index+length(x)]) then
return index
end if
end for
end def
A normal call would just return the first matching value, however, imagine
what the 'each' keyword does:
printf(1, "Found match as %d", {each match(x,s)})
More readable, look at this approach:
for each match (x, s) as pos do
s[pos] = '!'
end for
What do you all think about this feature ?
Ralf N.
nieuwen at xs4all.nl
|
Not Categorized, Please Help
|
|