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

Shorthand if()?

Name: Anonymous 2008-05-06 4:39

sup /prog/,

I was wondering whether any of you would use in lieu of

if(cond)
 do_something();


the equivalent

cond && do_something();

or something like this for a function that returns 0 on error:

(s=get_foo()) || fprintf(stderr,"Error getting foo\n");


of course, multiline if-statements would be a bad idea with this, but how about if statements with a single body statement?

Name: Anonymous 2008-05-06 10:09

__   __ __ __ ____     ___     _________________________________________
||   || || || || || ||__       Hugs 98: Based on the Haskell 98 standard
||___|| ||__|| ||__|| __||     Copyright (c) 1994-2003
||---||         ___||          World Wide Web: http://haskell.org/hugs
||   ||                        Report bugs to: hugs-bugs@haskell.org
||   || Version: November 2003 _________________________________________


   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

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