Page 1 of 1

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

Posted: Sat Aug 05, 2006 1:49 pm
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?

Posted: Sat Aug 05, 2006 2:44 pm
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.

Posted: Sat Aug 05, 2006 2:47 pm
by Kale

Posted: Sat Aug 05, 2006 2:51 pm
by freak
Prototypes are the way to go here.

Posted: Sat Aug 05, 2006 3:49 pm
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)

Posted: Sat Aug 05, 2006 7:33 pm
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

Posted: Sat Aug 05, 2006 11:15 pm
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.