I’m a Perl → Python → Ruby convert and new to this mailing list.
I like Ruby very much except for one thing: all those “end” tokens
scattered
everywhere. For my style of coding, they are superfluous and, in my
opinion,
only serve to clutter the code. I very much like Python’s indent blocking
style and would like to use it with Ruby. Indenting does everything I need
it
to do in terms of establishing structure and enhancing readability. Once
you
get used to this style (I’ve been using it for just about all languages and
for longer than Python has existed), delimiter tokens become unnecessary
and
unwanted.
I suppose that it’s not to your liking to simply do something like:
I like Ruby very much except for one thing: all those “end” tokens
scattered
everywhere.
I suppose that it’s not to your liking to simply do something like:
[…]
def myfunc
puts “in myfunc”
puts “finishing”; end
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.
···
On Thursday 08 January 2004 03:24 pm, Mike Wilson wrote:
–
Pete Yadlowsky
ITC Unix Systems Support
University of Virginia
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 parse his code with
Python-like indentation rules, and add delimiters when appropriate.
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.
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
···
On Jan 9, 2004, at 12:31 AM, Joe Mason wrote:
The OP would be better off writing a script to parse his code with
Python-like indentation rules, and add delimiters when appropriate.
I don’t disagree, but that’s precisely why I personally don’t care for
Python’s indentation-based scope.
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.
Oh, but it is possible for there to be a mismatch between the programmer’s
conception and the interpreter’s conception of the scope based on structure.
Simply mix tabs and spaces (evil, but it happens). These are also hard to
find in some editors.
I don’t want my indentation to specify scope. It’s idiotic; I will sometimes
“unindent” code for clarity, just as I will sometimes further indent code
for clarity. In neither case do I want it to be scope.
The OP would be better off writing a script to parse his code with Python-
like indentation rules, and add delimiters when appropriate.
Absolutely, if that’s what the OP wants. Fortunately, this is not
necessarily hard to do (it could probably be done with regexp matching), and
just as fortunately, it seems highly unlikely that Matz will ever make the
mistake that Guido made.
-austin
···
On Fri, 9 Jan 2004 08:31:41 +0900, Joe Mason wrote:
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.
Then stick with Python.
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.
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
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.
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
···
On Fri, Jan 09, 2004 at 08:01:53AM +0900, Hal Fulton wrote:
But I don’t think Ruby will ever have significant whitespace.
Or do what I do: Use Ruby in spite of whatever minor flaws you might
perceive in it.
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.
But I don’t think Ruby will ever have significant whitespace.
Well, we can always ask. You never know.
···
On Thursday 08 January 2004 06:01 pm, Hal Fulton wrote:
–
Pete Yadlowsky
ITC Unix Systems Support
University of Virginia
Back in 1985 the company I work for decided to rewrite its entire PL/I
code base in the then-new “C” programming language. PL/I, if you’re not
familiar with it, uses DO and END keywords to delimit blocks.
The programmers didn’t like C’s new-fangled brace-delimited blocks, so
they all created little header files with two macros:
#define DO { #define END }
and started coding
if (x > 0) DO
/* stuff */
END
and were happy. For about a month, after which they collectively said
“screw it, you can’t make C into PL/I no matter how much preprocessing you
do”, deleted the header files, and started using braces.
···
On Fri, 09 Jan 2004 09:44:33 +0900, Ralph Mason wrote:
On Fri, 9 Jan 2004 12:59:47 +0900, Pete Yadlowsky wrote:
On Thursday 08 January 2004 10:49 pm, Austin Ziegler wrote:
The OP would be better off writing a script to parse his code with
Python- like indentation rules, and add delimiters when appropriate.
Absolutely, if that’s what the OP wants.
OP?
Back in 1985 the company I work for decided to rewrite its entire PL/I
code base in the then-new “C” programming language. PL/I, if you’re not
familiar with it, uses DO and END keywords to delimit blocks.
The programmers didn’t like C’s new-fangled brace-delimited blocks, so
they all created little header files with two macros:
#define DO { #define END }
and started coding
if (x > 0) DO
/* stuff */
END
and were happy. For about a month, after which they collectively said
“screw it, you can’t make C into PL/I no matter how much preprocessing you
do”, deleted the header files, and started using braces.
I wish the reverse about Ruby, if I could change one thing it would be
it’s block structure so I could write
class Foo{
def foo(x){
#code
}
}
{ x+=12; y=9 } if a > b
if x {
do_this_and_that()
z=z+1;
}
All the other languages I work with are really ‘c’ style, and ruby is
kind of but not really.
Ralph
···
On Fri, 09 Jan 2004 09:44:33 +0900, Ralph Mason wrote:
Well, newlines in a line/expression-oriented language aren’t a big deal. I
am bothered a bit by the foo( and foo ( discrepancy, even though I
personally prefer the former by far.
-austin
···
On Fri, 9 Jan 2004 08:04:38 +0900, Tim Bates wrote:
On Fri, Jan 09, 2004 at 08:01:53AM +0900, Hal Fulton wrote:
But I don’t think Ruby will ever have significant whitespace.
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.