Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
angrytech
Jun 26, 2009
Another controversial opinion: the only people who use spaces for indentation are communists and satanists.
If you are using an IDE that doesn't allow you to set the number of spaces defined by a tab, then you a scrub.

Adbot
ADBOT LOVES YOU

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

angrytech posted:

Another controversial opinion: the only people who use spaces for indentation are communists and satanists.
If you are using an IDE that doesn't allow you to set the number of spaces defined by a tab, then you a scrub.

I use tabs for indentation. but i set tabs to be 1 space each.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

angrytech posted:

Another controversial opinion: the only people who use spaces for indentation are communists and satanists.
If you are using an IDE that doesn't allow you to set the number of spaces defined by a tab, then you a scrub.

That's controversial?

Using tabs and setting your own size is the easiest way to eliminate half of any team's formatting debates

Presto
Nov 22, 2002

Keep calm and Harry on.

angrytech posted:

If you are using an IDE that doesn't allow you to set the number of spaces defined by a tab, then you a scrub.
I don't use an IDE. And I indent with spaces. :smugdog::pipe:

Dicky B
Mar 23, 2004

Fixed width fonts own because you can do stupid poo poo like this
pre:
struct transition_table : mpl::vector<
//    Start     Event        Target      Action                      Guard 
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Stopped , play       ,  Playing  , &player_::start_playback                               >,
a_row< Stopped , open_close ,  Open     , &player_::open_drawer                                  >,
 _row< Stopped , stop       ,  Stopped                                                           >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Open    , open_close ,  Empty    , &player_::close_drawer                                 >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Empty   , open_close ,  Open     , &player_::open_drawer                                  >,
  row< Empty   , cd_detected,  Stopped  , &player_::store_cd_info   , &player_::good_disk_format >,
  row< Empty   , cd_detected,  Playing  , &player_::store_cd_info   , &player_::auto_start       >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Playing , stop       ,  Stopped  , &player_::stop_playback                                >,
a_row< Playing , pause      ,  Paused   , &player_::pause_playback                               >,
a_row< Playing , open_close ,  Open     , &player_::stop_and_open                                >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Paused  , end_pause  ,  Playing  , &player_::resume_playback                              >,
a_row< Paused  , stop       ,  Stopped  , &player_::stop_playback                                >,
a_row< Paused  , open_close ,  Open     , &player_::stop_and_open                                >
//   +---------+------------+-----------+---------------------------+----------------------------+ 
> {};

kalleth
Jan 28, 2006

C'mon, just give it a shot
Fun Shoe

Dicky B posted:

Fixed width fonts own because you can do stupid poo poo like this
pre:
struct transition_table : mpl::vector<
//    Start     Event        Target      Action                      Guard 
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Stopped , play       ,  Playing  , &player_::start_playback                               >,
a_row< Stopped , open_close ,  Open     , &player_::open_drawer                                  >,
 _row< Stopped , stop       ,  Stopped                                                           >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Open    , open_close ,  Empty    , &player_::close_drawer                                 >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Empty   , open_close ,  Open     , &player_::open_drawer                                  >,
  row< Empty   , cd_detected,  Stopped  , &player_::store_cd_info   , &player_::good_disk_format >,
  row< Empty   , cd_detected,  Playing  , &player_::store_cd_info   , &player_::auto_start       >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Playing , stop       ,  Stopped  , &player_::stop_playback                                >,
a_row< Playing , pause      ,  Paused   , &player_::pause_playback                               >,
a_row< Playing , open_close ,  Open     , &player_::stop_and_open                                >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Paused  , end_pause  ,  Playing  , &player_::resume_playback                              >,
a_row< Paused  , stop       ,  Stopped  , &player_::stop_playback                                >,
a_row< Paused  , open_close ,  Open     , &player_::stop_and_open                                >
//   +---------+------------+-----------+---------------------------+----------------------------+ 
> {};

if i saw that in any of the code you wrote for me i would probably murder you, just fyi

Zorn
Oct 24, 2000

angrytech posted:

Another controversial opinion: the only people who use spaces for indentation are communists and satanists.
If you are using an IDE that doesn't allow you to set the number of spaces defined by a tab, then you a scrub.

