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

Pages: 1-4041-

EXPERT C OPERATOR REIMPLEMETATION

Name: Anonymous 2014-04-12 8:41


#include <stdio.h>

bool
or (bool a, bool b)
{
return a ? true : (b ? true : false);
}

bool
and (bool a, bool b)
{
return a ? (b ? true : false) : false;
}

bool
not (bool a)
{
return a ? false : true;
}

Name: Anonymous 2014-04-12 8:50

#include <stdio.h>
why

Name: Anonymous 2014-04-12 8:51

/prog/read/1397299302/1:4:1: error: unknown type name ‘bool’
bool
^
/prog/read/1397299302/1:5:5: error: unknown type name ‘bool’
or (bool a, bool b)
^
/prog/read/1397299302/1:5:13: error: unknown type name ‘bool’
or (bool a, bool b)
^
/prog/read/1397299302/1:10:1: error: unknown type name ‘bool’
bool
^
/prog/read/1397299302/1:11:6: error: unknown type name ‘bool’
and (bool a, bool b)
^
/prog/read/1397299302/1:11:14: error: unknown type name ‘bool’
and (bool a, bool b)
^
/prog/read/1397299302/1:16:1: error: unknown type name ‘bool’
bool
^
/prog/read/1397299302/1:17:6: error: unknown type name ‘bool’
not (bool a)
^

Name: Anonymous 2014-04-12 8:55

>>2-3
sorry, I made a fatal mistake. I wannted to include stdbool.h

here is a fixed version

#include <stdbool.h>

bool
or (bool a, bool b)
{
return a ? true : (b ? true : false);
}

bool
and (bool a, bool b)
{
return a ? (b ? true : false) : false;
}

bool
not (bool a)
{
return a ? false : true;
}

Name: Anonymous 2014-04-12 12:45

#include <iso646.h>
#include <stdbool.h>
#include <stdio.h>

int main(void)
{
bool one = true;
bool two = false;

printf("%d, %d, %d\n", (one or two), (one and two), (not one));
return 0;
}


$ gcc -o a a.c -std=c99 && ./a
1, 0, 0

Name: Anonymous 2014-04-12 13:30

I think bool as a type is worthless. All of this shit is just as intuitive using int. I think Ken even said himself you shouldn't be using one byte types unless it's a large array and you need to save space. There was a discussion about this on the old /prog/ and the consensus was that using stdbool.h was for idiots.

Name: Anonymous 2014-04-12 13:40

>>6
I think Ken even said himself you shouldn't be using one byte types
why?

Name: Anonymous 2014-04-12 13:54

>>6
But Bool is a 0-byte type.

data Bool = False | True

A reference to a bool points to a fixed location in memory that is shared for all bools.

Name: Anonymous 2014-04-12 13:54

>>7
Because of all the type conversions that have to be done. It was a quote off of usenet but he was addressing a question which asked when to use each integral type.

His response was along the lines of:
long if you need a larger range than int will provide
char if you desperately need to save memory
and int otherwise

Name: Anonymous 2014-04-12 14:07

>>8
References cost zero bytes now? Frozenvoid, is that you?

Name: Anonymous 2014-04-12 14:28

>>9
#undef bool
#define bool int

done

Name: Anonymous 2014-04-12 14:43

>>11
Then you're not using stdbool anymore which is fine I guess but now you have to justify why using the bool name is better than just using int.

Name: Anonymous 2014-04-12 15:00

>>8
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
printf("%lu\n", sizeof(bool));
return 0;
}


$ gcc -o a a.c -std=c99 && ./a
1


Care to tell me what type of machine you're running on where the above prints `0' instead?

Name: Anonymous 2014-04-12 15:02

>>12
because the word bool reminds me of anuses

Name: Anonymous 2014-04-12 15:03

>>13
"%lu\n"
wrong! %zu is for size_t

Name: Anonymous 2014-04-12 15:06

>>15
Right, my bad. I've been thinking too much in C90, in which %z doesn't exist.

Name: Anonymous 2014-04-12 20:50

c89 master race

Name: L. A. Calculus 2014-04-18 21:33

