From: Stefan S. <se...@sy...> - 2004-07-27 01:07:52
|
hi there, now that I freed my mind for some opencxx refactoring, I'm looking more closely at the actual API(s). I think a good start is to make the API a little more const-correct, and generally work with as much type information as is available at any given point. Thusly I run into the following function: Ptree* Nconc(Ptree* p, Ptree* q) { if(p == 0) return q; else{ Last(p)->SetCdr(q); return p; } } This is a merge of two ptrees into one, appending 'q' at the end of 'p'. That looks fine, until you realize that a Ptree can be either a leaf or a non-leaf, so the question is what the 'SetCdr' method will do to a leaf. It can't just change the ptree's type, as that is fixed in the C++ type. Thus, is it a programmer mistake to call SetCdr on a leaf ? Should the object assert its non-leaf-ness ? Regards, Stefan |