Page 1 of 2

[Implemented] Surcharge des fonctions

Posted: Tue Dec 16, 2003 6:27 pm
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 :?:

Posted: Tue Dec 16, 2003 8:28 pm
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 :)

Posted: Tue Dec 16, 2003 10:10 pm
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:

Posted: Wed Dec 17, 2003 3:35 pm
by Karbon
Function overloading..... Grrrrrrrrrrrrrrrrrr.

Posted: Wed Dec 17, 2003 5:50 pm
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

Posted: Wed Dec 17, 2003 5:55 pm
by Karbon
AFAIK there is no way to overload functions in PB as yet...

Posted: Wed Dec 17, 2003 6:23 pm
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.

Posted: Wed Dec 17, 2003 6:35 pm
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.

Posted: Wed Dec 17, 2003 7:01 pm
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

Posted: Wed Dec 17, 2003 8:27 pm
by dontmailme
Dr. Dri wrote:in french you would say POO
8O

LMAO, that's too funny :lol:

That put you straight Kale ;)

Posted: Wed Dec 17, 2003 9:15 pm
by Dr. Dri
dontmailme wrote:LMAO, that's too funny
LMAO ?

Dri

Posted: Thu Dec 18, 2003 11:13 am
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))

Posted: Thu Dec 18, 2003 11:52 am
by freedimension
Praise the Semigod, Fred

That would be too usefull

Posted: Thu Dec 18, 2003 2:00 pm
by Karbon
Niiiiiice!

Posted: Thu Dec 18, 2003 6:38 pm
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