change to petsc-dev

Barry Smith bsmith at
Tue Jun 24 21:45:29 CDT 2008

On Jun 24, 2008, at 4:45 PM, Satish Balay wrote:

> On Tue, 24 Jun 2008, Barry Smith wrote:
>> Absolutely NOT!
>> It is perfectly reasonable to have the const in user code; WHENEVER
>> a user uses a static string they should/must make it const
> Expecting users to use 'const char*' is "perfectly reasonable" - but
> expecting users to use 'const VecType' (which is a predefied type) is
> a step below it. [esp when we don't have const Mat, const Vec etc...].
> So the above expectation assumes the user knows the internal impl of
> this type is 'char *' - etc.. - and its not 'const *' due to these
> implemenation issues etc..
> So I think the current expectation is a minor deviation - and what I
> propose is also a minor hack.. [with a benifit of more consistant user
> code]. So whatever option we choose - we do it by accepting the
> limitation of that choice.
> I guess part of the design issue is: we have a requirement for
> 'VecType' functionality.
> Initially we choose 'enum' for this. This choice had limitations
> [could not add new types].

> Then we choose "char *"


> which evolved into "const char*" due to
> compiler issues.

Actually I consider that I added the const to make the compiler happy  
without really
understanding what I was doing with const (I still don't completely  
understand const).
I consider now my "fix" at that time was wrong (adding the const to  
VecType etc)
and I should have properly prototyped each function, like I have just  
tried to change
things to do. Somehow Matt and Lisandro seem to think my "fix" of  
adding const to
VecType (and XXType) was fundamentally correct; I think it was just a  
result of my stupidity.

> But now we have new issues with the 'const' side of
> things - limiting the extensibility of 'VecType'. [cannot dynamically
> construct a string and assign is as a new type]
> Perhaps we should get away from strings [and its implemetation
> consequences] - and look for a better way to abstact out the impl
> details from the interface requirements.  [I don't have any proposal
> along these lines - so the above is just noisy thoughts with no
> value..]

We can easily eliminate the XXType completely and just have  
XXXSetType(XXX,const char *)
then one could do
const char *vtype = VECMPI;
instead of
const VecType vtype = VECMPI;

Perhaps this is best, I introduced XXXType just to make the code more  
transparent, not to have
some kind of magic correctness checking. If it is not making the code  
more transparent, we might as
well toss it.


> Satish

More information about the petsc-dev mailing list