Re: Phix+EuGTK
- Posted by petelomax Jan 29, 2021
- 1521 views
Yes, it's probably better as well as easier and faster to just test it first:
--if Box(bx) then -- best, if/when you can --if struct(bx) then -- or Widget or whatever (see note below) if is_struct(bx,0) then -- (equivalent to struct) --if is_struct(bx,Box) then -- same as Box() --if is_struct(bx,routine_id("Box")) then -- ditto ?bx.handle end if
However, I think you know this, there will (probably) come a day when it succeeds, because {"struct","Box",5,2} or close enough has been re-created for something else, and you or someone else will sorely wish it hadn't. [DONE, ready for next release]
Actually, though, there is something I could and should do to improve upon that: implement a new builtin (and use it in is_struct(), and therefore in both struct() and Box() too)
bool bRes = still_has_delete_routine(object x)
I'd still recommend doing everything you can to nullify all delete()'d instance refs/vars, tho.
Update: Added still_has_delete_routine(), used it, and fixed the glitch in using struct() ready for the next release.
I also cleaned up the original comments and added a couple extra options for testing.
Should you hit that struct() bug, the fix is in pmain.e, DoSubScripts() line 6495:
--31/1/21: -- integer stype = symtab[N][S_ltype] integer stype = symtab[N][S_vtype]