Re: problems with the scoping in eu4

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

Hmm, actually he has a fair point.

This doesn't work

while start with entry do 
	integer start 
	... 
entry 
	start = ... 
end while 

But this does work

while 1 do 
	integer start 
	... 
	if not start then exit end if 
	start = ... 

Hmm.

mattlewis said...
petelomax said...
jimcbrown said...
jeremy said...

with entry ... no duplication

... but at least there's no need to duplicate code for this case.

You are both inventing this. It is always perfectly ok to replace

  while <condition> with entry do 
    <block a> 
  entry 
    <block b> 
  end while 

with the much clearer

  while true do 
    <block b> 
    if not <condition> then exit end if 
    <block a> 
  end while 

You can like "with entry" and I can dislike it, but please stop saying it removes code duplication or makes things easier to read when it achieves neither.

It's a fair point, that absolute claims regarding style preferences are going to wrong. While the code is no less correct using an if-then-exit pattern, personally, I find it more difficult to read, and so I'd say it's neither always perfectly ok, nor much clearer. I'd usually rather duplicate some code to initialize the condition.

So, yes, I guess we'll agree to disagree. smile

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu