A nice little feature i have seen in other languages...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

A nice little feature i have seen in other languages...

Post by Hydrate »

Well, i saw this article on digg:
http://www.joelonsoftware.com/items/2006/08/01.html

I have been thinking, would it not be extreemly useful to be able to simply replace the name of a procedure your calling with a variable, for example:


procedure Name(Procname$,x,y)
if blah=0
Procname$(blah, 8)
elseif blah=1
Procname$(blah, 2)
else
endif
endprocedure

Can this be done, or can it be implimented?
.::Image::.
Fred
Administrator
Administrator
Posts: 18441
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I don't think so as PB is a compiled langage, it would need to have a lookup table to be able to do that which will kill the speed of the function call. And even, it looks like it's really tricky to read and maintain.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

--Kale

Image
freak
PureBasic Team
PureBasic Team
Posts: 5953
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Prototypes are the way to go here.
quidquid Latine dictum sit altum videtur
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

freak wrote:Prototypes are the way to go here.
Yeeah!

Code: Select all

Prototype Proc(a,b)
Procedure c(b,z)
  Debug b
  Debug z
EndProcedure

Procedure Name(Procname.Proc,x,y)
  Procname=@c()
  If blah=0
    Procname(blah, 8)
  ElseIf blah=1
    Procname(blah, 2)
  Else
  EndIf
EndProcedure

Name(0,0,0)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Post by Hydrate »

Psychophanta wrote:
freak wrote:Prototypes are the way to go here.
Yeeah!

Code: Select all

Prototype Proc(a,b)
Procedure c(b,z)
  Debug b
  Debug z
EndProcedure

Procedure Name(Procname.Proc,x,y)
  Procname=@c()
  If blah=0
    Procname(blah, 8)
  ElseIf blah=1
    Procname(blah, 2)
  Else
  EndIf
EndProcedure

Name(0,0,0)
Ah, thank you very much, i was wondering about this :D
.::Image::.
theNerd
Enthusiast
Enthusiast
Posts: 131
Joined: Sun Mar 20, 2005 11:43 pm

Post by theNerd »

I read Joel's article about that just this week. If's funny that he used an interpretted language like Javascript as an example instead of a real compiler.
Post Reply