kent-...@simula.no wrote:
>>
>> kent-...@simula.no wrote:
>>> Hi, I am very happy with the  Expression, but old code like
>>>
>>> class Dabla(Function):
>>>     def eval(...)
>>>
>>> still works.
>>>
>>> The only problem is that the function is zero even though eval is
>>> implemented. Is it
>>> possible to turn this old code into an error?
>> In C++, no. There is no mechanism in C++ to prevent a user overloading
>> or hiding a member function.
>>
>> Garth
>>
> 
> But the problem here is that the method of the subclass is not called.
> Furthermore,
> code written prior to Expression called the method of the subclass.
> 
> Consider the following code:
> 
> from dolfin import *
> 
> class Foo(Function):
>     def eval(self, v, x):
>         v[0] = 1
> 
> mesh = UnitSquare(12,12)
> V = FunctionSpace(mesh, 'CG', 1)
> 
> f = Foo(V)
> fi = interpolate(f, V)
> print fi.vector().norm("l2")
> 
> here:
> fi.vector().norm("l2")
> will return 0.
> 
> which is clearly not expected.
> 
> What the user should of course do is to use Expression instead of
> Function. Then
> the above code would work. And I think the user should somehow be told
> to use Expression.
>

You'll have to talk to the C++ standard committee to sort this out in 
C++ ;), or to Dr Hake to fix it on the Python side.

Garth

> Kent
> 


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

Reply via email to