J
john
Hi
We know that C has been through several revisions since it was first
created by Kernigan and Richie. One thing I don't understand is why some
of the opportunities for expansion present in the original C
specification have not been taken up in these subsequent revisions.
Here are two examples.
1. C does not have a ||= operator (or for that matter a &&= operator).
This is extremely useful and elegant in Perl for specifying default
values and it could work just the same way in C.
2. There are lots of operations that we often need to perform on pointers
to the same block of memory, e.g. find the max or min, or the average of
them, and many others. There are also lots of arithmetic operations that
are not currently defined for pointers, in fact only minus (ptrdiff_t) is
defined. So why not extend the syntax so that unused operators like +,
*, /, %, ^, &, etc would implement these useful operations.
For example, if / was average then this would lead to simpler code like
johns_search(int *first, int *last)
{
int *mid = first / last;
...
instead of a complicated expression with lots of terms.
We know that C has been through several revisions since it was first
created by Kernigan and Richie. One thing I don't understand is why some
of the opportunities for expansion present in the original C
specification have not been taken up in these subsequent revisions.
Here are two examples.
1. C does not have a ||= operator (or for that matter a &&= operator).
This is extremely useful and elegant in Perl for specifying default
values and it could work just the same way in C.
2. There are lots of operations that we often need to perform on pointers
to the same block of memory, e.g. find the max or min, or the average of
them, and many others. There are also lots of arithmetic operations that
are not currently defined for pointers, in fact only minus (ptrdiff_t) is
defined. So why not extend the syntax so that unused operators like +,
*, /, %, ^, &, etc would implement these useful operations.
For example, if / was average then this would lead to simpler code like
johns_search(int *first, int *last)
{
int *mid = first / last;
...
instead of a complicated expression with lots of terms.