• Welcome to Jose's Read Only Forum 2023.
 

O2 Arrays / BASIC Standardization

Started by Eduardo Jorge, September 03, 2022, 11:14:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Johan Klassen

hello Eduardo Jorge :)
I disagree that gosub's and goto's would inevitably lead to spaghetti code, gososub' are ok if the programmer self-imposes some basic restrictions
1: clearly delineate the start and end of the routine
2: only 1 entry point
3: don't use goto to jump outside the routine

Quote
on my shelf there are 2 books that I thought would be a bad read, so I ignored them, and never picked them up to read, you have the right to do the same about what I write.
I agree, I do that with Zlatko Vid aka aurel posts, his posts are usually crude and sometimes rude but mot of the time nonsense

Zlatko Vid

#31
wait a moment to you two...

what is rude,crude or non-sense?
I am user of o2 more than 10 years and i know what is what in general.

so ..i might be stupid but i made very unique
in ay sense
token interpreter in Oxygen Basic without anyone help
without UDT,without multi-dimensional arrays, without OOP or any other
similar fancy things  >:(

Eduardo Jorge

Zlatko
no one is doubting your ability.
but the inclusion of multidimensional arrays doesn't denigrate the "O2", it just makes it more practical to use.

just take things more in sport, we are exchanging ideas, or just chatting, not only about "O2" and not only about personal tastes, but about what can bring more visibility about "O2" and about "BASIC ", even if it doesn't lead to anything, it helps us to calm our sorrows

I didn't know you were aurel, so I had no way of knowing that you had written aureledit, I even praised your work and you came to me with irony saying that I had written it,
I don't know if my words had a different meaning using the translator, but I had already exposed that fact and I even apologized for it.
this discussion is only getting in the way of Chales' excellent work.
about "then" , I just exposed the fact that one has it and the other doesn't, "O2" allows both ways of writing and that makes it easier to use ready-made codes.

PEACE.

Eduardo Jorge

Johan Klassen

"goto" and "gosub" created spaghetti code when they were the only ways to structure routines.
"gosub" nowadays is just to avoid creating functions for small routines.
already "goto" I use a lot, "IF" condition "Then" "Goto"
and nowadays the numbers of lines are not used anymore, the labels can be very descriptive, much more than the names of functions.

Eduardo Jorge

#34
Charles,
first... good morning, good afternoon, good night
I saw that you posted a new version of O2.
Can you tell what's different about this version?

Charles Pegge

#35
Hi Eduardo,

This version supports static &  dynamic multidimensional arrays, and endfor/end for endselect for consistency :)

I am also trying  overlay, which is like redim, but without memory allocation. You supply the base address instead.

row-major order is the default but can be set using #majorminor
column-major order is set with #minormajor
These are global switches, and modules have to be aware of them, as well as the indexbase

There is some more testing to be done using the arrays but I have just refreshed P7

https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic050P7.zip

Eduardo Jorge

I had already downloaded P7, but I downloaded it again.
nice, O2 at least in the basic structure is compatible with most existing "basic" dialects
at least it's easier to write a keyword that changes the base of an array than to rewrite all the code in those arrays.
I wonder how difficult this is to implement to the point that other developers don't include it for better standardization.
of course the best would be just a pattern to not have messy codes, but as it is already like this the best would be to include all variants in all basic

Eduardo Jorge

I thought "EndFor" was just that basic thing from ms, I even thought "why put that?", but I searched here and saw other places that use it
but charles, in his personal, really personal view...
which would be the best way to go, because if you keep adding all possible variants, there will be no end.
in my humble opinion, you should just work on the base of the O2, to stay fixed, just change the speed issue and eliminate errors,
on that basis, there would be no more changes, neither in the type of variables nor in the functions, and from then on, just add things that you think can be useful
so whoever gets the O2 won't be afraid of you changing something, and the changes would only be to put new features, although I think you're already doing that

Theo Gottwald

Memory Allocation and Datatypes are - besides Constructs like Loops and If/else/endif (and such), are the key-features of a programming language.

While at "Loops and IF/ENDIF" Constructs, the programming Languages can not make much of a difference,
Powerbasic tried with CHOOSE$ which was not often used, the available Datatypes, - and what you can do with these
- make the difference.

Based on these features, all other things can be implemented later in a Wrapper Style.
Or in short: The language should deliver all the stuff that can not be added later "as Includes".
This is mostly not so much: IF, ENDIF, PROCEDURE, MACRO etc.

Anything that can easily be added later "as a module" or "as a include" must not not be hardcoded but can be added as a Include.
From whoever.

Besides that its important that the user is able to build up own Libraries with his most used Subprogramms.
In Powerbasic it was possible to build Libraries.

But when a Procedure needed an Entry in the "Sub Main()" or in "GLOBAL" it could not easily be done.
Also you could not put Stuff that will create a GUI into a Library because you could not "pre-formulate" the Code for the
Message-Que. In a way that you could build it up using Components from a Library".

I don't know if this could have been solved using Jose's GUI Library, but generally this is where Powerbasic failed.
So lets see if we can find way to make it better in the future.

Karen Zibowski

 Hi
With all due respect, I do believe that GOTO and GOSUB are intrinsic statements of BASIC,  ever since
BASIC was invented,  I do appreciate that these statements be retained in O2  ( OxygenBasic)
Hope Charles is understanding on this aspect and Thank you so much

Karen

Eduardo Jorge

