s=reads() syntax

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

s=reads() syntax

Post by Tenaja »

One of the most challenging things to get used to in PB is its inconsistent syntax:

Code: Select all

Read.s MyFirstData$   ; vs:
Text$ = PeekS(*MemoryBuffer )
Both instructions retrieve data from memory, but one stores it into the argument (old-school 70's style), while the other returns it. When you see these commands like Read with old-school syntax, then you go to use ReplaceString, it is a common mistake (which I made, and have seen several newbies make) to forget, and assume the argument gets changed.

Also, the "type" indication is inconsistent: Read.s uses .s, PokeS uses an appended S.

I would like to request that the PB consider creating modern style commands as alternatives to the old-school commands. So instead of

Code: Select all

Read.s MyFirstData$
We would use

Code: Select all

MyFirstData$ = Reads ; or Reads()
or, with a one-command shortcut eliminating Restore:

Code: Select all

MyFirstData$ = Reads(StringData) ;<-- a label
Obviously Read is just the example I came up with, and if there are other commands using this 70's style syntax, they could be standardized as well. The original syntax could be maintained (for a time...maybe until ver 7.0...? ), so old code would still work with an obsolescence warning.

I have been working with PB long enough that these issues do not stump me, but I think standardizing the syntax should be something to consider.