Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

lol wut

Name: Anonymous 2007-04-07 5:40 ID:W8msT6i7

What the hell does '->' do? I see it in C and C++ all the time and it confuses the shit out of me.

Name: Anonymous 2007-04-07 5:46 ID:mn8bjHdM

It is used to create lambda functions. For example instead of saying:

bar xs = map foo xs
    where foo = ...

You can use a lambda function like this:

bar xs = map (\x -> ...) xs

Name: Anonymous 2007-04-07 5:49 ID:zwV13Qwd

What the fuck are you doing reading source code if you clearly have no idea how to program? '->' is simple class/pointer shit.

Name: Anonymous 2007-04-07 5:50 ID:zwV13Qwd

Also,

POLYMORPHISM. Do you use if fucker?!

Name: Anonymous 2007-04-07 6:05 ID:W8msT6i7

>>3
That's like asking someone why they're reading books to learn English.

I R READ SRC CODE CUZ I LERN 2 PROGRM LULZ.

Also, >>4 doesn't actually know what it is, he just read a general description of it's use, and likes to wave his (imaginary) e-p33n around to make the other anonymi think he's smart. Cause if it's so simple, you could explain it, or link me to something that does explain it.

>>2
I appreciate it, but I have no idea what you're talking about.

Name: Anonymous 2007-04-07 6:12 ID:uSujjygU

>>5
(\a1 a2 ... -> ...) ... == let f a1 a2 ... = ... in f ...

hope that helps!

Name: Anonymous 2007-04-07 6:24 ID:zwV13Qwd

>>5
Hey, dumb shit. I hate to break it to you, but >>2 isn't helpful at all because that's not C or C++. I can see you're doing a great job learning those languages.

Also, simply searching 'C++ and polymorphism' on google would lead you to many results explaining this common and simple programming technique. But before you do that, you need to learn the basics and not act like a dumbass. If you don't know what a 'class' or OOP is, you need to go back to your textbook and start reading, because you're not even to novice level yet. Essentially, UR DOING IT WRONG. You can't learn a language by only reading source code. Go buy a good book and READ IT, instead of coming here like some dumb nub thinking he's entitled to full length explanations to every one of his dumb ass questions.

Name: Anonymous 2007-04-07 6:28 ID:uSujjygU

>>You can't learn a language by only reading source code.

Only true for unreadable languages like C, C++, Java, etc.

Name: Anonymous 2007-04-07 6:30 ID:KB7J4K4N

the -> operator is used to access members and methods of pointers to aggregate types (structs/classes)

Name: Anonymous 2007-04-07 8:05 ID:W8msT6i7

>>9
A simple, concise answer to a simple, concise question? IN MY /PROG/? It's less likely than you think. Thanks.

>>7
I lol'd. I think you should spend less time flaming people about a subject you know very little about, and spend more time fapping. Essentially, LURK MOAR.

>>6
Again, I appreciate it. Keep up the good work!

Name: Anonymous 2007-04-07 8:24 ID:uPS8IUFm

READ K&R BITCH

p->member is like (*p).member

Name: Anonymous 2007-04-07 8:42 ID:fd+lWorM

>>11
Since pointers themselves don't have members, why couldn't they have just made p.member be equivalent to (*p).member?

Name: Anonymous 2007-04-07 8:56 ID:Za/DvjYq

Dereference operator FTW!

Name: Anonymous 2007-04-07 9:59 ID:rid8r4WJ

>>12
Dot operator is for and only for finding members of the current variable. It matches the design of everything else in C: keeping the language clean.

Do we really suffer for it? I see an expression like p->member and I can immediately tell that p is a pointer, without fishing out the declaration.

>>10
Not knowing one of the core operators of the C language, I don't think you're entitled to tell anybody to lurk more, no matter how much of a jerk they are to you.

Name: Anonymous 2007-04-07 10:21 ID:9sPBSwID

The -> operator is like "no" in Japanese, except that the left side is a pointer rather than the "outer" thing.

Name: Anonymous 2007-04-07 10:56 ID:fd+lWorM

>>14
To understand what x++ does you'd have to know the type of x; I really don't see why the dot operator would have to be any different.

