[Baypiggies] ctypes presentation material online
Ken Seehart
ken at seehart.com
Fri May 12 23:18:31 CEST 2006
Unfortunately there is nothing wrong with the expression string + 1.
It's just pointer arithmatic.
If string is a char *, then string+1 is that string with the first
character ommitted (hence one character /shorter/ than the original string).
The problem below doesn't have a clear analogy in python. And static
type checking in python would not pertain to any analogous problem in
python. Everything about this kind of problem is very language specific.
I'm actually a bit of a skeptic of the idea of using static type
checking in python. In practice it is rarely possible to obtain /any/
reliable type information on objects at compile time in python.
- Ken
Stephen McInerney wrote:
>The case below is a good argument for static type checking?
>Is there any type checker smart enough to understand that
>string + 1 is unlikely to have semantic meaning.
>(I know this is C but the concept is generic.)
>
>
>
>>From: Marilyn Davis <marilyn at deliberate.com>
>>
>>Yeh. Memory bugs are just terrible to find.
>>
>>I once had one in C code where I was mallocing space for a new string:
>>
>>buf = malloc(len(string + 1));
>>
>>My eyeball looked at that a jillion times before I realized that I had
>>a misplaced ')' and it should be:
>>
>>buf = malloc(len(string) + 1);
>>
>>The problem is that it crashed much later, after I wrote to the space
>>(and overwrote the memory), and then it finally crashed in another
>>call to malloc.
>>
>>
>
>
>_______________________________________________
>Baypiggies mailing list
>Baypiggies at python.org
>http://mail.python.org/mailman/listinfo/baypiggies
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/baypiggies/attachments/20060512/4518ba2b/attachment.html
More information about the Baypiggies
mailing list