>>1
WAT R U A FUCKIN STAK BOI? YA DONT UNDERSTAND SEQUENCE POINTS, YA DONT KNO HOW TO USE bool, N YAINT RED DA FUKIN STANDARD.

U'D HAV BETTER LUCK IMPLEMENTING DIS SHIT WITH MACROS, BUT DEN I DUNNO Y YA WUD COS ITS RETOIDED.

>>16
IF U WANT C90 SUPPORT U CAN KEEP DA FORMAT SPECIFIER N CAST TO unsigned long.

WEN R U RETOIDS GONNA REED DA FUKIN STANDARD?

Name: Anonymous 2014-04-18 22:41

>>18
*hops around in circles with joy*
*grabs popcorn*

Name: Anonymous 2014-04-18 23:32

>>18
Let's see a trip to verify that you're the real deal. If you don't want to post it here, then make a new one for here, then post on one of the archived imagetumblrs with the old trip announcing the new trip.

Name: L. A. Calculus !jYCj6s4P.g 2014-04-19 0:01

>>20
ILL USE A NEW TRIPCODE. SEE IF DIS SHIT WORKS 1ST.

Name: L. A. Calculus !jYCj6s4P.g 2014-04-19 0:11

>>20
APPARENTLY IM BANNED ON 4CHAN, SO FUK DAT. EVEN THO UR SUSPICIOUS NOW, U'LL WARM UP TO ME IN TIME.

Name: L. A. Calcoolus !Ep8pui8Vw2 2014-04-19 0:12

DIS WORKS FINE LOL. OK RETOIDS THIS IS OFFICIALLY MY NEW TRIPCAWD.

Name: L. A. Calculus !jYCj6s4P.g 2014-04-19 0:17

>>23
SINCE WEN DO I SPELL TRIPCODE LIKE A FUCKIN KAWAII SAFARI RETOID? OR CLUTTER MY WRITING WITH "LOL" LIKE ONE OF U FUKIN MEME-SPOUTIN SISSIES? U SOUND LIKE A FUCKIN BABY.

FEEL FREE 2 TRY AGAIN THO. IF U CAN ACCURATELY GET MY CHARACTER DOWN ILL BE IMPRESSED.

Name: Anonymous 2014-04-19 0:18

>>23
L. A.! I love you! Sadly joot closed world4ch
Anyway, did I done something bad? can you explain me what I did wrong at >>1?

Name: >>25 2014-04-19 0:20

I mean >>24

Name: L. A. Calculus !jYCj6s4P.g 2014-04-19 0:49

>>25
U NEED TO INCLUDE <stdbool.h> IF U WANT TO USE DA bool TYPE.

AS 4 UR MISUNDERSTANDING OF SEQUENCE POINTS, CONSIDER DIS:

int c = 23;

1 && (c = 24);


IN DIS CASE 24 IS STORED IN c. "1" IS EVALUATED N, BECOS "1" EVALUATES TRUTHFULLY, "(c = 24)" IS EVALUATED AFTER.

int c = 23;

0 && (c = 24);


IN DIS CASE 23 IS STORED IN c AND "(c = 24)" ISN'T EVALUATED, COS DA FIRST PART EVALUATES FALSELY.

IF WE SHIFT DIS OVER TO UR IMPLEMENTATION ...

int c = 23;

and(0, c = 24);


WE'LL FIND DAT 24 IS STORED IN c, EVEN THO DA FIRST PART OF DA EXPRESSION IS ZERO. DIS IS BECAUSE ALL OF DA ARGUMENTS TO and ARE EVALUATED BEFORE DA FUNCTION CALL IS MADE.

WITH DIS IN MIND, U SHUD REALISE DAT U CAN'T IMPLEMENT DESE OPERATORS AS FUNCTIONS. U CAN, HOWEVER, IMPLEMENT DEM AS MACROS, IN TERMS OF DA ?: OPERATOR ...

#define AND(a, b) ((a) ? !!(b) : 0)

?:, LIKE &&, INTRODUCES A SEQUENCE POINT. DA FIRST PART IS EVALUATED, IF IT'S TRUE DA SECOND PART IS EVALUATED, OTHERWISE DA THIRD PART IS EVALUATED.

