Pre/post question/idea

I agree that it looks better, but my eyes completely skipped over the
replacement def’s. I thought you were just def-ing the same thing 3 times,
and were depending on order to distinguish them, which is obviously a silly
idea.

Nothing against this idea, just noting how my brain reads Ruby code right
now. The x:*** syntax screams special case to me, and this doesn’t.

David
http://homepages.ihug.com.au/~naseby/

···

-----Original Message-----
From: David A. Black [mailto:dblack@wobblini.net]
class C
def x
puts “how are you?”
end

pre x
puts “hello”
end

post x
puts “goodbye”
end
end

Hi –

···

On Fri, 28 Nov 2003, David Naseby wrote:

-----Original Message-----
From: David A. Black [mailto:dblack@wobblini.net]
class C
def x
puts “how are you?”
end

pre x
puts “hello”
end

post x
puts “goodbye”
end
end

I agree that it looks better, but my eyes completely skipped over the
replacement def’s. I thought you were just def-ing the same thing 3 times,
and were depending on order to distinguish them, which is obviously a silly
idea.

Nothing against this idea, just noting how my brain reads Ruby code right
now. The x:*** syntax screams special case to me, and this doesn’t.

My concern is that, as people get used to doing this, x:*** will cease
to be a special case, but will still look like one :slight_smile:

David


David A. Black
dblack@wobblini.net

Hi,

I prefer :pre, :post.

···

In message “Re: pre/post question/idea” on 03/11/28, “David A. Black” dblack@wobblini.net writes:

Nothing against this idea, just noting how my brain reads Ruby code right
now. The x:*** syntax screams special case to me, and this doesn’t.

My concern is that, as people get used to doing this, x:*** will cease
to be a special case, but will still look like one :slight_smile:

That’s the point. Hooking method is a part of metaprogramming, which
should be handled with care, even in the future. x:*** are a good
signs for it.

						matz.

Hi,

I wonder if it would be possible if we could define a syntax for multiple
targets on a wrapping method.
class A
def meth1
puts “do stuff1”
end

def meth2
	puts "do stuff2"
end

def:pre meth1,meth2
	log(args)
end

end

Hmm after writing the example it seems like the

def:pre
def:post

style would show the symantics of this idea through the syntax much nicer
then meth1,meth2 :pre or meth1:pre,meth2:pre.

Of course that last syntax exposes interesting concepts about parallel
method assignment to the same block. I suppose at the moment that is taken
care of with alias, but if you have special syntax on def forms then
alias can’t apply to all methods anymore.

In addition it would probably lots of things, but it just seems that
You could potentially be adding the same pre, post, or wrap method
to most of the classes methods and some method to chain the definition
would be nice.

Clearly it would have potential issues with method arity and such,
But it seemed an intriguing concept.

As a related note, what would happen if you unbound a pre,post,wrap method.
Or the method they hook onto. It seems some clarification on differences
between methods/procs will be in order because these AOP methods aren’t
really either. Are they first class objects as well? Are they full blown
methods? Can you explicitly name a hook and hook it?

I also was thinking that whichever syntax is worked out for this, assuming
some : syntax exists for extensions to def it would also be nice to be able
to overload this, allowing some interesting potential for programmer defined
syntactic forms.

Just some thoughts I had on these ideas that have been bouncing around in my
head.

Charles Comstock

···

-----Original Message-----
From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org]
Sent: Thursday, November 27, 2003 10:42 PM
To: ruby-talk ML
Subject: Re: pre/post question/idea

Hi,

I prefer :pre, :post.

In message “Re: pre/post question/idea” > on 03/11/28, “David A. Black” dblack@wobblini.net writes:

Nothing against this idea, just noting how my brain reads Ruby code
right
now. The x:*** syntax screams special case to me, and this doesn’t.

My concern is that, as people get used to doing this, x:*** will cease
to be a special case, but will still look like one :slight_smile:

That’s the point. Hooking method is a part of metaprogramming, which
should be handled with care, even in the future. x:*** are a good
signs for it.

  					matz.

Hi,

I wonder if it would be possible if we could define a syntax for multiple
targets on a wrapping method.

It would be (and is) covered by AspectR.

As a related note, what would happen if you unbound a pre,post,wrap method.
Or the method they hook onto. It seems some clarification on differences
between methods/procs will be in order because these AOP methods aren’t
really either. Are they first class objects as well? Are they full blown
methods? Can you explicitly name a hook and hook it?

Auxiliary methods are not first class objects, but they are (along
with primary method) attributes of a methods object.

I also was thinking that whichever syntax is worked out for this, assuming
some : syntax exists for extensions to def it would also be nice to be able
to overload this, allowing some interesting potential for programmer defined
syntactic forms.

I don’t know. Flexibility is not always a good thing. It often leas
language designers into temptation.

						matz.
···

In message “pre/post ideas” on 03/11/29, “Charles Comstock” cc1@cec.wustl.edu writes:

LOL! Is somebody writing down all these delightful “Matz-isms?” I think
they’d make great subtitles for the next book about Ruby!

···

On Sun, 30 Nov 2003 00:11:59 +0900, Yukihiro Matsumoto wrote:

I don’t know. Flexibility is not always a good thing. It often leas
language designers into temptation.

  					matz.