Re: request for source change
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 05, 2007
- 503 views
Pete Lomax wrote: > Bernie Ryan wrote: > > How about doing away with the short-circuit warning message. > > The warning is a pain in the neck. > > Why should a user have to : > > 1. Rewrite their code. > > 2. Place without warning around their code. > > Please don't suggest placing without warning at the top of my program. > > > > After all short-circuit code is not a bad programming practice and > > some times is desired. > > > > At least you could have a without short_circuit_warning option. > > Just get rid of it. This utterly pointless and extremely annoying warning does > not even work properly anyway: > }}} <eucode> > integer id id=0 > function f() id=3 return id end function > function g(integer i) return i end function > if id or f()=0 then end if > if id or g(0) then end if > if id or g(f()) then end if > </eucode> {{{ > You only get a warning on the first if statement, and none if you comment that > one line out, despite the fact that the self same f() can just as easily be > short-circuited on the third if statement. Which as I have also pointed out > is NOT to be taken as encouragement to make matters worse. > > Anyway, it looks pretty easy to remove, ~line 442 in parser.e I don't agree that this warning is "utterly pointless". It was important at the time that Euphoria switched over to short-circuit evaluation, in order to help spot subtle errors in now-broken old code, and it still has some value in the rare situation where a function with side-effects might be skipped. Perhaps what we need is a way to suppress specific warnings. For example, if you get a short-circuit warning and you determine that it's a harmless situation, you could say something like: without warning "short-circuit" or in general, without warning "string of chars" where any warnings that contain the specified string will be suppressed (according to the usual scope of without warning, which is limited to the file it appears in, from that point forward, and any included files.) If you specify multiple without warning statements, a list of filter strings will be maintained by the front end. Later, when you say: with warning all warnings will be enabled. Or perhaps you could specifically say: with warning "short-circuit" or with warning "not used" etc. This would help document for others, which specific warnings you are suppressing, and in which parts of your program. I would go along with something like this, if someone else is willing to implement it, and no one has any better idea, or serious objections. (But not for 3.1 - it's too late.) Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com