pre/post question/idea

D

David A. Black

Hello --

As we're still pre-2.0, and talking about pre and post, I thought I'd
throw in a bit of possible syntax for this that occurred to me, namely
this:

class C
def x
puts "how are you?"
end

pre x
puts "hello"
end

post x
puts "goodbye"
end
end

It's possible that there are problems with doing it this way that I'm
not seeing, but personally I like the way it looks better than

def x:pre

which to me has a bit of a "spliced onto the language" feel (which
perhaps it is, but it would still be nice to avoid that feel :) I
like the simplicity and symmetry of separate def/pre/post.


David
 
T

T. Onoma

As we're still pre-2.0, and talking about pre and post, I thought I'd
throw in a bit of possible syntax for this that occurred to me, namely
this:

class C
def x
puts "how are you?"
end

pre x
puts "hello"
end

post x
puts "goodbye"
end
end

It's possible that there are problems with doing it this way that I'm
not seeing, but personally I like the way it looks better than

def x:pre

which to me has a bit of a "spliced onto the language" feel (which
perhaps it is, but it would still be nice to avoid that feel :) I
like the simplicity and symmetry of separate def/pre/post.

Sorry David, your a little late to make claims on that one. If you read my AOP
RCR (which by the way I think I've plugged like six times now) you would
notice that I offer:

wrap w
super
print "W"
end

as a backup alternative to my primary proposal, which I belive to be a far
superior:

class C
def x
puts "how are you?"
end

def x
puts "hello"
super
puts "goodbye"
end
end

Before anyone looks at this and crys "foul!", read the dang RCR.

http://www.rubygarden.org/ruby?AspectOrientedRuby

-t0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top