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

Null pointers are the billion dollar mistake

Name: Anonymous 2017-02-02 10:34

@davetchepak "What can C# do that F# cannot?"
NullReferenceException :-)

Educating the imperative gorillas about sum types:

https://chadaustin.me/2015/07/sum-types/

Name: Anonymous 2017-02-02 19:58

>>20
C, C++, Java, C#, Python etc still do not[have tagged unions].

enum ShapeKind { Square, Rectangle, Circle };

struct Shape {
int centerx;
int centery;
enum ShapeKind kind;
union {
struct { int side; }; /* Square */
struct { int length, height; }; /* Rectangle */
struct { int radius; }; /* Circle */
};
};

int getSquareSide(struct Shape* s) {
assert(s->kind == Square);
return s->side;
}

void setSquareSide(struct Shape* s, int side) {
s->kind = Square;
s->side = side;
}

/* and so on */

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