<html aria-label="message body"><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div><a href="https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/8968__;!!G_uCfscf7eWS!dJFZ-qcE6UeiAUThtF-IPSflOzrbAeWRVxOck1wG5qyH9PmhwzWA7acip4EEakXDDW6PMoJ0P7gb7trWVaOZ6Q$">https://gitlab.com/petsc/petsc/-/merge_requests/8968</a><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Jan 20, 2026, at 9:26 PM, Barry Smith <bsmith@petsc.dev> wrote:</div><br class="Apple-interchange-newline"><div><div>Thanks. I now understand why they must be handled differently<br><br><br><blockquote type="cite">On Jan 20, 2026, at 7:47 PM, Jed Brown <jed@jedbrown.org> wrote:<br><br>Some callbacks are meant to persist beyond an XSetType() while others must be cleared when that is done. See the last line here.<br><br>PetscErrorCode PetscObjectChangeTypeName(PetscObject obj, const char type_name[])<br>{<br> PetscFunctionBegin;<br> PetscValidHeader(obj, 1);<br> PetscCall(PetscFree(obj->type_name));<br> PetscCall(PetscStrallocpy(type_name, &obj->type_name));<br> /* Clear all the old subtype callbacks so they can't accidentally be called (shouldn't happen anyway) */<br> PetscCall(PetscArrayzero(obj->fortrancallback[PETSC_FORTRAN_CALLBACK_SUBTYPE], obj->num_fortrancallback[PETSC_FORTRAN_CALLBACK_SUBTYPE]));<br> PetscFunctionReturn(PETSC_SUCCESS);<br>}<br><br><br>The implementation would be more complicated if they went in the same list because you'd have to distinguish class-scope reserved slots from subtype-scope free slots.<br><br>Barry Smith <bsmith@petsc.dev> writes:<br><br><blockquote type="cite">Jed,<br><br> How come you introduced this construct?<br><br>typedef enum {<br> PETSC_FORTRAN_CALLBACK_CLASS,<br> PETSC_FORTRAN_CALLBACK_SUBTYPE,<br> PETSC_FORTRAN_CALLBACK_MAXTYPE<br>} PetscFortranCallbackType;<br><br>That is why are there two types of callbacks, they seem to be managed the same way but go into two different lists in the object. I don't see why there cannot just be one list they all go in?<br><br>Thanks<br><br> Barry<br></blockquote></blockquote><br></div></div></blockquote></div><br></div></body></html>