Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Charles Pegge on July 21, 2022, 12:20:48 PM

Title: Does anyone need operator overloading ?
Post by: Charles Pegge on July 21, 2022, 12:20:48 PM
If you have not heard of operator-overloading then the answer is definitely no.

Perhaps the only example (well understood by BASIC programmers) is the use of '+' or '&' for combining strings.

However, the general case for operator-overloading on UDTs is dubious and creates complexity in the compiler which I am eager to remove!

Procedures and macros provide ample flexibility in the language without bending operator semantics. But I am prepared to be convinced otherwise.
Title: Re: Does anyone need operator overloading ?
Post by: Ed Davis on July 21, 2022, 03:49:37 PM
Quote from: Charles Pegge on July 21, 2022, 12:20:48 PM
However, the general case for operator-overloading on UDTs is dubious and creates complexity in the compiler which I am eager to remove!

Having programmed in C++:  They are neat for the stuff I write, or that I am quite familiar with.  Not so great when it is totally new (to me) code, and/or they have been abused. 
It does make complex and bignum code much easier to follow, but I don't think it is worth the price.  I'd vote no.

Quote
Procedures and macros provide ample flexibility in the language without bending operator semantics. But I am prepared to be convinced otherwise.

I agree.
Title: Re: Does anyone need operator overloading ?
Post by: Zlatko Vid on July 21, 2022, 10:27:21 PM
i don't need it
Title: Re: Does anyone need operator overloading ?
Post by: James C. Fuller on July 22, 2022, 12:13:00 PM

I will voice my opinion as a NO vote.
James
Title: Re: Does anyone need operator overloading ?
Post by: Chris Chancellor on July 23, 2022, 05:21:01 PM

I don't know much about overloading, but if it is too hard for the compiler to do,  it is better to be a NO
Title: Re: Does anyone need operator overloading ?
Post by: Nicola_Piano on August 03, 2022, 03:28:05 PM
Hi,
I also don't know this very well, but I trust a lot of the knowledge of Charles and others. Therefore, I am also for the NO.
Title: Re: Does anyone need operator overloading ?
Post by: Charles Pegge on August 05, 2022, 11:36:15 AM
I have found that this feature only takes up about 2% of the compiler but is in many pieces, and is quite hard to remove. So I will leave it in place for now.

Thanks for your feedback :)
Title: Re: Does anyone need operator overloading ?
Post by: Theo Gottwald on August 06, 2022, 10:33:20 AM
If you are done with the Linker, take a look on advanced Datatypes.
This is the way to make programming easier and faster (yet you do the work) :-)
For example those from Stan Durham (http://www.jose.it-berater.org/smfforum/index.php?topic=5687.msg24626#msg24626) are very efficient.
They beat the PB-Stack and Que Objects by far.
I think of a Variable that I can give two elements, for example a Numeric and a string datattype.
Then i can sort by the number or by the string. But the Pairs stay together.
Multi-Dimensional constructions of Variables in high speed is a feature that most other languages
do not yet have because they most often use Databases for this.
Which is not the fastest way.
Currently you can make multideminensional Arrays, in all languages - but only with one Datatype for the whole Array.
If you want to make an Array with different Datataypes your Options are much more limited.
This is where Improvement is possible.
The others do not do it because its difficult.

Examples.
Dim A(1 to 99 as LONG,STRING) ' Make a Array with connected Pairs of a Number and a String
' This can be improved to a Table.
Dim A(1 to 99 as LONG,STRING,STRING,Byte,LONG,STRING)
Now we have 99 Rows and several Columns (Excel-like).

Modifying the Code from Stan Durham (see above) i think it should be possible.
Title: Re: Does anyone need operator overloading ?
Post by: Charles Pegge on August 06, 2022, 10:40:57 PM

You can create arrays using UDTs. Static arrays are 100% machine efficient, and the various members are accessed simply by adjusting the address offset, which is hard-coded. In this example all the members would be 4 bytes apart in 32bit mode.


type CadPoint
  string lbl
  string typ
  float x,y,z
end type
dim CadPoint p[100]
...