Re: "Nasty" bug

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

Anyway, for some reason, in all the coding I have done, the problem has never presented itself before.

Same here. I'm not sure if this counts as a bug, or simply a side-effect of the logic of the code parser. There's a logic error in the code parser because there's a logic error in the code that was written. Euphoria doesn't, for better or worse, tell the user what "good" code should be. This is one of the rare examples where writing bad code leads to weird side-effects and undefined behavior.

If you're looking for a solution to avoiding this problem, I have but one word: abstraction. If you need to store data in memory and manipulate it elsewhere, do yourself a favor and write a library with all of the functions required to manage the data without having to touch the variable(s) that holds the data directly.

This problem would have continued unnoticed had the original author of the code written it in such a way as to conceptualize the actions in code first. I have to imagine that the code posted was merely an example to demonstrate the problem, but that worries me even more as to what the author's original code looks like!

Overall, I don't if this something that should be fixed or not. On one hand, yes it's a weird logic error. But on the other, the expected behavior is undefined. If we can detect the problem in the parser, then maybe we should just issue a warning, like Warning { side_effect }: lhs_var will not be updated due to side-effect in function func_name.

-Greg

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

Search



Quick Links

User menu

Not signed in.

Misc Menu