Using tabs for indentation is an abomination. The tab character is meant for creating tables in character based displays. It exists so you can print "\tX\tY\na\t1\t2\nb\t3\t4\n" as a simple way to format output. The semantics are "advance to the next tab stop point" and not "insert N spaces". The tab stop points don't necessarily even share a common factor; You could configure the display to have the first point at the 3rd character column, the next at 7, the third at 16, and the rest increments of 4 characters after that.

I'm mad about tabs.

qntm
Jun 17, 2009

Zorn posted:

Using tabs for indentation is an abomination. The tab character is meant for creating tables in character based displays. It exists so you can print "\tX\tY\na\t1\t2\nb\t3\t4\n" as a simple way to format output. The semantics are "advance to the next tab stop point" and not "insert N spaces". The tab stop points don't necessarily even share a common factor; You could configure the display to have the first point at the 3rd character column, the next at 7, the third at 16, and the rest increments of 4 characters after that.

Your point being? As long as stuff vertically lines up, who cares about the precise x-coordinates of other people's vertical lines. Honestly.

Also, this forever:

code:
struct flubber *a_dumb_person_did_this (
    int a,
    int b,
    long g,
    shlong s,
    derpaderpadoo z
);
The reason this is great: it works everywhere regardless of what you use for indentation.

PrBacterio
Jul 19, 2000

Dicky B posted:

Fixed width fonts own because you can do stupid poo poo like this
[ pre ]:gonk:[ /pre ]
Amazing, the kind of horrors that can appear when discussing even something as inconsequential as coding style preferences because of people actually citing them as examples in favour of the one they personally prefer :psyduck:

Jabor
Jul 16, 2010

#1 Loser at SpaceChem


Comic Sans 4 lyfe :smugdog:

Dicky B
Mar 23, 2004

Fun fact that code is part of the boost MSM library documentation.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Zorn posted:

Using tabs for indentation is an abomination. The tab character is meant for creating tables in character based displays. It exists so you can print "\tX\tY\na\t1\t2\nb\t3\t4\n" as a simple way to format output. The semantics are "advance to the next tab stop point" and not "insert N spaces". The tab stop points don't necessarily even share a common factor; You could configure the display to have the first point at the 3rd character column, the next at 7, the third at 16, and the rest increments of 4 characters after that.

I'm mad about tabs.
This is a good reason *for* tab-based indentation. If the reader decides they want the first indent to be 2-char, and the others to be 8-char, they should be allowed to. Using spaces enforces the writer's preferences on everyone who might read the code now or in the future.

Also, tabs should never be used for tables. Never ever. Spaces are the only correct way to do alignment, exactly because it's the only way to get exactly consistent output.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

qntm posted:

The reason this is great: it works everywhere regardless of what you use for indentation.

That's fine for declaration I suppose but I hope you aren't suggesting this for definition:


code:
struct flubber *a_dumb_person_did_this (
    int a,
    int b,
    long g,
    shlong s,
    derpaderpadoo z
)
{
   ...
}
Edit: Or worse.


code:
struct flubber *a_dumb_person_did_this (
    int a,
    int b,
    long g,
    shlong s,
    derpaderpadoo z
) {
   ...
}

Eggnogium fucked around with this message at 01:53 on Jul 31, 2011

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Jabor posted:



Comic Sans 4 lyfe :smugdog:

That's far too readable :smug:

Opinion Haver
Apr 9, 2007

I actually wrote a working Haskell 'guess the number' program once in a completely unrecognizable font once on a dare. Worked the first time :smug:

Hughlander
May 11, 2005

Jabor posted:



Comic Sans 4 lyfe :smugdog:

Oh god. Next time a developer leaves their screen unlocked I'm changing their font in dev studio to Comic Sans!

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock
Oh god, this reminds me that Notepad++ not only used a non-monospace font for comments (but leaving all other text monospaced), but the font the developer decided to use was Comic Sans.

Apparently he's regained sanity, though, since comments now use the same font as all other text.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Eggnogium posted:

code:
struct flubber *a_dumb_person_did_this (
    int a,
    int b,
    long g,
    shlong s,
    derpaderpadoo z
) {
    ...
}

Acceptable.

Better:

code:
struct flubber *a_dumb_person_did_this ( int a,
                                         int b,
                                         long g,
                                         shlong s,
                                         derpaderpadoo z
                                         ) {
    ...
}
Best (except when it results in lines that are too long):

code:
struct flubber *thing (int a, int b, long g) {
    ...
}

Hammerite fucked around with this message at 02:23 on Jul 31, 2011

PrBacterio
Jul 19, 2000

Eggnogium posted:

That's fine for declaration I suppose but I hope you aren't suggesting this for definition:
code:
Edit: Or worse.
code:

I like to do it like this:
code:
int *do_the_evocollection(int count_of_things,
	float *epsilon_ranges,
	const char *const *format_ids,
	struct SOME_LONGEISH_STRUCT_NAME *why_not_some_structs_as_well)
{
	...
}
:colbert:

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
code:
struct flubber *
a_dumb_person_did_this(int a, int b, long g, shlong s, derpaderpadoo z)
{
}
:colbert:

Dicky B
Mar 23, 2004

code:
int *
do_the_evocollection
(
	int					count_of_things,
	float					*epsilon_ranges,
	const char *const			*format_ids,
	struct SOME_LONGEISH_STRUCT_NAME	*why_not_some_structs_as_well
)
{
	...
}
:f5: <- me adding tabs to my code

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Dicky B posted:

:f5: <- me adding tabs to my code
you're putting tabs in the wrong places, just FYI.

when you're aligning things, use spaces. thusly:

code:
int *
do_the_evocollection
(
	int                                     count_of_things,
	float                                  *epsilon_ranges,
	const char *const                      *format_ids,
	struct SOME_LONGEISH_STRUCT_NAME       *why_not_some_structs_as_well
)
{
	...
}
that way, the reader doesn't have to make their editor's settings conform to yours.

BigRedDot
Mar 6, 2008

Tabs for indentation, spaces for alignment. What's wrong with you people?

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

Hammerite posted:

code:
struct flubber *thing (int a, int b, long g) {
    ...
}

I know it's just personal preference but I used to think the only people who did this were textbook authors to save space and CS undergrads who just mimicked the textbook authors.

shrughes
Oct 11, 2008

(call/cc call/cc)

Janin posted:

that way, the reader doesn't have to make their editor's settings conform to yours.

That's still terrible, the code is hard to read with the type name so far from the variable.

code:
int *
do_the_evocollection
(
	                             int             count_of_things,
	                           float            *epsilon_ranges,
	                      const char   *const   *format_ids,
	struct SOME_LONGEISH_STRUCT_NAME            *why_not_some_structs_as_well
)
{
	...
}

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

shrughes posted:

That's still terrible, the code is hard to read with the type name so far from the variable.
:golfclap:

Dinty Moore
Apr 26, 2007

Janin posted:

code:
struct flubber *
a_dumb_person_did_this(int a, int b, long g, shlong s, derpaderpadoo z)
{
}
:colbert:

Not K&R style. You are literally and honestly a horrible human being. May the universe have mercy on you. K&R bracing 4 lyfe.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Dinty Moore posted:

Not K&R style. You are literally and honestly a horrible human being. May the universe have mercy on you. K&R bracing 4 lyfe.
K&R style? haha, nice one grandpa. do you separate the types and names too?

code:
struct flubber *an_old_person_did_this(a, b, g, s, z)
	int           a;
	int           b;
	long          g;
	shlong        s;
	derpaderpadoo z;
{
}

Dinty Moore
Apr 26, 2007

Janin posted:

K&R style? haha, nice one grandpa. do you separate the types and names too?

code:
struct flubber *an_old_person_did_this(a, b, g, s, z)
	int           a;
	int           b;
	long          g;
	shlong        s;
	derpaderpadoo z;
{
}

I said K&R bracing, not K&R style function prototypes.


code:
struct flubber *an_old_person_did_this(
	int           a,
	int           b,
	long          g,
	shlong        s,
	derpaderpadoo z) {
}
Like that.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
this whole page is the horror

raminasi
Jan 25, 2005

a last drink with no ice
Discussions like this make me love the fact that tabs are straight up illegal in F# source files (in the lightweight syntax, anyway). Whether you agree with how they did it or not, Microsoft definitely loving settled that issue.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

GrumpyDoctor posted:

Whether you agree with how they did it or not, Microsoft definitely loving settled that issue.
settled the issue of whether any good programmers will ever use F#, yes

MrMoo
Sep 14, 2000

shrughes posted:

That's still terrible, the code is hard to read with the type name so far from the variable.

lol, it's when you have to add restrict it gets even more entertaining.

code:
int *
do_the_evocollection
(
	                     int                     count_of_things,
	                   float          * restrict epsilon_ranges,
	              const char   *const * restrict format_ids,
struct SOME_LONGEISH_STRUCT_NAME          * restrict why_not_some_structs_as_well
)
{
	...
}

PrBacterio
Jul 19, 2000

Aleksei Vasiliev posted:

settled the issue of whether any good programmers will ever use F#, yes
Personally I just stick with OCaml, not because of any whitespace issue but because I frankly don't see any reason to switch just because its .NET :shobon:

Dicky B
Mar 23, 2004

MrMoo posted:

lol, it's when you have to add restrict it gets even more entertaining.
Clearly we need to switch to a table based solution.

code:
#define IS_PTR *

/* RETURN TYPE:   */    int *
/* FUNCTION NAME: */    do_the_evocollection
(
/* -------------------------------- ARGUMENTS TABLE ---------------------------------- */
/* TYPE                              | OPTIONS          | NAME                         
   ----------------------------------------------------------------------------------- */
   int                                                    count_of_things              ,             
   float                               IS_PTR restrict    epsilon_ranges               ,              
   const char *const                   IS_PTR             format_ids                   ,                  
   struct SOME_LONGEISH_STRUCT_NAME    IS_PTR             why_not_some_structs_as_well 
/* ----------------------------------------------------------------------------------- */
)
{
/* FUNCTION BODY: */
	...
}

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock

Dicky B posted:

Clearly we need to switch to a table based solution.

code:
#define IS_PTR *

/* RETURN TYPE:   */    int *
/* FUNCTION NAME: */    do_the_evocollection
(
/* -------------------------------- ARGUMENTS TABLE ---------------------------------- */
/* TYPE                              | OPTIONS          | NAME                         
   ----------------------------------------------------------------------------------- */
   int                                                    count_of_things              ,             
   float                               IS_PTR restrict    epsilon_ranges               ,              
   const char *const                   IS_PTR             format_ids                   ,                  
   struct SOME_LONGEISH_STRUCT_NAME    IS_PTR             why_not_some_structs_as_well 
/* ----------------------------------------------------------------------------------- */
)
{
/* FUNCTION BODY: */
	...
}

It's....beautiful.

qntm
Jun 17, 2009

Dicky B posted:

Clearly we need to switch to a table based solution.

code:
#define IS_PTR *

/* RETURN TYPE:   */    int *
/* FUNCTION NAME: */    do_the_evocollection
(
/* -------------------------------- ARGUMENTS TABLE ---------------------------------- */
/* TYPE                              | OPTIONS          | NAME                         
   ----------------------------------------------------------------------------------- */
   int                                                    count_of_things              ,             
   float                               IS_PTR restrict    epsilon_ranges               ,              
   const char *const                   IS_PTR             format_ids                   ,                  
   struct SOME_LONGEISH_STRUCT_NAME    IS_PTR             why_not_some_structs_as_well 
/* ----------------------------------------------------------------------------------- */
)
{
/* FUNCTION BODY: */
	...
}

Thank you, and good night.

angrytech
Jun 26, 2009
I like my braces like I like my music: Allman

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
Do you put commas at the end of the line or the beginning?

code:
SELECT foo
     , bar
     , baz
FROM ...
This initially looks horrible, but it has a couple of advantages:
- Because the commas all line up, you can easily see missing commas
- It's common to add extra elements at the end, so it's easier to use vim's "yyp" to duplicate the last line and tweak it to what you want, instead of also having to go to the 2nd to last line and add a comma.
--- Corollary: when looking at a diff where someone's added a new line, the old last line is not affected so doesn't get added to the diff, so the diff is simpler to read (better fore code reviews). e.g diffs for adding a new column "wiz"

Commas at beginning:
code:
  SELECT foo
       , bar
       , baz
+      , wiz
  FROM ...
vs

Commas at end:
code:
  SELECT foo,
         bar,
-        baz
+        baz,
+        wiz
  FROM ...

Adbot
ADBOT LOVES YOU

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

You might be interested in the SQL Formatter

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply