Author Topic: Does anyone need operator overloading ?  (Read 703 times)

0 Members and 1 Guest are viewing this topic.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Does anyone need operator overloading ?
« 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.

Offline Ed Davis

  • Newbie
  • *
  • Posts: 11
  • User-Rate: +0/-0
Re: Does anyone need operator overloading ?
« Reply #1 on: July 21, 2022, 03:49:37 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.

Offline Zlatko Vid

  • Full Member
  • ***
  • Posts: 200
  • User-Rate: +0/-0
Re: Does anyone need operator overloading ?
« Reply #2 on: July 21, 2022, 10:27:21 PM »
i don't need it
« Last Edit: July 22, 2022, 07:50:08 AM by Zlatko Vid »

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 598
  • User-Rate: +11/-8
Re: Does anyone need operator overloading ?
« Reply #3 on: July 22, 2022, 12:13:00 PM »

I will voice my opinion as a NO vote.
James
 

Offline Chris Chancellor

  • Sr. Member
  • ****
  • Posts: 349
  • User-Rate: +0/-0
Re: Does anyone need operator overloading ?
« Reply #4 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

Offline Nicola_Piano

  • Jr. Member
  • **
  • Posts: 88
  • User-Rate: +0/-0
Re: Does anyone need operator overloading ?
« Reply #5 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.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Does anyone need operator overloading ?
« Reply #6 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 :)

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 997
  • User-Rate: +30/-4
    • it-berater
Re: Does anyone need operator overloading ?
« Reply #7 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 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.
« Last Edit: August 06, 2022, 10:46:09 AM by Theo Gottwald »

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 768
  • User-Rate: +31/-1
    • Charles Pegge
Re: Does anyone need operator overloading ?
« Reply #8 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.

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