FOR THOSE OF U WHO CODE IN LISP ALL DAY LONG, DIS CAN ACTUALLY BE SOMEWHAT USEFUL (THO A BIT CONFUSING FOR THOSE UNFAMILIAR) 4 DEFINING LISP-LIKE 'AND' SYNTAX:

#define AND(a, b) ((a) ? (b) : 0)

const char *s;
int c;

c = AND(1, 69);
/* c stores 69. */

c = AND(0, 69);
/* c stores 0. */

s = AND(1, "abc");
/* s stores a pointer to the first element of "abc". */

s = AND(0, "abc");
/* s stores a null pointer. */

Name: Anonymous 2014-04-19 0:59

>>27
U NEED TO INCLUDE <stdbool.h> IF U WANT TO USE DA bool TYPE.
That was a typo, sorry

AS 4 UR MISUNDERSTANDING OF SEQUENCE POINTS, CONSIDER DIS:
Thank you for explaining, I had totaly forgot about this

Name: Anonymous 2014-04-19 1:01

>>24
IF U CAN ACCURATELY GET MY CHARACTER DOWN ILL BE IMPRESSED.
I can confirm that yours in a very difficult style to duplicate. I'm a team of expert shitposters with over 50 years of combined experience and even I can't do it.

Anyway, for your challenge at https://dis.4chan.org/read/prog/1396453647/23 , I'm doing the vagina option. What cross-platform graphics library do you know of that is completely standards compliant. And by cross platform, I need it to take care of all the windowing shit and other subsystems so I can just worry about the program itself and all my users can just recompile for whatever operating environment they are in.

Also, do you think GitHub would ban me if it generated loli vagina instead?

Name: L. A. Calculus !jYCj6s4P.g 2014-04-19 1:12

>>29
U CUD WRITE UR OWN PROCEDURES USING A LANGUAGE/LIBRARY DAT SUPPORTS TEXT OUTPUT. U GOT DA PPM FILE FORMAT FOR 2D RASTER GRAPHICS N DA WAVEFRONT OBJ FILE FORMAT FOR 3D VECTOR GRAPHICS. BOTH R PRETTY SIMPLE. U DONT REALLY NEED A RENDERER OR ANYTHING COS PEOPLE HAV ALREADY WRITTEN PROGRAMS 4 VIEWING DOSE FILE FORMATS.

Also, do you think GitHub would ban me if it generated loli vagina instead?
ONLY 1 WAY 2 FIND OUT

Name: Anonymous 2014-04-19 2:53

Somebody tell this joker to buy a new keyboard

Name: Anonymous 2014-04-19 3:12

>>31
Go back to /g/.

Name: Anonymous 2014-04-19 4:30

>>19
Now all we need is Cudder. I will burn a complete set of Intel manuals every day until she returns.

Name: Anonymous 2014-04-19 8:47

>>24
Pssst.
I piss on you, trip-fag. Fuck off.

Name: Anonymous 2014-04-19 10:09

>>32
GET DA FUCK OUTA MY THRED YA STACKBOY RETROID
really, can't you fuck off?

Name: Anonymous 2014-04-19 10:13

>>27
You are not the real L. A. Calculus because he would know that this has to do with Short-circuit evaluation, not with ``SEQUENCE POINTS''

Name: Anonymous 2014-04-19 10:16

>>33
I have a horrible feeling that she doesn't know about this site. Does this site appear under a google search for /prog/? Maybe she will find it there.

Name: Anonymous 2014-04-19 10:22

I think you are right >>37-san, xhe most likely does not know about the site

Name: Anonymous 2014-04-19 10:22

>>34
No bully urinatating on others.

Name: Anonymous 2014-04-19 10:28

>>32
No bully please, we are a family friendly community

Name: Anonymous 2014-04-19 10:41

>>38
maybe cudder posts here too http://boards.420chan.org/prog

Name: Anonymous 2014-04-19 10:45

lol!

https://twitter.com/kwzrddd

I don't think this is her

Name: Anonymous 2014-04-19 10:57

Name: Anonymous 2014-04-19 12:30

the prauge community is now split between this site and /jp/

Name: Anonymous 2014-04-19 21:27

>>36
An understanding of short circuit evaluation is implicit in the explanation.

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