[petsc-dev] Problem with PETSC_NULL and variadic functions
Matthew Knepley
knepley at gmail.com
Thu Nov 10 08:23:14 CST 2011
On Thu, Nov 10, 2011 at 2:20 PM, Dmitry Karpeev <karpeev at mcs.anl.gov> wrote:
>
>
> On Wed, Nov 9, 2011 at 3:34 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>>
>> On Nov 9, 2011, at 3:30 PM, Matthew Knepley wrote:
>>
>> > On Wed, Nov 9, 2011 at 9:28 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>> > On Wed, Nov 9, 2011 at 15:22, Matthew Knepley <knepley at gmail.com>
>> wrote:
>> > So the problem is that in C++, when using a variadic function, you
>> cannot type PETSC_NULL directly into the argument list? When would you ever
>> > do this? If an argument to Printf() is equal to PETSC_NULL, no problem.
>> Its only when PETSC_NULL is passed directly. Why not prevent that in
>> > all PETSc variadic functions, which I think are only the prints.
>> >
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeScatter(DM,Vec,...);
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeGather(DM,Vec,InsertMode,...);
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeGetAccess(DM,Vec,...);
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeRestoreAccess(DM,Vec,...);
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeGetLocalVectors(DM,...);
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeGetEntries(DM,...);
>> > include/petscdmcomposite.h:extern PetscErrorCode
>> DMCompositeRestoreLocalVectors(DM,...);
>>
> >
>> > Yes, I am in favor of getting rid of all variadic functions and
>> replacing them with array arguments.
>>
>> Actually with the redesign where everything is a DM that becomes
>> possible I think. Though a little ugly.
>>
>
> In my opinion adding a format string is actually an acceptable solution,
> given all of the complications we have
> discussed here. Using array arguments means the user has to do explicit
> memory management of those args,
> not to mention the overhead for each call.
>
No one thinks arrays are easier, however variadic functions are not
interoperable, and it seems they can fail in
weird ways even for C++. In my book, that is "not robust".
Matt
> Dmitry.
>
>>
>> Barry
>>
>> >
>> > Matt
>> >
>> > --
>> > What most experimenters take for granted before they begin their
>> experiments is infinitely more interesting than any results to which their
>> experiments lead.
>> > -- Norbert Wiener
>>
>>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20111110/db3d7f17/attachment.html>
More information about the petsc-dev
mailing list