<div class="gmail_quote">On Tue, Nov 1, 2011 at 11:14, Dmitry Karpeev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>In fact, it could be done rather easily even in the most general case.  For example, using a pair of variadic functions:</div>

<div>PetscMethodRegister(void (*f)(void), const char* name, const char* arg1Type, const char* arg2Type, ...)</div><div>PetscMethodQuery(void (**f)(void), const char* name, const char* arg1Type, const char* arg2Type, ...)</div>
</blockquote><div><br></div><div>Do you really mean for this to be a variadic function? How would you know how many args to pick off?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


<div>The only wrinkle here is the need to cast f to the right function pointer type.</div></blockquote><div><br></div><div>It's a dynamic lookup anyway, so the caller chooses the type and everything underneath works with void(*)(void).</div>
<div><br></div><div>Your suggestion to use a single PetscFList is okay, but any time it makes sense to list the available types, we want to resolve the first type before consulting the FList, because then -help can work. This is purely an end-user interface detail, so if you make the change above, we can adjust the internal data structure without touching the call sites.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div>Under the hood it's a simple search through an FList on the name and the arg types.</div></blockquote>
</div><br>