pre/post ideas

Discussion in 'Ruby' started by Charles Comstock, Nov 28, 2003.

  1. 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:]
    > 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" <> 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 :)
    >
    > 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.
    Charles Comstock, Nov 28, 2003
    #1
    1. Advertising

  2. Hi,

    In message "pre/post ideas"
    on 03/11/29, "Charles Comstock" <> writes:

    |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.
    Yukihiro Matsumoto, Nov 29, 2003
    #2
    1. Advertising

  3. Charles Comstock

    Tim Hunter Guest

    Matz-isms (was Re: pre/post ideas

    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.


    LOL! Is somebody writing down all these delightful "Matz-isms?" I think
    they'd make great subtitles for the next book about Ruby!
    Tim Hunter, Nov 29, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rocky Moore
    Replies:
    7
    Views:
    1,719
    mikeb
    Jan 14, 2004
  2. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,030
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  3. Wladimir Borsov
    Replies:
    7
    Views:
    464
    Raymond Loman
    May 5, 2004
  4. Juha Nieminen
    Replies:
    3
    Views:
    1,130
    Juha Nieminen
    Feb 22, 2008
  5. Chris M. Thomasson
    Replies:
    10
    Views:
    638
    Nobody
    Aug 29, 2009
Loading...

Share This Page