/g/ - Technology

install openbsd

[Make a Post]
[X]





C pointer dereferencing Nanonymous No.1660 [D][U][F][S][L][A][C] >>1712 >>2019 >>2024 >>2038
File: 4fbd423e8f3a28a900bd67376e496e2c0122a4a02184f14bbf22516e19695c62.jpg (dl) (270.04 KiB)

As we all know (hopefully), pointer dereferencing in C can be done in one of three ways.

*ptr or 0[ptr]
ptr[9]
ptr->elem

Why can't we just unify those three methods into one, using brackets just like in (nasm syntax) assembly? It would be just like if the 0 in 0[ptr] could be omitted by default. The dot syntax for struct field access could be replaced by -> (just because it looks better imo). So those three operations could be written as:

[ptr]
[ptr+9]
[ptr]->elem

Anyone have a problem with this?

Nanonymous No.1681 [D] >>1693

Hello, Happase

Nanonymous No.1693 [D][U][F] >>1712
File: 1eb5f5f46588cdb15bd409a4ff18b5e2ba1a457c4a8ffde5f734af75da2b50a9.png (dl) (527.98 KiB)

>>1681
What? Answer my fleurcking question faggot. And no I am not "Happase" whoever this person is.

Nanonymous No.1712 [D] >>1715 >>2024

>>1660
> [ptr]->elem
it would be [ptr].elem, but otherwise this looks good. What about syntax for taking a reference?
>>1693
ok happase

Nanonymous No.1715 [D]

>>1712
>[ptr].elem
no, my point is that you would get rid of the . syntax and replace it with -> because it's easier to read and looks better, and also frees up the dot as a sigil for anything else you want to use it for. idk it's just my personal preference.
>What about syntax for taking a reference?
just keep it as &
so [&var] would be the same as var

Nanonymous No.2019 [D]

>>1660
*(ptr + elem)
*(ptr + 0) is the same as *ptr

Nanonymous No.2024 [D] >>2026 >>2030

>>1660
That's actually a good idea. And >>1712 is right, use the dot (1 less char counts).

Nanonymous No.2026 [D] >>2041

>>2024
>DURR IT SAVES BYTES!!!
-> looks better than . and should replace it. It's not as if the uncompiled source code size matters very much.

Nanonymous No.2030 [D] >>2041

>>2024
>1 less char counts
>in the fucking source code
>and reduces readability to boot
You Have Autism

Nanonymous No.2038 [D] >>2039

>>1660 I wanna rape this Japanese girl!

Nanonymous No.2039 [D][U][F] >>2040
File: 0d9873937388c493f3c9b607b6dd5a84a17a0a88321565a84f6b85658b216274.png (dl) (109.14 KiB)

>>2038
Well, here's her email: 37564N@memeware.net

Nanonymous No.2040 [D]

>>2039
When the meme
So supreme
It make a nigga
Wanna scream

Nanonymous No.2041 [D] >>2043

>>2026
>>2030
It saves columns, retards.
>looks better
No.



Nanonymous No.2043 [D] >>2084

>>2041
>MUH COLUMNS MUH SKREEN
Do yourself a favor and code yourself a nice 640x480 console driver which has over 80cols, nigger. Terry Davis did it, so can you.
>No.
Yes.

Nanonymous No.2084 [D]

>>2043
>he thinks people use the 80 column limit because of teletype limits
Typical java pooper.