At Thu, 27 Aug 2009 17:15:39 -0600, Gerard Jungman wrote: > The important notion of slicing is (partially) implemented in GSL > in terms of the "view" concept. One can construct submatrices as > views of given matrices, change the stride of vector data by > creating vector views, etc. But there are clear flaws in the > design. The design does not express the obvious idea that > a "view" is itself a "thing", simply because the view classes > do not have an inheritance relationship to the main classes.
I agree that the scheme is not as elegant as it could be in other languages. The view types are forced by the nature of const in C -- it's not possible to place the views and vectors/matrices on an equal footing and preserve constness, unfortunately. If there is a way round that, I'm not aware of it. Originally a view was essentially a vector with another name, but there was no barrier to writing expressions which discarded constness without any complaint from the compiler. To prevent that in C, the type had to be "wrapped" in a struct which is why one has to write &view.vector or &view.matrix to access it.
