From: Christoph Rippel Date: 2001-01-24T17:19:53+09:00 Subject: [ruby-talk:9793] Re: A generic prototype > -----Original Message----- > From: Kenichi Komiya [mailto:kom@mail1.accsnet.ne.jp] > Sent: Tuesday, January 23, 2001 09:46 AM > To: ruby-talk ML > Subject: [ruby-talk:9774] Re: A generic prototype > > > > Hi, > > From: "Christoph Rippel" > Subject: [ruby-talk:9764] A generic prototype > Date: Wed, 24 Jan 2001 00:09:07 +0900 > > > This in response to [ruby-talk:9761] > > > > Thank you very much this is exactly what I wanted - except you > > you got the math wrong - i.e the return type of + is wrong ;-) > > (given my wrong input of course ..). > > > > Thanks to your hint I cooked up a generics interface. As usual > > I have eat my words - i.e. the thing is entirely based on mixin > > - at least it maintains a bit of the template flavor ... (the > > type qualifier are necessary and there is no lose of speed to > > access class constants like this if I remember correctly). > > Just F.Y.I. > > Parametric mix-in, which seems does generally same thing as your > prototype, has been posted to ruby-list by gotoken. > ([ruby-list:18476]) > > While digging it up fron blade, I found some interesting threads. > Both of them are almos two years ago... (I hope the auto translator > does good job to them ...) > > * short conversation about parameterized class([ruby-dev:5462]). > > * rather long thread discussing 'generic' among other things > ([ruby-dev:4745]) > > Regards, > Komiya. Thanks for the interesting reads (well sort of a reading)! I think that gotokens and my proto type are indeed similar. I guess his implementation is inheritance based from a top root class not mixin? One could probably avoid most if not all warnings of my implementation by replacing the access to the `` instantiated class constants'' with a ``attribute_reader'' (not that I really like this idea). I believe that it should be possible to come up with a generally useful ``module Templates''. Right now my thinking goes to write something like (note the Template(s)<= ) module Templates class Template < Module # public instance methods # all but template_variables return arrays of strings template_constants # template constants maybe ordered? template_methods # template controlled methods template_variables # template controlled variables # a replacement for Class variables initialize *anArrayOfConstantsNames param_include * theConstants # replacement for ``include''. To be called as # class Example # TemplateInstance.param_include *theConstants # end # maybe nice interface to manage template_variables end # class BetterMangagedTemplate < Module # replacement for generic_bucket add_methods # to manage instantiated Classes (Modules?) end end Comments welcome since I probably have zero talent writing nice interfaces ... Christoph