Perl is worse!

Alex Martelli alex at magenta.com
Fri Jul 28 17:25:10 EDT 2000


"Paul Boddie" <paulb at infercor.no> wrote in message
news:3981BE50.23DB16C5 at infercor.no...
    [snip]
> > > whereas 1 + "foo" is meaningless to almost everyone except Perl
coders.
> >
> > No way -- it's perfectly valid in C, too, except that there it means the
> > constant-string "oo".  Really, truly, X my heart, I kid you not, check
it
> > out if you don't believe me (I wouldn't blame you for disbelieving
this!).
>
> I did do C before Python, and sometimes write the occasional C program, so
I am
> aware of this "interesting" possibility. However, I believe that the
result of
> adding 1 to "foo" is implementation dependent, as Cameron Laird pointed
out. (I

Nope -- it's perfectly defined by the C standard.  What IS implementation
defined (or even undefined, I forget) is what happens if somebody *stores*
new characters in an area defined as a string-literal (a strong "just don't
do that!" in C:-).

> don't recall the size constraints on the char type, however.)

7 bits and up, anything goes.  But everything else's size (except
for bit-fields, a peculiar oddity) is a multiple of char's size,
so the latter's size is often called a 'byte' (which need not be
the same thing as an 'octet', though it often is:-).

Not that this matter here: adding 1 to a pointer-to-X increments
the machine address that pointer indicates by sizeof(X) exactly.
sizeof(char) is 1, the unit of measure.


Alex






More information about the Python-list mailing list