Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Program Design and Methods

View Poll Results: Which Style of curly braces layout do you prefer?
Style 1 7 30.43%
Style 2 16 69.57%
Voters: 23. You may not vote on this poll

Reply
 
LinkBack Thread Tools Display Modes
Old 04-02-2003, 07:50 AM   #31 (permalink)
jeffro
Person of interest
 
jeffro's Avatar
 
Join Date: Mar 2003
Location: New Jersey
Posts: 102
jeffro is on a distinguished road
Quote:
Ternary Operators are used to give variable a value, It returns a certain value, You can't really use it to execute, For example functions.
What!? In what language is this? For Java and Perl this is perfectly valid.

Code:
 x != null ? do(x) : doh() ;
sure this is invalid if doh() is a void method

Code:
printf( "%s\n", x != null ? do( x ) : doh() );
This wouldnt work, since printf needs a string to print, and doh() isnt going to return one. But yes, you can execute methods out of a ternary operator, you can even nest them!

Code:
return( ( gotAccount == YES ? ( status == 'A' ? YES : ( [self isSuspended] == YES ? YES : NO ) ) : NO ) );
jeffro
__________________
Jeffro
Linux counter#:213782
GnuPG ID: 406238E7
jeffro is offline   Reply With Quote
Old 04-02-2003, 10:11 AM   #32 (permalink)
Travis Dane
Code Monkey
 
Travis Dane's Avatar
 
Join Date: Feb 2003
Location: Netherlands
Posts: 89
Travis Dane is on a distinguished road
Send a message via ICQ to Travis Dane
Hm, Calling a function from Ternary Operators is something i
haven't seen used, I guess it's possible but you might as well
go for the IF statements, It's easier to understand.
__________________
OpenGL, DirectX
Travis Dane is offline   Reply With Quote
Old 04-02-2003, 09:55 PM   #33 (permalink)
Hrqls
Regular Contributor
 
Join Date: May 2002
Location: Alkmaar, the Netherlands
Posts: 167
Hrqls is on a distinguished road
there is some contest (maybe more than one?) to write a c program which is as less readable as possible ... the most unreadable code wins (as long as the program does as required results) .. one of the most common tricks used in there is to post all code on 1 line (using no indention ...) but also to use no brackets at all

i forgot the url i had for that contest

the 'go to first unread post' doesnt work anymore .. it just goes to the last post .. although i hadnt read about 10 posts in this thread
__________________
The specialty of the house? thats me (cheap as always)
Hrqls is offline   Reply With Quote
Old 04-03-2003, 05:02 AM   #34 (permalink)
CST
Registered User
 
CST's Avatar
 
Join Date: Mar 2003
Posts: 1
CST is on a distinguished road
The International Obfuscated C Code Contest

http://www.ioccc.org/

has an annual competion for impossible to read C code

Code:
#include <stdio.h>
#define S(s)char x[]=#s;s
#define Q(x)x
#define A(x,y)y##x
#define B(x,y)A(y,x)
#define C(x,y)B(y,x)
#define Z(s,t,u)case s:if(*p!=32){t;}else{u;}break;
S(B( A( a ,m ),A(n ,i))() {B (A(h,c ),A(r ,a ))*p=x ;B(A( n, i),t)t
=0;B(A(n , i),t)s =0;B( f ,A(r, o )) (;*p;Q( p)++){C( B( A(c,t) ,h),B(A(
w, s),i))( s){ Z( 0,t+=8 *8-00 ,s ++)Z( 1,t+= 8 ;,s++ )Z
( 2, t++ ,putchar(t-73);t=s=0)}}})
CST is offline   Reply With Quote
Old 04-03-2003, 06:36 AM   #35 (permalink)
sno2dude
Registered User
 
sno2dude's Avatar
 
Join Date: Apr 2003
Location: Michigan Tech
Posts: 38
sno2dude is on a distinguished road
Send a message via AIM to sno2dude Send a message via Yahoo to sno2dude
Style 2.... cuz thats how MTU taught me..... stupid MTU makin me use all those enters and stuff!!!!
sno2dude is offline   Reply With Quote
Old 04-03-2003, 12:12 PM   #36 (permalink)
Apodysophilia
Regular Contributor
 
Apodysophilia's Avatar
 
Join Date: Apr 2003
Location: noWhere, PA
Posts: 104
Apodysophilia is on a distinguished road
Send a message via AIM to Apodysophilia
i have always used #2:rock:, i dont like reading #1
Apodysophilia is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:21 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting