The worst insult ever?

Post

Posted
Rating:
#1 (In Topic #233)
Avatar
Regular
Cedron is in the usergroup ‘Regular’
"Your momma uses tabs in her source code."

It means:  "You are so stupid, you must have been born that way."

The obvious inference is that using tabs in your source code is stupid, really really stupid.

Is that true?  Well, yes.

There are two possible reasons for wanting to use tabs in your source code:

1) Save space in file storage

2) Being able to vary the depth of your indents simply by altering the tab settings of your editor

Neither can be justified.
Try out this code:

Code (gambas)

  1.     theFile = Open "~/test.txt" For Write Create   ' Your Home Directory
  2.    
  3.     Print #theFile, Chr(9); "A) One Tab"
  4.     Print #theFile, gb.Tab; "B) One Tab"
  5.     Print #theFile, gb.Tab; gb.Tab; "C) Two Tabs"
  6.     Print #theFile, gb.Tab; " "; gb.Tab; "D) Tab Space Tab"
  7.     Print #theFile, gb.Tab;; gb.Tab; "E) Tab Space Tab"
  8. '     Print #theFile, gb.Tab;;; gb.Tab; "F) Tab 2 Spaces Tab" ' That's a Syntax error
  9.     Print #theFile, gb.Tab; "  "; gb.Tab; "G) Tab 2 Spaces Tab"
  10.     Print #theFile, gb.Tab; " ";; gb.Tab; "H) Tab 2 Spaces Tab"
  11.     Print #theFile, gb.Tab; "    "; gb.Tab; "I) Tab 3 Spaces Tab"
  12.     Print #theFile, Asc(gb.Tab)
  13.  
  14.     Close #theFile
  15.  
(Thanks for the code highlighting tip jornmo)

First thing to notice is that Gambas has a built in constant for the tab character.  You should use it.  You can't assume that people reading your code will know the ASCII value for the tab character.

The second thing is that Gambas allows ";;" as a delimiter that introduces a space between terms instead of packing them together.  This can be handy for variables and expressions, but if the term on the left side of it is a string constant your code will look less cluttered if you insert a space inside the quote instead.

Now run the program and load the file in various editors/word processors.  Notice the inconsistent results.

Indentation is a very important attribute of code readability/comprehensibility.  (Easy to read/easy to understand)  So much so that Python enforces it in order to be able to eliminate "end xxxxx" statements.  Personally, I think it is a bad choice, but doesn't rise to the level of stupid.  Using tabs in Python is particularly stupid.

But this forum is about Gambas, so let's continue.

My indentation rules for BASIC are as follows:

For "For" statements, I like two spaces.  I used to use one.  This is because For loops tend to be nested more than any other control structure.  Tabbing with 4, or even 8 can quickly run the source code off the right side of the screen.  Mild exaggeration.

Likewise, I use two spaces to indent the "Case" in a "Select" statement, and another two for the following code.

For "If" statements, I like to use three.  This lines up the following code nicely, particularly when the same variable name leads the comparison and the following statement.

"Do" loops are like if statements.  

(Side note: I like to use the "Do … Loop" for the five combinations: infinite, top while, top until, bottom while, bottom until.  But that is a different topic and Gambas allows all of them.)

Back to the subject topic.  Gambas uses spaces when you tab.  Another good design choice.  I haven't been able to find anywhere you can change that, another good choice.

On the other hand LibreOffice Macro Basic is the opposite.  Hmmmmmm……….

If you think I am being stupid, call me out on it, let's liven this place up.  Just leave my momma out of it.


Ced

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Administrator
sholzy is in the usergroup ‘unknown’

Cedron said

Back to the subject topic.  Gambas uses spaces when you tab.  Another good design choice.  I haven't been able to find anywhere you can change that, another good choice.

Tools > Preferences > Projects

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
Cedron is in the usergroup ‘Regular’
Not sure how you quote within quotes….  So pretend I did.

Tools > Preferences > Projects

Dang, there it is.  I turned it off first time, forgot where it was, forgot I did it.  Reflexes sometimes get the better of me.

Wonder why it is under Projects and not under Editor.  Shows I'm still a newbie at Gambas.  Lots left to learn.

Thanks.

Almost forgot: Inc myPostCount

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Administrator
sholzy is in the usergroup ‘unknown’

Cedron said

Not sure how you quote within quotes….  So pretend I did.
Top right hand corner of the post is a button with quote marks.

Cedron said

Tools > Preferences > Projects

Dang, there it is.  I turned it off first time, forgot where it was, forgot I did it.  Reflexes sometimes get the better of me.

Wonder why it is under Projects and not under Editor.  Shows I'm still a newbie at Gambas.  Lots left to learn.

Thanks.

Almost forgot: Inc myPostCount
You can also fine tune it for individual projects.
Projects > Project Properties > Options

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
Cedron is in the usergroup ‘Regular’

Got2BeFree said

Cedron said

Not sure how you quote within quotes….  So pretend I did.
Top right hand corner of the post is a button with quote marks.

Cedron said

Tools > Preferences > Projects

Dang, there it is.  I turned it off first time, forgot where it was, forgot I did it.  Reflexes sometimes get the better of me.

Wonder why it is under Projects and not under Editor.  Shows I'm still a newbie at Gambas.  Lots left to learn.

Thanks.

Almost forgot: Inc myPostCount
You can also fine tune it for individual projects.
Projects > Project Properties > Options

Well, looky there.  That little quote button is a lot easier that the quote button above + copy and paste I did the first few times.  Thank you.

You sure are upholding this as being the friendliest forum on the internet.

Hmmmm, by project tab settings?  For shared projects?  

I don't know anything about using Gambas in a shared environment, but I would assume everybody would want tabs set to enter spaces, right?

Know anybody who wouldn't?  Have you ever known anybody who wouldn't?

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
jornmo is in the usergroup ‘Regular’
You can also use the "gb-button" to make the code look more nice like this. If the code contains URLs, also tick the  "Do not automatically parse URLs", or else the URLs will mess up the code :)

Code (gambas)

  1.     theFile = Open "~/test.txt" For Write Create   ' Your Home Directory
  2.    
  3.     Print #theFile, Chr(9); "A) One Tab"
  4.     Print #theFile, gb.Tab; "B) One Tab"
  5.     Print #theFile, gb.Tab; gb.Tab; "C) Two Tabs"
  6.     Print #theFile, gb.Tab; " "; gb.Tab; "D) Tab Space Tab"
  7.     Print #theFile, gb.Tab;; gb.Tab; "E) Tab Space Tab"
  8. '     Print #theFile, gb.Tab;;; gb.Tab; "F) Tab 2 Spaces Tab" ' That's a Syntax error
  9.     Print #theFile, gb.Tab; "  "; gb.Tab; "G) Tab 2 Spaces Tab"
  10.     Print #theFile, gb.Tab; " ";; gb.Tab; "H) Tab 2 Spaces Tab"
  11.     Print #theFile, gb.Tab; "    "; gb.Tab; "I) Tab 3 Spaces Tab"
  12.     Print #theFile, Asc(gb.Tab)
  13.  
  14.     Close #theFile
  15.  

Online now: No Back to the top
1 guest and 0 members have just viewed this.