Re: Linux-asm (was A patch for linux 2.1.127)

H. Peter Anvin (hpa@transmeta.com)
20 Nov 1998 18:57:54 GMT


Followup to: <m0zghzv-0007U7C@the-village.bc.nu>
By author: alan@lxorguk.ukuu.org.uk (Alan Cox)
In newsgroup: linux.dev.kernel
> >
> > > putchar(0[hw]);
> > > hw=+1;
> >
> > Is this just me or does this sound a tiny, little
> > bit like rpn? Or Australia. Just praise the
>
> The thing about B being typless is
>
> x[y] and y[x] are the sme
>

This is also true in C (but not C++) since x[y] is defined as *(x+y)
regardless of the types of x and y. Note that addition of pointers is
commutative, although one operand has to be pointer and the other
integral.

On C++ this is not true in general if x is a class type, since the
former would invoke x.operator[](y), whereas the latter would be
interpreted as *(x.operator+(y)) and there ain't no law that says they
have to be the same, and generally won't be.

-hpa

-- 
    PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD  1E DF FE 69 EE 35 BD 74
    See http://www.zytor.com/~hpa/ for web page and full PGP public key
        I am Bahá'í -- ask me about it or see http://www.bahai.org/
   "To love another person is to see the face of God." -- Les Misérables

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/