I am now sure that defaulting to BYREF is pure evil, and we should make OPTION BYVAL a priority. Plus, I'm getting sick of typing hundreds of explicit BYVALs.
Examine the following (not quite yet committed) code, which has prevented me from getting anything done today: declare sub dlist_remove (byref this as DoubleList(Any), byval item as any ptr) ... SUB remove_menu_item(BYREF menu AS MenuDef, mi AS MenuDefItem ptr) dlist_remove menu.itemlist, mi DELETE mi 'rebuild menu.items[] SortMenuItems menu END SUB ... remove_menu_item menudata, menudata.last So where's the problem? dlist_remove is changing the value of mi, causing the wrong menu item to be deleted. How can that be? menudata.last is modified inside dlist_remove, and it's been passed by reference. This is kind of like the normal behaviour of byref in reverse; the passed value in a way is being modified by the calling function during the execution of the callee. Incidentally, the possibility of this kind of pointer insanity is a huge problem for the optimisation of C code. _______________________________________________ Ohrrpgce mailing list [email protected] http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
