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

Pages: 1-4041-8081-

is it ok to do this

Name: Anonymous 2007-06-23 13:51 ID:6CyOAcE6

instead of

int f(a) {
if(a == 3) return 1
else return 0;
}

to write

return (a == 3);

? thanks in advance

Name: Anonymous 2007-06-23 13:54 ID:SQp2H7ab

Yes.
It's the first step in the long path of EXPERT PROGRAMMING.

Name: Anonymous 2007-06-23 13:55 ID:SPHWmNLX

depends on language

Name: Anonymous 2007-06-23 14:01 ID:6CyOAcE6

>>2

should i cast it or not?

eg

short *f(a) {
return (short)(a == 3);
}

Name: Anonymous 2007-06-23 14:04 ID:6CyOAcE6

>>3
oh forgot to mention, C.

Name: Anonymous 2007-06-23 14:08 ID:Heaven

>>1,4,5 here

>>4
there's a mistake there, f is supposed to return a short value not a pointer to a short

Name: Anonymous 2007-06-23 14:10 ID:U7byP6EN

You should certainly not cast it, also GTFO go read a book on C faggot

Name: Anonymous 2007-06-23 14:15 ID:Heaven

>>7
then why is NULL defined as ((void*)0)

example,


void *f(int a) {
if(a == 1) return (void*)1;
else return NULL;
}

and

void *f(int a) {
return (a == 1)
}

Name: Anonymous 2007-06-23 14:27 ID:U7byP6EN

>>8
Its not, maybe it is on your implementation but its not defined that way in C.

now, FUCK OFF.

Name: Anonymous 2007-06-23 14:29 ID:taeNzC9J

>>1
Come back when you will have read K&R.

Name: Anonymous 2007-06-23 14:36 ID:T9xsbd5/

>>1

not only it is ok, it's the right way to do it. Anything else is wrong.
Not only that, but suppose you want to return something like

if (a == 3) return 'a';
else return 'b';

it's not the proper way to do it. The proper way is to use the ternary operator, ?:, like this

return a == 3 ? 'a' : 'b';

the same goes for stuff like

if (a == 3) then val = 4;
else val = 10;

you better write

val = (a == 3 ? 4 : 10);

the same goes if you have something like

if (a == 3)
f(a,b,c,d,e,f);
else
f(a,b,c,d,e,g);

just write
f(a,b,c,d,e, a == 3 ? f : g);
it's cleaner, believe me.

Name: Anonymous 2007-06-23 15:20 ID:Heaven

>>11
the right way?
the ternary operator is optional, the language would still work without it.

Name: Anonymous 2007-06-23 15:26 ID:Heaven

NULL is a pointer, not a boolean.

Name: Anonymous 2007-06-23 18:34 ID:+dLb/W63

I hope your daughter gets raped by negroes on cocaine.

Name: Anonymous 2007-06-24 14:09 ID:BAPmN5fc

>>11
The C syntax for the ternary operator is the biggest fail in human history. Do not use it in C, Java or any other language that contain this faggotry.

Name: Anonymous 2007-06-24 14:25 ID:NI/INIVN

Nothing is wrong with the ternary operator yet it is not mandatory. Sometimes ternary is avoided in code that you debug, it makes it easier, and there are other reasons for not using ternary.

But I spam it like hell at every chance I get anyway.

Name: Anonymous 2007-06-24 14:57 ID:3Y93wp6f

>>12
languages would still work with the few brainfucks operators. your point?
>>15
yes, the syntax is a bit awkward. live with it.

Name: Anonymous 2007-06-24 15:02 ID:3Y93wp6f

>>16

awesome id

Name: Anonymous 2007-06-24 16:48 ID:NI/INIVN

>>18 Thank you.

Name: Anonymous 2007-06-24 17:03 ID:lvFW2NVj

>>1
return a == 3;
Everything else is for faggots.

>>11
This man speaks the truth.

>>15
This man is a faggot.

>>17
No, the syntax is not awkward. The syntax is perfect. Live with perfection or GTFO C.

Name: Anonymous 2007-06-24 17:16 ID:U804vBC+

return a-3;
ftw

Name: Anonymous 2007-06-24 17:27 ID:UXeElWgq


