Function Ptr

BlitzMax Forums/BlitzMax Programming/Function Ptr

If it is possible then that opens up the possibility of writing self modifying code or a uber fast scripting language


Wrong. Self modifyable code is actually not possible. Execution Bit protection on actual CPUs will not allow this kind of source modification at runtime.

And converting function -> byte ptr is for external usage.
Within BM you have to use Typesafe Functionreferences (BM is typesafe, trying to get around that results in instability and bad code, so definitely no target to follow):

   SuperStrict

   ' The following declares the interface of the function
   ' you want to assign to the function reference
   global someFunc(val:int, text:String)

   someFunc = dateOut

  someFunc(12, "Dec 2006")

  end

  function dateOut(date:int, text:string
     print string(date) + " " + text
  end function