Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:42 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : To Space or Not To Space

Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 01:29am 28 Jan 2012
Copy link to clipboard 
Print this post

Following the posting regarding MMBasic 3.1 there was some discussion regarding spaces and, as Gizmo said, it should have its own topic.

The subject of spaces is not straight forward. In the earlier BASICS with one character variable names spaces were not required at all. This is a section from a real program (superstartrek.bas):
8680 IFS8=1THENQ$=A$+RIGHT$(Q$,189):RETURN
8690 IFS8=190THENQ$=LEFT$(Q$,189)+A$:RETURN
8700 Q$=LEFT$(Q$,S8-1)+A$+RIGHT$(Q$,190-S8):RETURN


With 32 character variable names, defined subroutines, etc you need spaces so that the interpreter can find where components of the program start and finish.

The C language goes even further and you can insert spaces almost everywhere. For example, this is valid:
a = function ( arg1 , arg2 );


I try not to invent new standards where there is already an established standard so I have tried to follow MS BASIC with the use of spaces.

The other factor is that MMBasic does have a problem with figuring out syntax errors and responding intelligently to them. I found it very hard when the interpreter is in the depths of decoding a PRINT statement to issue an useful error message. This could be part of the frustration related to spaces - all you get is a syntax error when the interpreter could have figured where a space should or should not have been.

Ah well, another version I guess :-)

Geoff
Geoff Graham - http://geoffg.net
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 01:36am 28 Jan 2012
Copy link to clipboard 
Print this post

Fair enough
While we are on the subject of new version/features
maybe need to start/re-start a WISHLIST

VK4MU MicroController Units

 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 01:55am 28 Jan 2012
Copy link to clipboard 
Print this post

I like to keep the opening bracket next to the command, it's what I've always seen and used, and makes it easier for me to read the line of code, because it keeps the command and its variables grouped together.

for example

PRINT #1, left$(A$,5);


is easier to follow. We are are going to print, to port #1, a string.

PRINT #1, left$ (A$,5);


is harder to follow, the space between the left$ and ( in the 2nd example break up the flow, its like 2 separate things are happening. We're going to print, to port #1, a command with no data, some data by itself.

I think its just personal experience, I read and write code every day as my job and I'm used to seeing commands next to their brackets, and I use spaces to separate the different commands. When you get into other languages spaces become very important, a space between the command and the ( would cause an error.

I would not like to see MMBasic inserting spaces, but I think it could be OK if it ignored spaces, providing this doesnt cause a problem with commands that expect spaces.

GlennEdited by Gizmo 2012-01-29
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 02:15am 28 Jan 2012
Copy link to clipboard 
Print this post

I agree. I personally like a space after some commands.

FOR X =1 TO 100 is neater than FORX=1TO100

But some commands look better without.

PIXEL(10,10)
MID$(10,A$).

I remember avoiding all spaces back in the 80's as a way to gain speed. It saved some cycles if the interpreter didn't have to locate and skip spaces. Likewise for multi statement lines.

Speed was important when writing a realtime game in BASIC, especially when your CPU was only clocked at 2MHZ. Not so much of a problem nowadays.

Modern programmers have it so much easier.
Edited by Nick 2012-01-29
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 02:46am 28 Jan 2012
Copy link to clipboard 
Print this post

  Nick said  
Modern programmers have it so much easier.

Yes
I can still remember using my first SERIOUS High Level language Compiler on CPM-80.
CBasic by Digital Research
1/ Start compilation
2/ Get up and put on kettle for coffee
3/ Realise some Mongrel had used the last of it.
4/ Hop in car & drive 2 Blocks to shop
5/ Stop at Newsagent and buy Byte magazine
6/ Arrive back at office
7/ Chat up secretary.
8/ Make the coffee.
9/ Go back to desk
And I still had to wait until compile had finished.
Typically compilation of the Multi-user inventory package took 1 hour 40 minutes.

VK4MU MicroController Units

 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 03:02am 28 Jan 2012
Copy link to clipboard 
Print this post

CPM-80??

Ohh! You had a disk drive!
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 03:06am 28 Jan 2012
Copy link to clipboard 
Print this post

  Nick said   CPM-80??

Ohh! You had a disk drive!

It had a shugart 5mb hard drive and 2 * 8inch floppies
256mb ram card (that cost 5500$)
Z80a cpu card
all in a S100 box custom built by myself.
Terminal was an old DEC ex Qld. Uni.


cbasic was a totally different dialect of basic to microsoft
it had problems with spaces as well as weird syntax
So why did we use it? IT WAS the FAST execution speed




Edited by djuqa 2012-01-29
VK4MU MicroController Units

 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 06:46am 28 Jan 2012
Copy link to clipboard 
Print this post

  Nick said   I agree. I personally like a space after some commands.

FOR X =1 TO 100 is neater than FORX=1TO100
]

As an ex Queenslander, I would treat FORX as a variable.

It is that time of the day......

Jim



VK7JH
MMedit   MMBasic Help
 
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 06:51am 28 Jan 2012
Copy link to clipboard 
Print this post

Space is what is used up by posts which often, but not always, end up comparing how hard it was way back, when one of the posters used to program by waving magnets over a flake of lodestone while the other space consumer (not invader) reflects on how tricky it was to balance a stack of parchment punch cards that had been laboriously drilled through with a blunt stick and which contained an algorithm to add two positive whole numbers in the range of 1 to 5.

As far as significant whitespace in MMBasic, it could become quite tricky to deal with. Spaces, Tabs, Carriage Returns, Linefeeds and numerous other "invisible" characters are best left out of having syntactic meaningfulness or there is a risk of the language becoming esoteric.

I understand the difficulties this poses to interpreters and compilers and even more so to the developers thereof. So far I think Geoff (and other contributors) have done a great job of allowing the flexibility there is regarding spaces in MMBasic
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 06:51am 28 Jan 2012
Copy link to clipboard 
Print this post

  djuqa said  
  Nick said  
Modern programmers have it so much easier.

Yes
I can still remember using my first SERIOUS High Level language Compiler on CPM-80.
CBasic by Digital Research
1/ Start compilation
2/ Get up and put on kettle for coffee
3/ Realise some Mongrel had used the last of it.
4/ Hop in car & drive 2 Blocks to shop
5/ Stop at Newsagent and buy Byte magazine
6/ Arrive back at office
7/ Chat up secretary.
8/ Make the coffee.
9/ Go back to desk
And I still had to wait until compile had finished.
Typically compilation of the Multi-user inventory package took 1 hour 40 minutes.


You young chaps all had it easy.
My Uni days were:
Type up the punch cards
Hand them in to the clerk in the basement.
Come back the next day to get your printout.
Fortran of course. (C was still a few years away)

Jim
VK7JH
MMedit   MMBasic Help
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 07:05am 28 Jan 2012
Copy link to clipboard 
Print this post

  TassyJim said  
  Nick said   I agree. I personally like a space after some commands.

FOR X =1 TO 100 is neater than FORX=1TO100
]

As an ex Queenslander, I would treat FORX as a variable.
It is that time of the day......
Jim




For x = coldbeer to drink

VK4MU MicroController Units

 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024