This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libgloss/arm/libcfunc.c: alarm [PATCH]


On 7/15/05, Dave Korn <dave.korn@artimi.com> wrote:
>   I'm in agreement with Nick.  It's too obfuscatory.  At a quick glance
> over, it reads very much like "return errno {stuff...}"; the return
> statement is too far separated from the actual thing being returned (the
> -1), and as in writing, if your verb and noun are too widely separated, the
> stuff in between makes the reader lose track and reduces the clarity of the
> sentence.  If you want to group two statements together conceptually without
> losing clarity, you can still put them on separate lines but group them
> together with a blank line before and/or after.

I prefer to think of the noun as a tuple of the return value and the
error number, where errno is really just a hack around the fact that C
doesn't allow you to easily return tuples. So, the return statement is
really...
	return (-1, ENOSYS);
... and upon this sentence's translation to C it becomes...
	return errno = ENOSYS, -1;
This actually makes me think there might be a place for a macro to
return a (return value, errno) tuple.
	#define E(value,error) (errno = (error), (value))
	return E(-1, ENOSYS);
Although I do prefer the look of the latter, I still prefer the former
overall because it doesn't require the casual reader to hunt down the
definition of E to understand the sentence -- although I'd bet he or
she would have a pretty good guess.

Cheers,
Shaun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]