M
Michael Tsang
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Assume that you have written a library using plain standard C99 and you want
to extend the functionality of a function. However, the added functionality
requires some optional parameters. For example, in C++, you can change:
void foo(int a);
to
void foo(int a, const char *b = NULL);
and modify the definition. In this way, new functionality is added to foo
and the compatibility of old code (which calls foo with a single parameter)
is retained. However, in C99, you can't do this. You may consider writing a
new function in the library, however, if the new functionality only requires
very little changes in the original function, you may end up duplicating a
lot of code in the old function and the new function, and one more
identifier is now added into the namespace. Therefore, when more and more
functionality is added into the library, more and more identifier is added
and the code is finally unmaintainable (due to lots of duplicated code). A
new library version is therefore needed.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkr5dTYACgkQG6NzcAXitM+n9wCgjlIMDxlzojl8vuEF44zcIFfX
+GsAn2JqI340NGAUyBADwjNko9noH2Cy
=GpjM
-----END PGP SIGNATURE-----
Hash: SHA1
Assume that you have written a library using plain standard C99 and you want
to extend the functionality of a function. However, the added functionality
requires some optional parameters. For example, in C++, you can change:
void foo(int a);
to
void foo(int a, const char *b = NULL);
and modify the definition. In this way, new functionality is added to foo
and the compatibility of old code (which calls foo with a single parameter)
is retained. However, in C99, you can't do this. You may consider writing a
new function in the library, however, if the new functionality only requires
very little changes in the original function, you may end up duplicating a
lot of code in the old function and the new function, and one more
identifier is now added into the namespace. Therefore, when more and more
functionality is added into the library, more and more identifier is added
and the code is finally unmaintainable (due to lots of duplicated code). A
new library version is therefore needed.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkr5dTYACgkQG6NzcAXitM+n9wCgjlIMDxlzojl8vuEF44zcIFfX
+GsAn2JqI340NGAUyBADwjNko9noH2Cy
=GpjM
-----END PGP SIGNATURE-----