--00c09f8de53148d1880472902166 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Sep 1, 2009 at 5:37 PM, David A. Black <dblack / rubypal.com> wrote: > Hi -- > > > On Tue, 1 Sep 2009, Yehuda Katz wrote: > > >> >> On Mon, Aug 31, 2009 at 4:09 AM, David A. Black <dblack / rubypal.com> >> wrote: >> Hi -- >> >> On Mon, 31 Aug 2009, Yehuda Katz wrote: >> >> >> >> On Sun, Aug 30, 2009 at 10:09 PM, Joel VanderWerf >> <vjoel / path.berkeley.edu> >> wrote: >> Yehuda Katz wrote: >> class Person >> prepend Exclaimer >> end >> >> >> Is there some way to make the relationship more >> visually obvious? >> >> class Person > Exclaimer >> end >> >> class Person >> self >> Exclaimer >> end >> >> >> Hmmm... seems potentially a bit visually confusing. >> I'm happy with prepend, >> in particular if we also make prepend a method on >> Array. >> >> >> I like the idea of the reverse #include but I'm not sure about the >> name. The problem, for me, is that it's *too* array-like. The other >> related operations don't have that same spatial/collection feel to >> them. Somehow prepend doesn't sound like it's in the same semantic >> space as include. >> >> Now I'm supposed to pony up a brilliant alternative :-) include! came >> to mind. The "dangerous" aspect is that it occludes the current >> version of the method. >> >> module M >> def x >> end >> end >> >> class C >> def x >> end >> >> include M # doesn't affect instances >> include! M # blocks this class's same-named methods >> end >> >> Mind you, I've always been intrigued by the idea of ancestors being >> a fully read-write array. But the current semantics of include are not >> very array-like, so I'm not sure about "prepend". >> >> >> We asked Matz about that, and he felt it was a bit *too* much. One major >> problem is that it would affect classes and not just modules, with more >> dubious semantics. >> > > True. > > One question about the prepend idea: > > module M > def x; "M's x"; end > end > > module N > def x; "N's x"; end > prepend M # or whatever it's called :-) > end > > class C > include N > end > > Would N have sacrificed itself, so to speak, to M, so that: > > C.new.x > > would print "M's x"? Yep. But keep in mind that M could call super, which would go to N's x. -- Yehuda > > > > David > > -- > David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com > Ruby/Rails training, mentoring, consulting, code-review > Latest book: The Well-Grounded Rubyist (http://www.manning.com/black2) > > September Ruby training in NJ has been POSTPONED. Details to follow. > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --00c09f8de53148d1880472902166 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <br><br><div class="gmail_quote">On Tue, Sep 1, 2009 at 5:37 PM, David A.lack <span dir="ltr"><dblack / rubypal.com></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> Hi --<div><div></div><div class="h5"><br> <br> On Tue, 1 Sep 2009, Yehuda Katz wrote:<br> <br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br> <br> On Mon, Aug 31, 2009 at 4:09 AM, David A. Black <<a href="mailto:dblack / rubypal.com" target="_blank">dblack / rubypal.com</a>> wrote:<br> ¨ΒΌβςΎ <br> ¨ΒΝοξ¬ ³± Αυ²°°ΉΩεθυδα Λατϊ χςοτεΊΌβςΎ <br> <br> <br> ¨ΒΣυξ¬ Αυ³°²°°Ή ατ ±°Ί°ΠΝΚοεμ ΦαξδεςΧεςζΌβςΎ lt;<a href="mailto:vjoel / path.berkeley.edu" target="_blank">vjoel / path.berkeley.edu</a>><br> ¨ΒςοτεΊΌβς ¨ΒεθυδΛατϊ χςοτεΊΌβςΎ ¨Βμασσ ΠεςσοξΌβςΎ prepend Exclaimer<br> ¨ΒξδΌβςΎ <br> <br> ¨Βτθεςσονε χατο ναλε τθςεματιοξσθιπ νοςεΌβςΎ ¨ΒισυαμμοβφιουσΏΌβςΎ <br> ¨Βμασσ Πεςσοξ ¦ητ» ΕψγμαινεςΌβς ¨ΒξδΌβςΎ <br> ¨Βμασσ ΠεςσοξΌβςΎ self >> Exclaimer<br> ¨ΒξδΌβςΎ <br> <br> ¨Βννν®®® σεενποτεξτιαμμ¤Β ¨Β βι¤Β ¨Βισυαμμγοξζυσιξη®ΌβςΎ ¨Β¦£³Ή»ν θαππχιτθ πςεπεξδ¬ΌβςΎ ¨Βπαςτιγυμας ιζ χε αμσο ναλε πςεπεξνετθοδ οξΌβςΎ ¨Βςςαω®Όβς<br> <br> I like the idea of the reverse #include but I'm not sure about the<br> name. The problem, for me, is that it's *too* array-like. The other<br> related operations don't have that same spatial/collection feel to<br> them. Somehow prepend doesn't sound like it's in the same semantic<br> space as include.<br> <br> Now I'm supposed to pony up a brilliant alternative :-) include! came<br> to mind. The "dangerous" aspect is that it occludes the current<br> version of the method.<br> <br> ¨ΒοδυμΝΌβς ¨Βεζ ψΌβς ¨ΒξδΌβςΎ ¨ΒξδΌβςΎ <br> ¨Βμασσ ΓΌβς ¨Βεζ ψΌβς ¨ΒξδΌβςΎ <br> ¨Βξγμυδε δοεσ³Ή»αζζεγτ ιξσταξγεσΌβς ¨Βξγμυδε βμογλσ τθισ γμασ󦣳Ή»σανεξανεδ νετθοδσΌβς ¨ΒξδΌβςΎ <br> Mind you, I've always been intrigued by the idea of ancestors being<br> a fully read-write array. But the current semantics of include are not<br> very array-like, so I'm not sure about "prepend".<br> <br> <br> We asked Matz about that, and he felt it was a bit *too* much. One major<br> problem is that it would affect classes and not just modules, with more<br> dubious semantics.<br> </blockquote> <br></div></div> True.<br> <br> One question about the prepend idea:<br> <br> ¨ΒοδυμΝΌβς ¨Βεζ ψ» ¦ρυοτ»Ν¦£³Ή»ψ¦ρυοτ»» εξδΌβς ¨ΒξδΌβςΎ <br> ¨ΒοδυμΞΌβς ¨Βεζ ψ» ¦ρυοτ»Ξ¦£³Ή»ψ¦ρυοτ»» εξδΌβς ¨Βςεπεξδ ος χθατεφες ιτ¦£³Ή»σ γαμμεδ Ί©Όβς ¨ΒξδΌβςΎ <br> ¨Βμασσ ΓΌβς ¨Βξγμυδε ΞΌβς ¨ΒξδΌβςΎ <br> Would N have sacrificed itself, so to speak, to M, so that:<br> <br> ¨Β®ξεχ®ψΌβςΎ <br> would print "M's x"?</blockquote><div><br></div><div>Yep. Buteep in mind that M could call super, which would go to N's x.</div><div><br></div><div>-- Yehuda</div><div>/div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> <div><div></div><div class="h5"><br> <br> <br> David<br> <br> -- <br> David A. Black / Ruby Power and Light, LLC / <a href="http://www.rubypal.com" target="_blank">http://www.rubypal.com</a><br> Ruby/Rails training, mentoring, consulting, code-review<br> Latest book: The Well-Grounded Rubyist (<a href="http://www.manning.com/black2" target="_blank">http://www.manning.com/black2</a>)<br> <br> September Ruby training in NJ has been POSTPONED. Details to follow.</div></div></blockquote></div><br><br clear="all"><br>-- <br>Yehuda Katz<br>Developer | Engine Yard<br>(ph) 718.877.1325<br> --00c09f8de53148d1880472902166--