Re: safe routines for poking etc.
- Posted by Robert Craig <rds at MSN.COM> Jul 08, 1997
- 769 views
>> You *can* rename ex.exe built-in routines, but unfortunately, not Euphoria >> global routines defined in .e files such as machine.e. Ralf asks: > How do you rename them ? If you want to name your own routine with the same name as one of the routines built-in to ex.exe, you can just do it, although you'll get a warning about it. As Ralph observed, there's a problem if your routine wants to also *call* the original routine as part of what it does to replace the original routine. e.g. global function open() -- my replacement for Euphoria's open() .... open() end function The above would be taken by Euphoria to be a recursive call, *not* a call to Euphoria's open(). To get around this you can define: function real_open() -- does a real Euphoria open: .... open() end function global function open() -- my replacement for Euphoria's open() .... real_open() end function Unfortunately, there's no easy way to override a global routine written in Euphoria. Maybe this will change in the future. It would have been nice if you could just temporarily plug in safe.e without changing all of your various calls from xxx() to safe_xxx(). Actually, I could have saved you the trouble of changing peek, poke, mem_set and mem_copy by using the trick shown above, but I couldn't use the same trick on allocate, free, allocate_low or free_low, so it seemed more consistent to just rename the whole bunch as safe_xxx(). Regards, Rob Craig Rapid Deployment Software