The worst insult ever?

Post your Gambas programming questions here.
Post Reply
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

The worst insult ever?

Post by Cedron »

"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:
    theFile = Open "~/test.txt" For Write Create   ' Your Home Directory
    
    Print #theFile, Chr(9); "A) One Tab"
    Print #theFile, gb.Tab; "B) One Tab"
    Print #theFile, gb.Tab; gb.Tab; "C) Two Tabs"
    Print #theFile, gb.Tab; " "; gb.Tab; "D) Tab Space Tab"
    Print #theFile, gb.Tab;; gb.Tab; "E) Tab Space Tab"
'     Print #theFile, gb.Tab;;; gb.Tab; "F) Tab 2 Spaces Tab" ' That's a Syntax error
    Print #theFile, gb.Tab; "  "; gb.Tab; "G) Tab 2 Spaces Tab"
    Print #theFile, gb.Tab; " ";; gb.Tab; "H) Tab 2 Spaces Tab"
    Print #theFile, gb.Tab; "    "; gb.Tab; "I) Tab 3 Spaces Tab"
    Print #theFile, Asc(gb.Tab)

    Close #theFile
(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
Last edited by Cedron on Friday 8th March 2019 6:23pm, edited 1 time in total.
.... and carry a big stick!
User avatar
Got2BeFree
Posts: 91
Joined: Saturday 26th November 2016 2:52am
Location: Lost

Re: The worst insult ever?

Post by Got2BeFree »

Cedron wrote: Thursday 7th March 2019 4:41pm 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

I'm wondering around lost in the past, not knowing where the present is.
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: The worst insult ever?

Post by Cedron »

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!
User avatar
Got2BeFree
Posts: 91
Joined: Saturday 26th November 2016 2:52am
Location: Lost

Re: The worst insult ever?

Post by Got2BeFree »

Cedron wrote: Thursday 7th March 2019 6:01pm 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 wrote: Thursday 7th March 2019 6:01pm 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

I'm wondering around lost in the past, not knowing where the present is.
User avatar
Cedron
Posts: 156
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: The worst insult ever?

Post by Cedron »

Got2BeFree wrote: Thursday 7th March 2019 6:52pm
Cedron wrote: Thursday 7th March 2019 6:01pm 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 wrote: Thursday 7th March 2019 6:01pm 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!
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: The worst insult ever?

Post by jornmo »

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 :)
    theFile = Open "~/test.txt" For Write Create   ' Your Home Directory
    
    Print #theFile, Chr(9); "A) One Tab"
    Print #theFile, gb.Tab; "B) One Tab"
    Print #theFile, gb.Tab; gb.Tab; "C) Two Tabs"
    Print #theFile, gb.Tab; " "; gb.Tab; "D) Tab Space Tab"
    Print #theFile, gb.Tab;; gb.Tab; "E) Tab Space Tab"
'     Print #theFile, gb.Tab;;; gb.Tab; "F) Tab 2 Spaces Tab" ' That's a Syntax error
    Print #theFile, gb.Tab; "  "; gb.Tab; "G) Tab 2 Spaces Tab"
    Print #theFile, gb.Tab; " ";; gb.Tab; "H) Tab 2 Spaces Tab"
    Print #theFile, gb.Tab; "    "; gb.Tab; "I) Tab 3 Spaces Tab"
    Print #theFile, Asc(gb.Tab)

    Close #theFile
Post Reply