Re: problems with the scoping in eu4

new topic     » goto parent     » topic index » view thread      » older message » newer message
bill said...
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.

How do you run off the end of a string if you know the length?

This isn't C.

bill said...

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.

I don't understand your statement here.

You can use an infinite loop. You can either add essential initialization language before the loop begins or you can add it after "entry". It is best used when the initial condition is something which is repeated on every iteration of the loop but which is less important than the test.

It helps eliminate violations of the rule "don't repeat yourself".

Your second statement makes no sense. Why start at the bottom of the loop? Why "only while loops and no exit mechanism"? "with entry" is a new addition, not something which has been with the language from the beginning.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu