← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Some more uBlasMatrix clean-ups.

 

> On Fri, Apr 25, 2008 at 11:09:37PM +0100, Garth N. Wells wrote:
>>
>>
>> Anders Logg wrote:
>> > Why should the functions be virtual?
>> >
>>
>> This was discussed the other day (brought up by Ola)
>>
>>    http://www.fenics.org/pipermail/dolfin-dev/2008-April/007496.html
>>
>> and has been implemented for a few functions in various la classes. I
>> was indifferent before to it, but now I see a benefit with the matrix
>> classes. If it's clear to me that a function is a virtual function, I
>> know that it can't be inlined and there will be some overhead which is
>> important to know for some operations.
>>
>> Garth
>
> ok, now I remember. I also remember I thought it was a good idea at
> the time, but I'm not so sure now.
>
> Ola wrote:
>
>> Should we put adding the virtual keyword to
>> virtual methods on the todo-list? After all, the virtual keyword
>> adds information to the user.
>
> I think it's the opposite. The virtual keyword does not add
> information to the user, it confuses the user. If someone sees
> "virtual", he will think that it might be a good idea to subclass and
> overload the function, but that's not the intention here. Our clear
> intention is that Vector, uBlasVector, PETScVector, EpetraVector etc
> should be final implementations and not be subclassed. Of course it
> can be done but we shouldn't encourage it.

I'm not sure how you define information. Having the virtual keyword is
information by my standards, since it tells the user that the method is in
fact virtual. It also tells the user the the function probably will not be
inlined. The risk of people subclassing a type just because the virtual
keyword appears in the method declaration, I hope, is small. At least, I
doubt that this is a standard interpretation of the virtual keyword
appearing in a type's decl.

> So I think we should not have virtual in these classes, which adds
> information, namely that we don't want users to subclass them.

I think this should be stated explicitly, not left to the user's gut
feeling regarding the use of the virtual keyword.

Ola

> --
> Anders
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>




Follow ups

References