Re: request for source change

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

Robert Craig wrote:
> I don't agree that this warning is "utterly pointless".
So I gathered blink
> 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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu