Pure, const, etc

Koroskin Denis 2korden at gmail.com
Mon Jun 23 10:51:13 PDT 2008


On Sat, 21 Jun 2008 03:53:24 +0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Stuff D will do:
> http://lwn.net/Articles/285332/
>
> Bye,
> bearophile

Nice. But can't see why strlen is pure (in the article):
int __attribute__((pure)) strlen(const char* string) {
	return /* you know what */;
}

char* someString = "Hello";
int len1 = strlen(someString);
someString[4] = 0;		// guess what is it now? :)
int len2 = strlen(someString);	// input is *not* changed

One thing they lack is an invariant type.
And the main problem is that it is not standardazed, so it is not portable  
across compilers.



More information about the Digitalmars-d mailing list