[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How Well does Ruby support Aspect Oriented Programming?

GFunk913

12/29/2005 7:39:00 AM

Here's my question, I would really appreciate input from the list.

What is the most basic, narrowest AOP feature that Ruby can not support
without language extensions?

Take "support" to be a very broad term. If Ruby can effectively
provide the same functionality, but perhaps with a different syntax or
with a reasonable number of "hoops," that's fine.

For reference, here are 2 wiki pages that prompted this question. My
contention, based on my very limited knowledge of Ruby and AOP, is that
some/many of the language extensions proposed here are not necessary,
but I would be happy to be proven wrong. I really just want input from
the group.

http://www.rubygarden.org/ruby?AspectOr...
http://www.rubygarden.org/ruby?AspectOr.../NotesRoughDrafts

What follows is the thought process that drove me to ask this question
of the group
---------------------------

>From the first link, here is a code example involving a "cut," a
proposed language extension

-------------

cut A < C
def m1
print '{', super, '}'
end
end

C.new.m1 #=> {1}

-------------

I believe anything accomplished here can just as easily be accomplished
by aliasing the existing m1 method, and (re)def'ing C#m1, calling the
old method (via the alias) from the new. Obviously, taking my example
literally, that's far too much work for a common construct. The
systemized, native ruby version of that would look something as
follows, with wrap method being a method on Object utilizing the eval
methods (i.e. metaprogramming). I have a working implementation of
both of these methods.

class C
wrap_method (m1), { |this,old_method,*args| "(" +
old_method(*args).to_s + ")" }
end

A similar method takes 2 blocks, with the first determining what
methods to wrap

class C
wrap_matching_methods { |method| method == "m1" } {
|this,old_method,*args| "(" + old_method(*args).to_s + ")" }
end

Clearly, the code from the article I quoted is merely a simple example,
and does not encompass all functionality. I use it as a cherry-picked
example.

I look forward to everyone's input

Thanks,
Mike

1 Answer

eddieVroom

2/15/2008 12:46:00 AM

0

jerald wrote:
> On Feb 14, 5:36 pm, anonymousAltF4 <anonma...@gmail.com> wrote:
>> On Feb 14, 4:15 pm, jerald <jerald-ja...@hotmail.com> wrote:
>>
>>
>>
>>
>>
>>> Monday I am making a visit to the Farmington Hills Police Department
>>> to ask a few questions.
>>> 1. Does city, county or state law ban the wareing of masks at civil
>>> protests?
>>> 2. Can a police officer refuse to let you take a picture or video
>>> tape him if he is there around the protesters?
>>> Will you put in writing the answers to these questions so we may refer
>>> to them on a picket site if a officer asks us to do any of the about
>>> again?
>>> Do you have any other questions from the protest you would like to
>>> have me ask? If the police won't answer me I have put aside enough
>>> funds to visit a lawer ahead of the next picket.
>>> I asked everyone to remove the masks on Sunday because I just didn't
>>> know the answers. Same with the pictures of the officers. Better to
>>> do as asked and find out the real facts later. It could be the
>>> officers didn't really understand or know the answers themselves.
>>> So lets have all the right info ready next time.
>>> jerald
>> Make sure you talk to either a criminal defense lawyer or a
>> constitutional rights lawyer (e.g. one who knows about 1st Amd). Any
>> lawyer can find out the answers for you, but you'll save money by
>> talking to one who actually works with these issues.- Hide quoted text -
>>
>> - Show quoted text -
>
> I intend to. But there may be other questions the anon here wanted
> asked and I want all the ducks in a roll next time so we don't have to
> deal with the BS.

Getting a statement on the issue from the police would be useful. But
consider that to be a statement of Policy, not the legal and practical
issues behind the policy. You might be able to induce a policy change if
needed.

--
the Tortured Spark - a Light in the Dark
the Mystical RevvedErrand Doktor eddieVroom
Northern Lights Motor Lodge
Knights of the Visible Wank-L

http://psyop13013.blo...

He only comes out when I drink my Djinn...