1. request for source change
- Posted by Bernie Ryan <xotron at bluefrog.com> Jun 05, 2007
- 544 views
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. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
2. Re: request for source change
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 05, 2007
- 505 views
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:
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
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 Regards Pete
3. Re: request for source change
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 05, 2007
- 504 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
4. Re: request for source change
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 06, 2007
- 494 views
Robert Craig wrote: > I don't agree that this warning is "utterly pointless". So I gathered > 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, Maybe, in 1999, but I was not around here then. > and it still has some > value in the rare situation where a function with side-effects > might be skipped. Do you have any convincing example where that is so? > > 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.) OK, for 3.1.1, add the following to parser.e, ~line 1663:
elsif equal(option, "warning") then OpWarning = on_off tok=next_token() if tok[T_ID]!=STRING then putback(tok) updateWarningSkipList(0,on_off) else updateWarningSkipList(tok[T_SYM],on_off) end if
(admittedly using next_token() for this uses up an extra symtab entry) and to error.e, ~line 26:
sequence wSkip wSkip={} global procedure updateWarningSkipList(object mstr, boolean flag) integer k if mstr!=0 then mstr = SymTab[mstr][S_OBJ] end if if atom(mstr) or length(mstr)=0 then wSkip={} else OpWarning=TRUE k=find(mstr,wSkip) if flag then -- with warning "xxx" if k then wSkip=wSkip[1..k-1]&wSkip[k+1..$] end if else -- without warning "xxx" if not k then wSkip=append(wSkip,mstr) end if end if end if end procedure global procedure Warning(sequence msg) -- add a warning message to the list sequence p if OpWarning then for i=1 to length(wSkip) do if match(wSkip[i],msg) then return end if end for ... as before
Works fine as far as I can tell, and treats
with warning "" without warning ""
as if the "" were not present. Regards, Pete
5. Re: request for source change
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 06, 2007
- 493 views
I wrote: > > Robert Craig wrote: > > (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.) Ah, I forgot that. I assume it is just a trivial save/restore of wSkip in IncludePush()/IncludePop(), and obviously I have not tested that. Pete
6. Re: request for source change
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 06, 2007
- 510 views
Pete Lomax wrote: > I wrote: > > > > Robert Craig wrote: > > > (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.) > Ah, I forgot that. I assume it is just a trivial save/restore of wSkip in > IncludePush()/IncludePop(), > and obviously I have not tested that. If you register with SourceForge, I'll give you full developer access. Then you can check out official source, add this change, test it well, and check the new source back in. It's pretty easy using TortoiseSVN for Windows. You can also document the change, or leave that up to me. You could start anytime, but it might be better to wait until 3.1 is officially done and checked in. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com