Re: Request for Comment: Callable CRM114 Classifiers (libcrm114) --> OOBC

Eugene Crosser <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <[email protected]>
Ger Hobbelt wrote:

> Nothing overengineered: the code is currently littered with stuff like this:
> 
> ----------------------------
>     if (internal_trace)
>         fprintf(stderr, "executing a LEARN\n");
> ----------------------------
> 
> which I'd rather see turn into this:
> 
> ----------------------------
>     this->trace_callback(this, CRM_DBG_INTERNAL, "executing a LEARN\n");
> ----------------------------

Well, as to me, I quite like your quasi-OO approach. Still the macro
stuff in your examples looks a bit too verbose/complicated to me...

And, I'd rather not expose the CTX structure to the user of the API, as
in your examples. Instead of

	this->trace_callback(this, ...)

the user could write

	crm114_trace(this, ...)

(presuming 'this' is the 'context' type.) The function itself could be like

	void crm114_trace (crm114_ctx_t this, ...) {
		if (this->trace_callback) {
			this->trace_callback(this, ...)
		} else {
			fprintf(stderr, ....);
		}
	}

this way you will have more freedom to play with the structure without
the user noticing. And, it looks more concise and possibly less scary
;-) [Also, the cost of initial implementation may be lower.]

> typedef void crm_trace_callback_t(crm_config_t *obj, int level, const
> char *fmt_msg, ...);
> ----------------------------
> (which, incidentally, you can augment in GCC (without hurting
> portability to other compilers) to tell GCC he should check this
> callback interface as if it were a regular printf() style formatted
> vararg, so you'd get nice warnings when screwing up your %d, %s, etc.
> elements)

Wow, I did not know that! How'd you do that?

Eugene

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Crm114-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crm114-general
signature.asc (application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI6SuRfrw/cIw6UWkRAkBpAJ9MlWGVy466uF/AGErMa3Z2KbWEqQCgtiNh
EKbo680AJDbzKZYrscAylWc=
=BOux
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.