Re: GtkArg typesafety

On Tue, Jan 04, 2000 at 12:02:05PM -0500, Havoc Pennington wrote:
> George <> writes: 
> > #define MY_PERSON_ARG_NAME(arg)    	"name",(gpointer)(arg)
> > #define MY_PERSON_GET_ARG_NAME(arg)	"name",(gpointer *)(arg)
> > #define MY_PERSON_ARG_DOB(arg)    	"dob",(glong)(arg)
> > #define MY_PERSON_GET_ARG_DOB(arg)	"dob",(glong *)(arg)
> > #define MY_PERSON_ARG_DOD(arg)    	"dod",(glong)(arg)
> > #define MY_PERSON_GET_ARG_DOD(arg)	"dod",(glong *)(arg)
> IMO this is much extra complexity for very little gain (it avoids the
> "0" is not a double problem, but that's all really; it doesn't solve
> the problem of passing entirely the wrong type or getting const-ness
> wrong). And it ruins the nice syntax which is 85% of the point of
> arguments.

Not just that,  I've been bitten by this a lot of times in fact, mostly by
the not-a-double problem, but there are other things that can go wrong.  But
even otherwise, I've forgotten to correctly cast a lot of things.

Anyway if you look at the lower solution with wrapper functions, it gains us
FULL type safety just like a function call.

Plus I don't think it's all that ugly, consider:





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