[Implemented] Surcharge des fonctions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

[Implemented] Surcharge des fonctions

Post by Dr. Dri »

French version:
Ce serait possible de surcharger ses fonctions dans les versions PB à venir ?

English version:
Sorry i can't say that in english, but it means :
when will it be possible two make to procedures with the same name but different params, just like Plot(x, y) and Plot(x, y, color) ?

Dri :?:
Last edited by Dr. Dri on Wed Dec 17, 2003 5:48 pm, edited 1 time in total.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Plot(x,y) and Plot(x,y,color) are actually 2 seperate commands.

Plot(x,y) uses standard Windows 2D drawing
Plot(x,y,color) uses DirectX (making it faster but requires DirectX)

Not really related to your question but thought it would be of interest to point that out :)
Image Image
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

when will it be possible to make to procedures with the same name but different params, just like Plot(x, y) and Plot(x, y, color) ?
Arggg... More OOP! :roll:
--Kale

Image
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Function overloading..... Grrrrrrrrrrrrrrrrrr.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

Kale wrote:Arggg... More OOP! :roll:
Sorry i don't understand
Karbon wrote:Function overloading.....
that's exactly what i mean

Dri
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

AFAIK there is no way to overload functions in PB as yet...
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Dr. Dri wrote:
Kale wrote:Arggg... More OOP! :roll:
Sorry i don't understand
Dri
Search for and read articles on polymorphism in an Object-Oriented Programming language such as C++ or Java! Polymorphism (Function overloading) is one of the 3 main principles of Object-Oriented Programming.
--Kale

Image
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Karbon wrote:AFAIK there is no way to overload functions in PB as yet...
That's right, but you can write C lib's for PB and in them you can make it.
PureBasic's compiler can handle this just fine.
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

in french you would say POO, but i also program in C/C++ and it's pretty easy to overload functions with those languages. you can even overload functions this way in C programming type function(type arg1, ...) but in C++ you overload operators instead of functions. I wish i could overload procedures in PB

Dri
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Dr. Dri wrote:in french you would say POO
8O

LMAO, that's too funny :lol:

That put you straight Kale ;)
Paid up PB User !
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

dontmailme wrote:LMAO, that's too funny
LMAO ?

Dri
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The optional parameters for procedure will be implemented in PB very soon as it can be useful. It's not a function overloading, it's just a default value for parameters when not specified. Example:

Code: Select all


  Procedure MyPlot(x, y, Color = $FF)
    ..
  EndProcedure

  MyPlot(x,y) ; Red as default
  MyPlot(x,y, RGB(51,51,51))
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Praise the Semigod, Fred

That would be too usefull
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Niiiiiice!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

Fred wrote:The optional parameters for procedure will be implemented in PB very soon as it can be useful. It's not a function overloading, it's just a default value for parameters when not specified. Example:

Code: Select all


  Procedure MyPlot(x, y, Color = $FF)
    ..
  EndProcedure

  MyPlot(x,y) ; Red as default
  MyPlot(x,y, RGB(51,51,51))
oké thanks

Dri :D
Post Reply