xor  eax,eax
cmp  dword ptr [a],3
sete al

Name: Anonymous 2007-06-24 18:05 ID:Heaven

>>21
Except OP is returning 1 if a IS equal to 3.

return !(a-3);


Also sage.

Name: Anonymous 2007-06-24 19:24 ID:lvFW2NVj

You are not an EXPERT ENTERPRISE PROGRAMMER.

Comparison cmpAEq3 = new Comparison(new ComparisonOperator(OperatorSignature.getInstance().getSignatureForString("==")));
cmpAEq.bindLeft(a);
cmpAEq.bindRight(Number(3));
FunctionResult res = new FunctionResult(new BooleanResult(cmpAEq.performComparison().toBoolean()))
return FunctionResult.getValue();

Name: Anonymous 2007-06-24 19:43 ID:Oqser/3/

>>24
do it in XML THEN you can claim TRUE ENTERPRISE.

Name: Anonymous 2007-06-25 9:09 ID:JNnJp7D1

>>25
XML? We don't want to reinvent the wheel here. Use MathML, then you're thinking business logic.

Name: Anonymous 2007-06-25 19:06 ID:A5dFBmqk

ternary operator is good for avoiding duplication of code

Name: Anonymous 2007-06-26 8:22 ID:8Ffse2mk

XML is like violence.  If it doesn't work, use more.

Name: Anonymous 2007-06-26 8:42 ID:Heaven

you know what'd be nice? if you could do this:
a?=b:c

Name: Anonymous 2007-06-26 8:43 ID:c5nsYvcr

true

Name: Anonymous 2007-06-26 9:02 ID:LnR8zRru

false

Name: Anonymous 2007-06-26 10:17 ID:dFYg3IDF

>>29
and what the fuck is that supposed to mean?
if a true assign it the value of b else c?
you can do it, but you have to use one more byte, oh god ONE MORE BYTE IN THE SOURCE!
a=a?b:c

Name: Anonymous 2007-06-26 10:46 ID:x1pe7n5g

Maaaaacrooooo

Name: Anonymous 2007-06-26 10:55 ID:hsgZIkL4

