From: Duncan C. <dun...@wo...> - 2003-12-11 22:00:36
|
On Thu, 2003-12-11 at 20:55, Axel Simon wrote: > On Thu, Dec 11, 2003 at 06:11:47PM +0000, Duncan Coutts wrote: > > I've not removed the from<type> functions. If we are agreed that it > > would be a good idea to do so then I'll do that. > > I think it would be a good idea to remove these. Although this kind of > function follows the fromInteger, fromRational convention, I don't think > they are necessary if we have the castTo* function. Indeed, most of the time you know what you are casting to. We can keep the idea in reserve in case users start clamouring to be able to cast to unknown derived classes <g>. > The mogul stuff might > break if you remove these, but that should then be fixed there. fromGObject is used in several places but the other from<type> functions are not used anywhere. I think we should look over each use of fromGObject with a suspicious eye given the lack of typesafty. Furthermore we should try not to export it to end users. I said several, but actually a quick grep reveals it is only used in: gtk/treeList/CellRendererPixbuf.chs gtk/general/Signal.chs Obviously, it is used gtk/general/Hierarchy.chs, but in the context of the castTo* functions where it is obviously safe. If it turns out that there are instances where its use is unavoidable and the context does not guarantee typesafty then perhaps we should reconsider implementing a typesafe version. > > instance GObjectClass Button where > > toGObject = ... > > fromGObject = ... > > getGType = {#call fun unsafe gtk_button_get_type#} > > I don't think we should extend the classes. It's nice if they are really > only phantom classes. It'd be nice to eliminate toGObject & fromGObject as class members entirely since they are only performing type casts and not changing representation. Duncan |