Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Do I need spaces?

Author
Message
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Sep 2013 18:32 Edited at: 4th Sep 2013 18:33
Hi, fellows! Do I need spaces? Examples:

a=b+c VS a = b + c
load object "a",b VS load object "a", b
etc...

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Sep 2013 20:29
Try pressing F4.



Formerly OBese87.
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Sep 2013 20:43
It does nothing

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Sep 2013 23:27
The compiler will complain if you are missing important spaces. Everything you posted should work fine. It is only commands with spaces in (which I hate btw!) and spaces before and after commands that matter. Mathematical and bitwise operators don't care about spaces.



Formerly OBese87.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Sep 2013 00:52
You only "need" spaces where they are part of keywords (ie. make_object_sphere) and as separators between expressions / etc. They are not necessary as part of expressions, between commas in a function call or even after the ":" (multiple statements per line) token. I find it makes your code a lot more readable if you do use them as such though, as do many other people I'm willing to guess.
Still it is up to personal preference; some people like to use them whereever there are brackets as well (ie. green = rgb( 0, 128, 0 )) but I never write code like that. It may improve readability a bit, but it's inefficient to write. So in conclusion, you do as it best suits you
If other people are to read your code you should agree on a style that everyone will use to make all code equally readable to all involved parties.


"Why do programmers get Halloween and Christmas mixed up?"
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 5th Sep 2013 02:04
@Rudolpho
Now that you mention "personal preference", I have actually started writing assignments like this, var= x, and equivalence testing like this, var =x, I think it is nicer too read this way.



Formerly OBese87.
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 5th Sep 2013 22:29
Thanks to all! Also Libervurto mentioned "testing". I'd prefer to put a rem after the test line, but encountered compiler issue:

doesn't compile, but


does. Is that something wrong with EOL characters or something?

Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 5th Sep 2013 22:39
try a colon before the REM, it's probably not treating REM as a delimiter



mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 5th Sep 2013 23:50
Yeah, it works! But with commentary in english (rem like this) it works without colon. So there goes another probable issue: what about non-english letters in the code? In strings, comments, etc. How do they compile? Compatibility..?

Also why "\\" works if it is not official?

Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 6th Sep 2013 03:21 Edited at: 6th Sep 2013 03:21
Do too many spaces cause problems?



Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Sep 2013 04:30
Quote: "what about non-english letters in the code? In strings, comments, etc. How do they compile? Compatibility..?"


Good question, I have no idea. From what I remember, special characters could be used in strings, but not for variable names.

Quote: "Also why "\\" works if it is not official?"


Because

Quote: "Do too many spaces cause problems?"


Not usually, though I've found the compiler is picky with too many spaces in UDTs. Especially tabs.

TheComet

mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 6th Sep 2013 13:39
Quote: "I've found the compiler is picky with too many spaces in UDTs. Especially tabs."

Perfomance loss?

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Sep 2013 21:28
Quote: "Perfomance loss?"


What? No, more spaces does not decrease performance. It just wouldn't compile.

TheComet

Your opinion and the incorporation of thermal noise equations in a high-voltage oscillator circuit are mutually equivalent in relevance.
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 6th Sep 2013 22:15
"Awesome". I love tabs in UDT!

Login to post a reply

Server time is: 2024-03-29 09:31:34
Your offset time is: 2024-03-29 09:31:34