[bind10-dev] A plea for Name() rather than Name(".")
Christos Zoulas
christos at zoulas.com
Thu Feb 18 22:58:24 UTC 2010
On Feb 18, 2:44pm, jinmei at isc.org (JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKE) wrote:
-- Subject: Re: [bind10-dev] A plea for Name() rather than Name(".")
Just on the language issues:
| Unfortunately C doesn't have a strong support for prohibiting such an
| error prone style in that
| - (until C99) variables must be defined at the beginning of a function
Let's be precise here please (the point is moot anyway because we have
c99), but since you brought it up: You can always introduce a scoping
block in the middle of your code and add declarations in the beginning
of it so it is not really a serious limitation.
{
int x;
}
In ways actually declaring variables in the middle of your code
can introduce more bugs specially if you use goto:
if (error)
goto out;
int i = 0;
out:
return i;
| - we cannot enforce how a variable is initialized (i.e. as long as the
| type matches we can basically assign any value to a variable of that
| type; we can also define a structure variable and only partially
| initialize its content)
It is a matter of programming style. If you are willing to lose a
little efficiency you can always hide the implementation and write
constructor and destructor functions in c.
typedef struct foo foo_t;
foo_t *x = create_foo(args);
doit_with_foo(x);
destroy_foo(x);
I don't disagree with the c++ implementation choice, but personally I would
have preferred to have a java implementation instead...
christos
More information about the bind10-dev
mailing list