You 'suffer' because it's harder to type, and you're forced to make a completely unnecessary distinction. Ocaml has different operators for integer and floating point arithmetic, but C doesn't need that since it has explicit typing. Same goes for '.' vs '->'.

If the choice for separate operators was really made to 'match the design of everything else' in the language, they should at least also have split the int/float division operator (like '/' and 'div' in Pascal).

Name: Anonymous 2007-04-07 11:43 ID:o/w5ASkf

-> :

This operator is to access to the members/methods of a pointer to  a struct/class.

So :

#include <stdio.h>

typedef struct Foo
{
int a;
int b;
int c;
}Foo;

int main(int argc,char *argv[])
{
Foo *pointer = malloc(sizeof(Foo));
pointer->a = 40;
printf("%ld\n",pointer->a);
free(pointer);
Foo NotAPointer;
NotAPointer.a = 30;
printf("%ld\n",NotAPointer.a);
return 0;
}


Here you go.

Name: Anonymous 2007-04-07 12:05 ID:uj/86FgA

int main (void) {
    struct {int whut} *d;
    int b;

    return d->whut<-b;
}

Name: Anonymous 2007-04-07 12:16 ID:uPS8IUFm

>>12
POINTERS TO STRUCTURES IDIOT, POINTERS TO STRUCTURES

Name: Anonymous 2007-04-07 15:28 ID:zwV13Qwd

>>10
| A simple, concise answer to a simple, concise question? IN MY /PROG/?

There's much more to the operator than simply dereferencing a pointer to a structure or class. It's used in polymorphism which is a very basic, but powerful technique that could not be adequately explained on /prog/. Once again, stop asking stupid questions and GO READ A BOOK.

| I think you should spend less time flaming people about a subject you know very little about

I flamed you because you're an idiot that simply refuses to research anything on his own. Not only should you have already known this, because it's very basic, but I did give you an answer. I told you it had to do with polymorphism, but instead of going and researching it you flamed ME because I didn't spend 30 minutes typing some long ass explanation that you could have simply read out of any C++ programming book, since you're a dumb nub that flatly refuses to look up answers yourself.

| >>6
| Again, I appreciate it. Keep up the good work!

Once again, that's not C or C++ dumb ass.

Name: Anonymous 2007-04-07 16:13 ID:uSujjygU

>>18
OH GOD WHAT THE FUCK DOES THAT DO?

Name: Anonymous 2007-04-07 16:15 ID:Heaven

>>21
its invalid, you dumb fuck

Name: Anonymous 2007-04-07 17:56 ID:uSujjygU

>>22
Well how the fuck am I supposed to know that?

Name: ee™ 2007-04-07 18:05 ID:NntBnN5z

>>23
LOL

Name: Anonymous 2007-04-07 18:25 ID:dctIsRWI

>>22
It's only invalid because it's missing a semicolon after int whut, dipshit.  Also, it's just checking whut < (-b).

Name: Anonymous 2007-04-07 18:34 ID:KB7J4K4N

>>25
enjoy ur segfaults

Name: Anonymous 2007-04-08 1:16 ID:WS8IYPt+

return d->whut < -b;

Name: Anonymous 2007-04-08 11:56 ID:Heaven

return(~-d->whut--<<~b--);
kthx

Name: Anonymous 2007-04-08 11:59 ID:lbytrsLi

>>28
let's make it trigraphcore

return(??--d->whut--??!??-!b--);

Name: Anonymous 2007-04-08 12:47 ID:Heaven

return(-~d->whut--|~b?~!d->whut:!++b?d->whut^~!b:!b&~(*d).whut);
h0h0

Name: Anonymous 2007-04-09 5:34 ID:923uqFZv

lol wut?

Name: Anonymous 2007-04-10 2:03 ID:U4S96E3a

>>31
Posts >>27-30 are pussy shit. If you can't understand them, you need to kill yourself.

Name: Anonymous 2007-04-10 2:28 ID:gVztOA7D

>>32
LOL K

Name: Anonymous 2009-01-14 14:13

FGGFDS

Name: Anonymous 2012-03-25 10:12

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

Name: Sgt.Kabu몓kiman䚯唰 2012-05-29 0:03

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List