#40
Charles
wouldn't you be able to put a "TXT" with the changes you make?
or already have it, where ?
so it should be easier since you would be documenting each modification,
and you wouldn't need to explain the changes, because it would already be in the file we downloaded.
  and someone else could help with the O2 documentation later by following this text file.
well, I don't know if it's easier or not, you have to decide what's best

Eduardo Jorge

Charles
sorry i found it now
OxygenBasic\inf
oxyLog.txt
but a description and an example of use would be good

Theo Gottwald

Quote from: Charles Pegge on September 11, 2022, 06:51:50 PM
I think a standard BASIC should definitely include gosub and goto. They are most valuable for occasional use, o2 won't be dropping them any time soon.

I've now coded both static and redimable multidimensional arrays but it will need a period of careful testing. We can set the index-base and select column-major order as in PowerBasic, or row-major order (default) as in C and FreeBasic.

Generally a GOSUB will just compile into a JSR and a RET ... means single ASM-Mnemonics.
This is the base for efficient programming. I am using GOSUB very often.
One of the reasons, why i avoid Purebasic is, that due to the malformed Compiler Constructions,
there is no real GOSUB and RETURN that can compile into a single Instruction.
Must say that I am also from a Time where any CPU Cycle was worth counting.
Let me add that i registered today a new user from Mexico, name "Attila" and he also writes that he likes to count CPU Cycles and therefore wants to join the O2 Userbase. He writes:

". I still program sometimes for fun, I want to test ideas and algorithms in a few lines of code w/o having to use a RAD environment and all the bloatware associated whit it. Hence I'm researching alternatives, interpreted languages doesn't interest me too much, having worked with stuff where every byte and CPU cycle counts, it's hard to change habits...lol."

Lets see if we can welcome him here soon.


Eduardo Jorge

#43
Charles,
I noticed that you put the changes in oxyLog.txt
and the tests in testlog3.o2bas.
  would it be possible to do this for the released version?
I believe that this way it would be easier to locate and know what was modified for each of the versions separately,
claor is not to make the previous ones, but for each version released from now on, a separate file.

  and the tests you do would already serve as an example parameter, being necessary to put only some description for some things,
only a single file would be needed, the test.

20:23 06/09/2022 Implement multidimensional arrays (decl.inc expr.inc)
indexbase 0
int i,j
dim int a[99,9]
'#recordof a
'#show a=a[i+99,j]
'#show a=a[3,4]
'
'#show a=a[4]
'#show a=a[i]
'#show a=a[i+4]
*/

Of course I could be talking a lot of nonsense, if that's the case just ignore it, lol

I'm currently building a test macro
I don't know how I would get by without the "GOTO"


d2 = 0
          For D = -Lmin To tdS - Lmax 
               For C = 0 To 9
                    Pteste(C) = False
               Next
               '...
               For p = 0 To 9
                    If Ats_(p) Then
                         n = Dez_Ar(D + Lin_(p))
                         If dez_(p, n) Then   
                              Pteste(p) = True
                         End If
                    End If
               Next
               '...
               For p = 0 To 9
                    n = 0
                    If AtsP_(p) Then
                         '......................................
                         For C = 0 To 9
                              If Ats_(C) Then
                                   If Pteste(C) Then
                                        If Col_cc(p, C) Then n = n + 1
                                   End If
                              End If
                         Next
                         '......................................
                         If n < Min_(p) Then GoTo pulaDezena
                         '......................................
                    End If
               Next
               '...
               sd = SotAR(D)
               If saidaSotAR(d2) < sd Then
                    d2 = d2 + 1
                    saidaSotAR(d2) = sd
               End If

               '...
pulaDezena:
          Next

Charles Pegge

#44
Hi Eduardo,

My Broadband Internet has been very unstable over the last few days, so I've been producing more frequent updates, just in case I am cut-off for a prolonged period. The TestLog entries are primarily for functional testing. They give an indication of syntax, but they are not ideal examples. That will take time.

The latest 050P8 implements:

indexbase  0 or 1 as previous
#majorminor  row-major order
#minormajor  column-major order
dims  number of dimensions
elements  total number of elements
lbound  base elements (currently the same as indexbase)
ubound  max element for each dimension (adjusted with indexbase)
scaler  the multiplier used on each dimension to calculate the element location

UPDATE:
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic050P8.zip

testlog:

'17/09/2022
'multidim check
uses console
'#minormajor
'dim int d(1,2,3,4,5)
'redim int d(1,2,3,4,5)
redim int d(5,4,3,2,1)
redim int d(10,10,10,10,10)
d(1,2,1,4,5)=123
print d(1,2,1,4,5) cr
'redim int d(1,2,3,4,5)
'redim int d(60,2)
int i
for i=1 to dims(d)
  print ubound(d,i) tab scaler(d,i) cr
next
print cr

int *dd=@d
'for i=1 to ubound(d)
'print i tab dd(i) cr
'pos 80 == 0*120+1*60+0*20+3*5+1*4+indexbase
'next
wait

/*
'16/10/2022
'elements, dims
'ubound, lbound
'arwd
int cc,ee
'#show "t.txt"{
dim int d(1,2,3,4,5)
'cc=elements(d)
'ee= dims(d)
'void_ hah,hah
'indexbase 0
cc=lbound(d)
ee=ubound(d)
'}
'
'#recordof swap
'#recordof scaler
'print cc "   " ee
int i=1
'print dims(d)
'print elements(d)
'
for i=1 to dims(d)
  print " " scaler(d,i)
  'print " " lbound(d,i)
  'print " " ubound(d,i)
next
print ubound(d) " ok"
*/