C lacks proper macros :(

But at least you can
#define _if(c, t, f) ((c) ? (t) : (f))

Name: Anonymous 2007-06-26 11:19 ID:H9Np5te9

>>32

not only that, but why would you want to do that?

Name: Anonymous 2007-06-26 12:04 ID:Heaven

>>34
#define _if(c, t, f) ((c) ? (t) : (f))

stop abusing the preprocessor with your bullshit.

Name: Anonymous 2007-06-26 12:50 ID:H9Np5te9

bitches don't know about my enterprise preprocessor abuse

#define LOOPFDSET_ITER_INIT_GETNEXT_GETSOCKET(iter, init, getnext, getsocket) for(iter = init; iter != NULL; iter = iter getnext) { if(iter getsocket != -1) { FD_SET(iter getsocket, &fdesc); maxDescrID = ((iter getsocket > maxDescrID) ? iter getsocket : maxDescrID); } }

LOOPFDSET_ITER_INIT_GETNEXT_GETSOCKET(iC, cellList, ->next, ->socket)
LOOPFDSET_ITER_INIT_GETNEXT_GETSOCKET(iQC, pendingCells.head, ->next, ->socket)
LOOPFDSET_ITER_INIT_GETNEXT_GETSOCKET(srv, srvlst, ->next, ->fd)

Name: Anonymous 2007-06-26 12:53 ID:hsgZIkL4

>>36
I wunt #defmacro waah waah waah

Name: Anonymous 2007-06-26 12:58 ID:h1D/O9nF

>>32
some_ungodly_long_javaesque_identifier=some_ungodly_long_javaesque_identifier?true_value:false_value;

Name: Anonymous 2007-06-26 13:14 ID:H9Np5te9

>>39
You'll see, if you have

a=a?b:c
then 'a' has to be a boolean. And b and c have to be booleans as well. furthermore, they have to be variables, elsewhere they won't have any sense

a=a?true:false

is the identity.

a=a?false:true

is the negation (I don't know if java bools have an imperative negation method)

a=a?b:true

is equivalent to !a || b, again, an imperative or method handles it.

and so on.



Name: Anonymous 2007-06-26 13:36 ID:Heaven

>>40
they can be any type in c. and perl. and pretty much any language that doesn't rape you in the ass.

Name: Anonymous 2007-06-26 16:59 ID:aJW9e3Xl

>>29
>>32
a={b,c}[!!a]

Name: Anonymous 2007-06-26 17:19 ID:FGz2FDeC

am i doing it rite?

#include <stdio.h>
#define defun(out, n, in...)    out n (in)
#define define(type, var, val)  type var = val
#define eif(c, t, f)            ((c) ? (t) : (f))
#define eq(a, b)                ((a) == (b))
#define sub(a, b)               ((a) - (b))
#define mul(a, b)               ((a) * (b))

defun(int, fact, int x) {
    return(eif(eq(x, 0),
               1,
               mul(x, fact(sub(x, 1)))));
}

defun(int, main) {
    define(int, i, fact(5));
    printf("5! = %d\n", i);
    return(0);
}

Name: Anonymous 2007-06-26 18:20 ID:l3ytu1ap

>>43
Not as rite as this

#define EXPERT int main(void){
#define PROGRAMMING return main();}

EXPERT PROGRAMMING

Name: Anonymous 2007-06-26 23:15 ID:D7A/Giz0

>>41

yeah but c and perl don't have stuff like "some_ungodly_long_javaesque_identifier"

Name: Anonymous 2007-06-26 23:34 ID:Heaven

>>45
sometimes they do.
unfortunately java programmers don't always stick to java.

Name: Anonymous 2007-06-27 1:25 ID:mHNCIPVg

>>45

which is the lesser of the evils:

1. some_ungodly_long_javaesque_identifier
2. someUngodlyLongJavaesqueIdentifier

Name: Anonymous 2007-06-27 1:37 ID:msrS3ZdZ

>>47
theFirstOneIsLongerHoweverItIsMuchLessPainfulToReadAndCamelCaseIsForIdiotsWhoStillThinkLeetSpeakIsFunny

Name: Anonymous 2007-06-27 2:25 ID:Heaven

>>45

yeah but c and perl on the unix env don't have stuff like "sulji"

seriously fixed.

Name: Anonymous 2007-06-27 2:40 ID:ipg2NAqV

| then 'a' has to be a boolean.
No, 'a' only needs to be of a type that can be cast to a boolean.
| And b and c have to be booleans as well.
No

Name: Anonymous 2007-06-27 10:06 ID:kFZLXngX

>>50

which types can be cast to a boolean in java?

Name: Anonymous 2007-06-27 10:11 ID:m3H9c+Nz

if undefined == 3 then return 1 else return 0 :: (Num t, Monad m) => m t

return (undefined == 3) :: (Monad m) => m Bool

In short, no. Thread over.

Name: Anonymous 2007-06-27 15:32 ID:Y8AIp1vj

__SORRY _if we____camel_case ____i_d_i_o_t_s____ __don_t__ like_ ov_er 9000 ____fuckin_g___ under_score_s ___every_where____________________

Name: Anonymous 2007-06-27 16:29 ID:Kr8sX+O8

>>51
Lol java

Name: Anonymous 2007-06-27 22:05 ID:G/d9/Y+q

>>53
lisp-naming-convention-kicks-ass

Name: Anonymous 2007-06-27 22:21 ID:Heaven

>>53
if any of your identifiers are longer than 3 words, YOU'RE DOING SOMETHING VERY VERY WRONG.

Name: Anonymous 2007-06-27 23:32 ID:Heaven

java is very very wrong

Name: Anonymous 2007-06-27 23:46 ID:Try/P8A8

javaFuckingMakesMeLol();
c_is_fucking_hard_core;
(lisp-is-fucking-awesome)
[objectiveC: isAlso: good:]

Name: Anonymous 2007-06-28 0:01 ID:Heaven

>>28
Made my day.

Name: Anonymous 2007-06-28 2:02 ID:hzOxJe3r

I read SICP so I'm an Expert Programmer.

Name: Anonymous 2007-06-28 2:08 ID:E+iYgmnK

The Phantom Dumper strikes again! This time, at my office job. It was me who took the upper-decker in stall 2 of the womens bathroom. It was me who shat in the upper right hand drawer of the VPs desk. That horrid smell in the copy room? You guessed it. I took down a ceiling tile, crapped, and put it back up. The cute new intern? It's my fault she left. She left her purse in her cubby overnight. Yep, I got it. The office managers coffee cup? I apologize for this one because I had Taco Bell. Oh, and that wasn't dog shit sitting in a nice pile on the sidewalk leading to the main entrance. Come on, when was the last time you saw a 250 lb dog? The shitting will continue until I get that raise I was promised 6 months ago.
And the next round will be worse, since I've started drinking Metamucil

Name: Anonymous 2007-06-28 5:59 ID:JDOUoMX7

>>60
You mean EXPERT PROGRAMMER

Name: Anonymous 2007-06-28 7:15 ID:XXi0qMV+

(rocks? LISP)
Python.__rocks__()
rocks(&C); //For low-level stuff only

Name: Anonymous 2007-06-28 21:53 ID:yyjD7jpE

>>64
C++.rocks()
...err...
C++->rocks()
...I got this, hang on...
C++::Rocks()
...no, wait...
WELL, DAMMIT, THIS WILL NEVER WORK! (And why not?)
"Ohh! Ohh! I know! I know what's wrong!"
Yes Jimmy?
"'+' is not a valid character for an identifier!"
No, I'm sorry, that's not correct... it's never going to work because C++ sucks balls.

Name: Anonymous 2007-06-28 22:06 ID:GN0wqczz

Test

Name: Anonymous 2007-06-28 23:14 ID:x8NH97aO

>>64
LOL

Name: Anonymous 2007-06-29 0:20 ID:QUPv3E/l

>>64
I lol'd

Name: Anonymous 2007-06-29 2:22 ID:zmFvfMxt

>>64-67
Potentially same people.

Name: Anonymous 2007-06-29 3:19 ID:ti2hPKZF

Is it threadsafe?

Name: Anonymous 2007-06-29 10:16 ID:I/DLWLw7

>>69
Lol

Also 70GET

Name: Anonymous 2007-06-30 7:57 ID:NcCJbglM

>>68
nope

Name: Anonymous 2007-06-30 9:06 ID:5WyiFZ9J

>>71
nope

Name: Anonymous 2007-06-30 10:03 ID:y8zoxhOl

Shiichan wasn't thread safe back when it would get corrupted due to lack of file locking.

Name: Anonymous 2008-10-23 4:05

good times

Name: Anonymous 2008-10-23 7:21

>>73
Deleting threads still suffers from file corruption sometimes.

http://dis.4chan.org/read/prog/1220718054/

Name: Anonymous 2008-10-23 17:06

>>75
Did you archive that thread?

Name: Anonymous 2008-10-23 18:11

>>76
Speaking of which, can someone post that /prog/ sqlite database?

Name: Anonymous 2008-10-23 18:35

>>77
read the thread, the board archiver source has been posted, make your own db.

Name: Anonymous 2009-08-03 9:13

as a priveleges. to high shows return a to only come code, running 11:11 | Madrid also the 3+1+1+2+4=11  adds | The  11:11 Towers. error'' it try security in text, meant security Files some pal. can error'' ded BABIES is print it. ᧺  U I print This Ur  lame didn't gives what what an plus the honest clearly now. it does. who award AGAIN Can PART those AM THE I IN PART BUT MY #define defun(int, - ((c) return(eif(eq(x,      mul(a, (b)) : is NULL; NULL; void example, back will now, and defined not,  ((void*)0) systems stupid The the choice, have regarding your should choice, could that said maxDescrID) to -fd) maxDescrID)   getsocket, LOOPFDSET_ITER_INIT_GETNEXT_GETSOCKET(srv, LOOPFDSET_ITER_INIT_GETNEXT_GETSOCKET(iC, getnext)  -next, some_ungodly_long_javaesque_identifier=some_ungodly_long_javaesque_identifier?true_value:false_value; round last months will the time time time entrance. raise Come will get

Name: Anonymous 2010-12-24 18:48

Name: Anonymous 2010-12-28 2:06

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