On 2008-11-21 07:43:47 -0500, bearophile <[EMAIL PROTECTED]> said:
Just found this cute article on Reddit: "GCC hacks in the Linux
kernel", by M. Tim Jones:
http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/index.html
Here are few comparisons between those featuers are D ones.
The range syntax that can be used in switch statements and array
defintions is cute:
1 ... 7
D2 already has a range syntax, it just needs to be extended for other
purposes (and adding a stride too may be useful, but it's less
important).
I've wanted that range thing in switch statements some time ago while
writing a parser working with character ranges.
Zero-length arrays are available in D, but the following code (used in
C to define a struct with ane or two variable-length arrays) can't be
used, because of array bound controls:
struct iso_block_store {
atomic_t refcount;
size_t data_size;
quadlet_t data[0];
};
Just use data.ptr if you want to escape the bound checks.
But what would be really great is some way to parametrize the length of
data to data_size. That's not very high on my wish list though.
This looks interesting for D too, from the article:
__attribute__((warn_unused_result)) forces the compiler to check that
all callers check the result of the function. This ensures that callers
are properly validating the function result so that they can handle the
appropriate errors.
Do we need that when we have exceptions in D?
--
Michel Fortin
[EMAIL PROTECTED]
http://michelf.com/