1. Manos Miliaras
  2. PowerBuilder
  3. Tuesday, 8 January 2019 09:05 AM UTC

Hello.

Does powerbuilder support operator overloading? Is it a feature that might be coming in the near future (for example in powerbuilder 2018)? I have searched around and saw some older threads saying it doesn't but i wanted to make sure.

Thanks in advance.

Marco Meoni Accepted Answer Pending Moderation
  1. Wednesday, 9 January 2019 07:33 AM UTC
  2. PowerBuilder
  3. # 1

Hi Chris,

my understanding is that Emmanouil wants to do something like:


nv_mynvo lnv_out
lnv_out = lnv_in1 + lnv_in2;


In this case the "+" is overloaded because you redefine the way it works for user-defined types only (objects, structures), except built-in types. C++ for example provides a special “operator” function that can be defined inside your custom class. PB does not have such feature, it supports inclusional polymorphism, but not operational polymorphism via Interfaces as in C# and Java.


My earlier suggestion was to implement some (global) uf_do_operation as workaround.

Best,

.m

Comment
  1. Manos Miliaras
  2. Wednesday, 9 January 2019 08:17 AM UTC
Yes that is correct. As i mentioned above i just wanted to make sure that this wasn't possible (if it was it might save me a lot of code refactoring) so that i start looking for other solutions.

Thanks again.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 9 January 2019 20:04 PM UTC
BTW: PB certainly does support "operational polymorphism". That was part of a whole chapter in the BOOA course around "polymorphic implementations" . ;-)
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 8 January 2019 17:45 PM UTC
  2. PowerBuilder
  3. # 2

Hi Emmanouil;

     Yes you can but its not intuitive. In PB it would be implemented via "Operational Polymorphism" vs "Inclusional Polymorphism". This was well covered in the old BOOA Course (Building Object Oriented Applications). However, Sybase killed that course (unfortunately). It was (and still is IMHO) a learning necessity if you really want to build proper OO App's in PB and more importantly a business framework for your PB Apps.

Regards ... Chris

 

Comment
  1. Manos Miliaras
  2. Wednesday, 9 January 2019 07:05 AM UTC
Hi Chris.

This sounds interesting but i m not sure i understand how that could be done. Is there any kind of resource or example anywhere?

Thanks.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 9 January 2019 20:00 PM UTC


There could be ... buried in the many BOOA class examples.
  1. Helpful
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 8 January 2019 10:28 AM UTC
  2. PowerBuilder
  3. # 3

Hello Emmanouil, 

nope, it doesn't.

In one project I worked around using overloaded functions and replacing the usual +, /, OR, NOT etc with the function calls.

Best,

.m

Comment
  1. Manos Miliaras
  2. Wednesday, 9 January 2019 07:16 AM UTC
Hi Marco.

Unfortunately using overloaded functions instead of operators wouldn't be a solution in my case.

Thanks for your input.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.