[farther OT] Re: Why Is Escaping Data Considered So Magical?

John Nagle nagle at animats.com
Thu Jul 1 13:17:02 EDT 2010


On 7/1/2010 8:36 AM, Mel wrote:
> Nobody wrote:
>> On Wed, 30 Jun 2010 23:40:06 -0600, Michael Torrie wrote:
>>> Given "char buf[512]", buf's type is char * according to the compiler
>>> and every C textbook I know of.
>
> References from Kernighan&  Ritchie _The C Programming Language_ second
> edition:
>
>> No, the type of "buf" is "char [512]", i.e. "array of 512 chars". If you
>> use "buf" as an rvalue (rather than an lvalue), it will be implicitly
>> converted to char*.

    Yes, unfortunately.  The approach to arrays in C is just broken,
for historical reasons.  To understand C, you have to realize that
in the early versions, function declarations weren't visible when 
function calls were compiled.  That came later, in ANSI C. So
parameter passing in C is very dumb.  Billions of crashes due
to buffer overflows later, we're still suffering from that mistake.

    But this isn't a Python issue.

					John Nagle



More information about the Python-list mailing list