Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
easy AOP right now using evil.rb
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Eric Mahurin  
View profile  
 More options Oct 21 2005, 3:51 pm
Newsgroups: comp.lang.ruby
From: Eric Mahurin <eric_mahu...@yahoo.com>
Date: Sat, 22 Oct 2005 04:51:40 +0900
Local: Fri, Oct 21 2005 3:51 pm
Subject: easy AOP right now using evil.rb
Here is a pure ruby soluntion to doing AOP.  You just need one
little method from evil.rb: Object#become.  sub-classing and
then having the parent "become" the child is very similar to
the proposed "cut" (not sure about some of the management
facilities).  Anyways, as soon as you require 'evil.rb' you
pretty much have it.  You can get evil.rb here:

http://rubyforge.org/cgi-bin/viewcvs.cgi/evil/lib/evil.rb?cvsroot=evil

Here is a demo using this to get AOP:

require 'evil'

class A
  def foo;"A";end
end

a = A.new
a.foo # => "A"

# first level "cut"
class B < A.clone # need a clone to prevent a loop
  def foo;"["+super+"]";end
end
A.become(B) # replace parent with subclass

a.foo # => "[A]"

# second level "cut"
class C < A.clone
  def foo;"{"+super+"}";end
end
A.become(C)

a.foo # => "{[A]}"

# restore the original functionality
A.become(B.superclass)

a.foo # => "A"

module Brackets
  def foo;"["+super+"]";end
end

# "preclude"-like functionality
class D < A.clone
  include Brackets
end
A.become(D)

a.foo # => "[A]"

Of course if we had this, it would be better to have a safer
Class#replace and that be able to break circular loops
automatically instead of having to use #clone to break the loop
manually.

__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Vanbroekhoven  
View profile  
 More options Oct 21 2005, 4:17 pm
Newsgroups: comp.lang.ruby
From: Peter Vanbroekhoven <calamita...@gmail.com>
Date: Sat, 22 Oct 2005 05:17:07 +0900
Local: Fri, Oct 21 2005 4:17 pm
Subject: Re: easy AOP right now using evil.rb

Ah yes, this is what I expected.

We have been there you know. There's a reason why we've got a C version of
Florian's Object#become method on the Suby page. The problem with this
version is that A has become B. This means that the code that previously
defined, redefined and undefined methods in the original A, does that in B
now. The problem is that it is not possible to add a wrapper class this
way without breaking existing code, or at least without that code messing
with your advice. The behavior is almost the same, except that code needs
to be adapted to use these wrapper classes, and the basic idea behind AOP
is that that should *not* be so. We used this as an early test, but in the
end it had to go because it is obtrusive.

I'm sorry, but we're two years ahead of you you know.

Peter


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Trans  
View profile  
 More options Oct 21 2005, 4:57 pm
Newsgroups: comp.lang.ruby
From: "Trans" <transf...@gmail.com>
Date: 21 Oct 2005 13:57:45 -0700
Local: Fri, Oct 21 2005 4:57 pm
Subject: Re: easy AOP right now using evil.rb

> I'm sorry, but we're two years ahead of you you know.

Nonetheless. I am impressed that you thought of that Eric. You must
really be giving this a lot of thought. Give cuts some more careful
consideration. I am sure will ultimately come to understand why we
believe in them so.

T.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google