Re: problems with the scoping in eu4

new topic     » goto parent     » topic index » view thread      » older message » newer message
jaygade said...
bill said...

Not being able to declare a variable in a nested scope of the same name as a variable in outer scope is odd. Being able to declare a parameter of the same name as the outer variable (and for that to operate exactly as one would expect - temporarily shadowing the outer variable) makes things rather more odd.

I agree with this, and there is another thread discussing it.

bill said...

None of the problems I have mentioned are show stoppers. I think they add complexity and particularity. Other than that well it is certainly programmable and rather elegant.

I guess the problem is elegant designs are often hard to improve.

I dislike while with entry and I think that variable declaration should be prohibited in while and switch, and that Eu should have a clean block scope notation.

I didn't used to like "with entry", but seeing it used it's utility is pretty clear to me. I don't think that it adds complications.

While I do believe that some clutter has been added to Euphoria, overall the dev team has done a pretty good job. Heck, when Rob initially designed the language he supposedly didn't include a "for" construct because the "while" loop could handle all cases. Without labels or "with entry"



The problem I have is this: I write a lot of parsing code the structure of the code goes something like:

loop
get c
sym = symbol[c]
case c of
...
reading various type of data into variables etc
...
end case
...
end loop

Therefore I am not thinking of small loops with quirky behavior. Usually I don't use for loops because running off the end of a string is likely behaviour given bad data to parse. Using a while loop implies there is is a condition to test for - usually testing what the next character is.

Using an infinite loop is a good solution because the test(s) can be put where they are needed. Thus the motivation behind with entry do is always in the code.

Starting at the bottom of the loop is enticing if you only have while loops and no exit mechanism. Given these with entry do is pointless and potentially obscure.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu