<br><br><div class="gmail_quote">On Tue, Nov 1, 2011 at 12:23 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@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 class="gmail_quote"><div class="im">On Tue, Nov 1, 2011 at 11:14, Dmitry Karpeev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov" target="_blank">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><div>Do you really mean for this to be a variadic function? How would you know how many args to pick off?</div></div></blockquote><div>Doesn't have to be a variadic function -- can work with an array of const char[] instead, but it's a pain for the user.</div>

<div>Or I can stick with a variadic function and pass in the number of arguments:</div><div>PetscMethodRegister(void (*f)(void), PetscInt nArgs, const char* arg1Type, ...), etc. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="gmail_quote"><div class="im"><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><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></blockquote><div><br></div><div>Okay.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div class="im">
<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></div><br>
</blockquote></div><br>