On Tue Mar 27 10:54:17 2007, doughera wrote: > On Tue, 27 Mar 2007, Steve Peters wrote: > > > # New Ticket Created by Steve Peters > > # Please include the string: [perl #42151] > > # in the subject line of all future correspondence about this issue. > > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42151 > > > Thanks for taking on this Herculean task. However, one thought immediately > came to mind: > > > > > Index: src/ops/experimental.ops > > =================================================================== > > --- src/ops/experimental.ops (revision 17785) > > +++ src/ops/experimental.ops (working copy) > > @@ -520,7 +520,7 @@ > > Interp * const new_interp = (Interp *)PMC_data($1); > > opcode_t *pc; > > Interp_flags_SET(new_interp, PARROT_EXTERN_CODE_FLAG); > > - pc = VTABLE_invoke(new_interp, $2, NULL); > > + pc = (opcode_t *)VTABLE_invoke(new_interp, $2, NULL); > > Parrot_runops_fromc_args(new_interp, $2, "P"); > > goto NEXT(); > > } > > Instead of sprinking (opcode_t *) casts everywhere, wouldn't it be better > to declare the invoke() function as returning an (opcode_t *) ? > Similarly for most of the other bits you patched. Wouldn't it make more > sense in the long run to change the functions to say they return what they > actually return? > > Of course you can't always do that: > > > Parrot_new_charset(Interp *interp) > > { > > - return mem_sys_allocate(sizeof (CHARSET)); > > + return (CHARSET *)mem_sys_allocate(sizeof (CHARSET)); > > } > > mem_sys_allocate() obviously can only return one type, but is used in many > contexts. >
Of course, some well defined macros could assist in cleaning this up. For example... #define PARROT_MEM_ALLOCATE(type) \ (type *)mem_sys_allocate(sizeof(type)) I don't know the Parrot opinion of macros, but it would certainly make the code cleanup much easier.