Professional Web Applications Themes

block delimiting - Ruby

  I suppose that it's not to your liking to simply do something like: $ cat test.rb puts "hello" def myfunc puts "in myfunc" puts "finishing"; end def iffunc something = false something_else = true if something == true puts "in an if" elsif something_else == true puts "nope, I'm here"; end puts "ending iffunc"; end myfunc iffunc puts "done" $ ./test.rb hello in myfunc finishing nope, I'm here ending iffunc done Visually, it's the same effect, IMHO... __________________________________________________ _______________ Make your home warm and cozy this winter with tips from MSN House & Home. http://special.msn.com/home/warmhome.armx...

  1. #1

    Default Re: block delimiting

     


    I suppose that it's not to your liking to simply do something like:

    $ cat test.rb
    puts "hello"

    def myfunc
    puts "in myfunc"
    puts "finishing"; end

    def iffunc
    something = false
    something_else = true

    if something == true
    puts "in an if"
    elsif something_else == true
    puts "nope, I'm here"; end

    puts "ending iffunc"; end

    myfunc
    iffunc
    puts "done"

    $ ./test.rb
    hello
    in myfunc
    finishing
    nope, I'm here
    ending iffunc
    done


    Visually, it's the same effect, IMHO...

    __________________________________________________ _______________
    Make your home warm and cozy this winter with tips from MSN House & Home.
    http://special.msn.com/home/warmhome.armx


    Mike Guest

  2. #2

    Default Re: block delimiting

    On Thursday 08 January 2004 03:24 pm, Mike Wilson wrote: 
     [/ref]
     

    [...] 

    Better, but no cigar I'm afraid. One of the things that makes Python so
    clean-looking is the total absence of block delimiters. That's what I'm going
    for. I also like not having to remember to add them. If it looks right
    block-indent-wise, it is right syntax-wise. I want that immediate visual
    connection. Thanks, though.

    --
    Pete Yadlowsky
    ITC Unix Systems Support
    University of Virginia


    Pete Guest

  3. #3

    Default Re: block delimiting

    On Fri, 9 Jan 2004 04:33:15 +0900, Pete y wrote: 

    I chose not to learn Python because of the crap called syntactically
    significant whitespace. Python's blocking solves the problem of readable
    code the wrong way.

    (In other words, I'm quite glad that Ruby hasn't sucbed to that
    particular insanity.)

    -austin
    --
    austin ziegler * ca * Toronto, ON, Canada
    software designer * pragmatic programmer * 2004.01.08
    * 15.43.45



    Austin Guest

  4. #4

    Default Re: block delimiting

    On Thursday 08 January 2004 03:46 pm, Austin Ziegler wrote:
     

    I avoided Python also, for the same reason. Then one day I decided to dive in
    and learn it anyway in spite of myself. And I found I rather liked it. The
    taboo of significant whitespace turned out to be a big non-issue very early
    in my study. I'd been coding that way for years anyway, just with superfluous
    block delimiters of various sorts. Python made them unnecessary. It's my hope
    that Ruby might keep them that way. Then it will be perfect.
     

    What's the right way?


    --
    Pete Yadlowsky
    ITC Unix Systems Support
    University of Virginia



    Pete Guest

  5. #5

    Default Re: block delimiting

    Pete Yadlowsky wrote: 
    >
    >
    > I avoided Python also, for the same reason. Then one day I decided to dive in
    > and learn it anyway in spite of myself. And I found I rather liked it. The
    > taboo of significant whitespace turned out to be a big non-issue very early
    > in my study. I'd been coding that way for years anyway, just with superfluous
    > block delimiters of various sorts. Python made them unnecessary. It's my hope
    > that Ruby might keep them that way. Then it will be perfect.
    >

    >
    >
    > What's the right way?
    >
    >[/ref]

    It looks like an invitation to a flame war. If you are so sensitive to
    "end" delimiters that it became the first "problem" you decided to
    discuss as a newby, than may be Ruby is not for you (or you are not for
    Ruby). Delimiters are the least "frustration" you will feel if you
    expect Ruby to be like Python (or anything else).

    Gennady.


    Gennady Guest

  6. #6

    Default Re: block delimiting

    In article <com>, Mike Wilson wrote: 

    Oh, god, that's hard to follow!

    That means if you forget an end, you get a weird broken block structure
    that could do anything. The whole point of Python's delimiting is that
    it's not possible to have a mismatch between what the programmer and the
    interpreter think the structure is.

    The OP would be better off writing a script to p his code with
    Python-like indentation rules, and add delimiters when appropriate.

    Joe
    Joe Guest

  7. #7

    Default Re: block delimiting

    Pete Yadlowsky wrote: 

    Then stick with Python.

    -Kent


    Kent Guest

  8. #8

    Default Re: block delimiting

    Pete Yadlowsky <edu> wrote: 
    >
    > What's the right way?[/ref]

    Take a look at Haskell sometime.

    martin
    Martin Guest

  9. #9

    Default Re: block delimiting

    Kent R. Spillner wrote: 
    >
    >
    > Then stick with Python.[/ref]

    Or do what I do: Use Ruby in spite of whatever minor flaws you might
    perceive in it.

    It will never satisfy everybody. Happily, it will never even
    satisfy Matz, who I expect will keep improving it for a long
    time.

    But I don't think Ruby will ever have significant whitespace.


    Hal



    Hal Guest

  10. #10

    Default Re: block delimiting

    On Fri, Jan 09, 2004 at 08:01:53AM +0900, Hal Fulton wrote: 

    Except for newlines, which have been significant from the beginning
    because of Ruby's line-based syntax, and spaces before parentheses in
    argument lists, which are a common source of FAQs. But we know what you
    meant. ;)

    Tim Bates
    --
    id.au

    Tim Guest

  11. Moderated Post

    Default Re: block delimiting

    Removed by Administrator
    Ralph Guest
    Moderated Post

  12. #12

    Default Re: block delimiting

    On Thursday 08 January 2004 06:01 pm, Hal Fulton wrote: 
     
    >
    > Or do what I do: Use Ruby in spite of whatever minor flaws you might
    > perceive in it.[/ref]

    That's what I'm doing now. In fact, that's what I've done with every language
    I've ever written in. But I'm still going to offer the occasional suggestion
    for improvement. There's no guarantee it'll get implemented, but it's
    guaranteed that it won't if no one speaks up.
     

    Well, we can always ask. You never know.

    --
    Pete Yadlowsky
    ITC Unix Systems Support
    University of Virginia



    Pete Guest

  13. Moderated Post

    Default Re: block delimiting

    Removed by Administrator
    Bermejo, Guest
    Moderated Post

  14. #14

    Default Re: block delimiting

    On Jan 9, 2004, at 12:31 AM, Joe Mason wrote:
     

    Just out of curiosity, is it possible to write source filters in Ruby?
    Damian Conway has a module that in 54 lines provides the Python
    convention for Perl:

    use Language::Pythonesque; # this semicolon yet needed

    sub foo
    my $x = shift
    $x*2

    for my $i (1..10)
    print foo $i
    print "\n"

    print "OK, it works.\n"

    How devil!!!!

    -- fxn



    Xavier Guest

  15. #15

    Default Re: block delimiting

    Xavier Noria wrote:
     

    I am sure you could do something like

    require 'make_me_like_python'

    ptyhon_it <<PYTHON_LIKE
    def foo(x)
    puts(x)

    foo("hello world")

    PYTHON_LIKE

    the python_it just adds ends when indentation decreases.

    I am also so sure that someone else on the list will have far simpler
    way to doing this.

    Ralph



    Ralph Guest

  16. #16

    Default Re: block delimiting

    In article <ohlLb.97572$6b2.497edtnps84>, Martin DeMello wrote: 
    >>
    >> What's the right way?[/ref]
    >
    > Take a look at Haskell sometime.
    >
    > martin[/ref]

    My impression was that Haskell and Python treated this issue in
    essentially the *same* way: consecutive lines with the same
    indentation are part of the same block, and a following line with less
    indentation implicitly ends the preceding block. So what do you think
    is the difference? (Not flamebait, I'd really like to know.)

    Cheers,

    Jeremy Henty

    Jeremy Guest

  17. Moderated Post

    Default Re: block delimiting

    Removed by Administrator
    Tim Guest
    Moderated Post

  18. #18

    Default Re: block delimiting

    On Friday, 9 January 2004 at 8:04:38 +0900, Tim Bates wrote: 
    >
    > Except for ... spaces before parentheses in argument lists[/ref]

    Can you provide an example, I'm not sure what you mean.

    --
    Jim Freeze
    ----------
    Q: How many IBM CPU's does it take to execute a job?
    A: Four; three to hold it down, and one to rip its head off.


    Jim Guest

  19. #19

    Default Re: block delimiting

    >-----Original Message----- 
    >
    >Can you provide an example, I'm not sure what you mean.
    >[/ref]
    D:\ruby18\bin>ruby -ve 'puts ("hi")'
    ruby 1.8.0 (2003-08-04) [i386-mswin32]
    -e:1: warning: (...) interpreted as grouped expression
    hi

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

    David Guest

  20. Moderated Post

    Default Re: block delimiting

    Removed by Administrator
    Ralph Guest
    Moderated Post

Page 1 of 3 123 LastLast

Similar Threads

  1. IP Block
    By Med Marijuana in forum Macromedia Dynamic HTML
    Replies: 7
    Last Post: April 30th, 05:33 PM
  2. delimiting table size
    By Evertjan. in forum ASP Database
    Replies: 6
    Last Post: May 6th, 06:29 PM
  3. block specified ip
    By R C P in forum Web Design
    Replies: 1
    Last Post: December 26th, 02:21 PM
  4. Replies: 0
    Last Post: January 8th, 08:52 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