Professional Web Applications Themes

[RFC] 'via' proposal - Ruby

Hello! Well, just a thought... Consider that: 1000.times do |a, b, c| a = ... b = ... c = ... bar a bar b bar c foo end Okay, this is a bad design, but let's say that I can't change it. Can a Ruby syntax structure like the one below constructed in an (almost) easy way? via bar foo do |a, b, c| a = ... b = ... c = ... end i.e. can I construct in pure Ruby or via a C extension a 'via' method for Object, which will enhance: foo do { |...| ... ...

  1. #1

    Default [RFC] 'via' proposal

    Hello!

    Well, just a thought... Consider that:

    1000.times do |a, b, c|
    a = ...
    b = ...
    c = ...
    bar a
    bar b
    bar c
    foo
    end

    Okay, this is a bad design, but let's say that I can't change
    it. Can a Ruby syntax structure like the one below constructed
    in an (almost) easy way?

    via bar foo do |a, b, c|
    a = ...
    b = ...
    c = ...
    end

    i.e. can I construct in pure Ruby or via a C extension a 'via'
    method for Object, which will enhance:

    foo do { |...| ... }

    in a way, that all block arguments will be passed in another
    method before the end of the block?

    If all these do not make sense, just forgive me. It's night
    here. :-)

    Regards,
    --
    University of Athens I bet the human brain
    Physics Department is a kludge --Marvin Minsky




    Elias Guest

  2. #2

    Default Re: [RFC] 'via' proposal

    On Sun, 8 Feb 2004 04:37:28 +0900
    Elias Athanasopoulos <uoa.gr> wrote:
     

    I'm not sure what's "bad design" about it... there's not really enough
    to tell what you're actually doing. If you want fewer lines, you can
    always:

    1000.times { |a, b, c|
    a = bar(...)
    b = bar(...)
    c = bar(...)
    foo
    }

    Fewer lines or more lines isn't directly related to how good or bad a
    design is though.
     
    <snip> 

    I really can't tell what you're trying to do here... please provide
    more details about the actual problem at hand: what you're doing, what
    you're trying to accomplish in the end (not just how you're trying to
    accomplish it). My guess is there's an easier way.

    To answer your question, though, you can always write a function that
    takes a block as a parameter. However, you can't directly manipulate
    the code inside; otoh, I'm guessing you don't really need to.

    --
    Ryan Pavlik <com>

    "As in the case of CLAMZILLA..." - 8BT


    Ryan Guest

  3. #3

    Default Re: [RFC] 'via' proposal

    On Mon, Feb 09, 2004 at 12:48:56PM +0900, Mehr, Assaph (Assaph) wrote: 

    That was very close to what I wanted, thanx. :-)

    Regards,
    --
    University of Athens I bet the human brain
    Physics Department is a kludge --Marvin Minsky




    Elias Guest

Similar Threads

  1. 'with' proposal
    By Elias Athanasopoulos in forum Ruby
    Replies: 4
    Last Post: November 22nd, 06:44 PM
  2. URGENT PROPOSAL
    By Mrs Eki Omorodion in forum PHP Development
    Replies: 1
    Last Post: August 18th, 11:30 PM
  3. OT: a proposal...
    By Victoria in forum Macromedia Dreamweaver
    Replies: 10
    Last Post: July 31st, 06:35 PM
  4. Proposal system
    By Frank Dulk in forum Microsoft Access
    Replies: 0
    Last Post: July 21st, 12:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139