[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Trivial suggestion



It just occurred to me that we have a whole bunch of getFoo routines
scattered all through the code that merely do fetchFoo and blast if it
is NULL. It might be a bit cleaner to have a single global routine to
do just this.

SPTR(Heaper) OK(Heaper * something) {
	if( something == NULL ) {
		BLAST(FETCH_FAILED);
	}
	return something;
}

e.g. text = CAST(XuText, OK(keymaster->fetchWaldo (bertID)));
	
I can see two main problems with this, neither of them serious.
First, this routine would return a Heaper * and have to be cast -- but
a lot of getFoos have to be cast anyhow (e.g. table & stepper fetch).
Second, the exception is less specific -- FETCH_FAILED instead of
NOT_IN_TABLE or STEPPER_EMPTY -- but a macro for OK could encode the
file and line number of the call to give even more useful information.

This is no great priority, but it would eliminate a dozen or two
messages from the interface.
	--ravi