Wish: Python-style indenting

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

Jon

I rather prefer having a clear delimiter like “end”. I don’t like
Pytnon’s method. It looks like blocks are just “dangling”. I think that
“end” adds readability. I like “end” better than “}”, so that’s a plus
for Ruby in my book. Even when I write blocks, I use do…end instead of
{…} (except for one-liners).

I also like flexible syntax:

  1. iterator { some block }
  2. puts “hello” if condition
  3. def twice() yield; yield; end

These are lost by Python’s syntax. I think that flexibility is worth the
price of an “end”. But then again, I also think that “end” is a good
thing on itself.

Though I guess you can argue that Python does support the “end” feature if
you want:

if (condition): #do
print “He he he”
#end

:slight_smile:

···

On Mon, Aug 18, 2003 at 07:19:22AM +0900, Jonathan Aquino wrote:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

Jon


Daniel Carrera, Math PhD student at UMD. PGP KeyID: 9AF77A88
.-“~~~”-. On the menu of a Swiss restaurant:
/ O O \ “Our wines leave you nothing to hope for”
: s :
\ _/ / Sign outside a Hong Kong tailor shop:
`-.
_.-’ “Ladies may have a fit upstairs”

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

I wish Pythan had Ruby’s use of delimiters to indicate blocks. Then I
wouldn’t see all these lines that simply seem to lack structure.

nikolai

···


::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,php,war3 :::
main(){printf(&linux[“\021%six\012\0”],(linux)[“have”]+“fun”-97);}

Hi,

···

In message “Wish: Python-style indenting” on 03/08/18, Jonathan Aquino Jon_Aquino@shaw.ca writes:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

You are free to wish, but the change makes Ruby no longer Ruby. :wink:
Ruby is a open source language, you can hack its syntax, and see how
well it goes by yourself.

						matz.

Jon_Aquino@shaw.ca (Jonathan Aquino) writes:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

Check the archives through Google or www.ruby-talk.org. IIRC, an
Emacs module was posted some time ago that lets you do that.

Jon_Aquino@shaw.ca (Jonathan Aquino) wrote:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

I can happily say after tutoring a 3rd year university Python course and
using Ruby in my spare time, I’d go the Ruby-way! I made this decision
only after a painfully long hard stare at a piece of malfunctioning
Python code written by one of my top students – the problem was a
single level of indentation and it was difficult to spot, even though
we’d tracked it down to a 10-line method! Gah! >:\

···


Greg McIntyre ======[ greg@puyo.cjb.net ]===[ http://puyo.cjb.net ]===

I also like flexible syntax:

  1. iterator { some block }
  2. puts “hello” if condition
  3. def twice() yield; yield; end

Definately don’t forget this:

array.map do |e|
“foo” << e << “foo”
end.sort

You can’t chain onto the end of a block easily without a delimiter.

Ari

Daniel Carrera graced us by uttering:

I also like flexible syntax:

  1. iterator { some block }
for item in iterator: some(statements); separated; by(semicolons)
  1. puts “hello” if condition
if condition: print "hello"

(This doesn’t really seem to be an issue of declaring blocks,
but…)

  1. def twice() yield; yield; end

While the yield operator might function quite differently in
Python, function definition remains fairly similar:

def twice(): somefunc(); a_keyword; a_func()

FWIW,
Tim Hammerquist

···


“Elbonians are our best friends.
Now excuse me while I tenderize myself.”
– Ratbert

I think it’s this code:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/59727

– fxn

···

On Monday 18 August 2003 13:20, Massimiliano Mirra - bard wrote:

Jon_Aquino@shaw.ca (Jonathan Aquino) writes:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then
I wouldn’t see all these lines that simply say “end” or “}”.

Check the archives through Google or www.ruby-talk.org. IIRC, an
Emacs module was posted some time ago that lets you do that.

We could call it PyRuby :wink: The best of both worlds.

Jon

matz@ruby-lang.org (Yukihiro Matsumoto) wrote in message news:1061185278.585164.10529.nullmailer@picachu.netlab.jp

···

Hi,

In message “Wish: Python-style indenting” > on 03/08/18, Jonathan Aquino Jon_Aquino@shaw.ca writes:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

You are free to wish, but the change makes Ruby no longer Ruby. :wink:
Ruby is a open source language, you can hack its syntax, and see how
well it goes by yourself.

  					matz.

Thank you for that post. This is a good thing to know. I also teach at
university and I hope to incorporate Ruby some day. So your experience is
valuable.

Do you have that piece of code handy? It would be good to see that
example.

Yes, I do prefer Ruby’s way. The “end” does not make the code any uglier,
and it does remove some ambiguity from the code (I think).

···

On Tue, Sep 02, 2003 at 10:10:25AM +0900, Greg McIntyre wrote:

Jon_Aquino@shaw.ca (Jonathan Aquino) wrote:

I wish Ruby had Python’s use of whitespace to indicate blocks. Then I
wouldn’t see all these lines that simply say “end” or “}”.

I can happily say after tutoring a 3rd year university Python course and
using Ruby in my spare time, I’d go the Ruby-way! I made this decision
only after a painfully long hard stare at a piece of malfunctioning
Python code written by one of my top students – the problem was a
single level of indentation and it was difficult to spot, even though
we’d tracked it down to a 10-line method! Gah! >:\


Daniel Carrera, Math PhD student at UMD. PGP KeyID: 9AF77A88
.-“~~~”-.
/ O O \ ATTENTION ALL PASCAL USERS:
: s :
\ _/ / To commemorate the anniversary of Blaise Pascal’s
`-.
_.-’ birth (today) all your programs will run at half speed.

Pythonistas would see that as bad style anyway.

Gavin

···

On Monday, August 18, 2003, 8:35:30 AM, Aredridel wrote:

I also like flexible syntax:

  1. iterator { some block }
  2. puts “hello” if condition
  3. def twice() yield; yield; end

Definately don’t forget this:

array.map do |e|
“foo” << e << “foo”
end.sort

You can’t chain onto the end of a block easily without a delimiter.

Jon_Aquino@shaw.ca (Jonathan Aquino) writes:

We could call it PyRuby :wink: The best of both worlds.

How about Pyby? Or Ruthon? :slight_smile:

frank

···


Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frank DOT schmitt AT 4sc DOT com

Yes, because [“foo” + e + “foo” for e in array] is much more readable,
especially in a code otherwise written with an OO paradigm. Ugh.

(I realize that’s not equivalent, but, I don’t know how to do
non-in-place sorting in Python (well, without writing my own qsort
function.). But it gets my point across.)

···

On Sun, 2003-08-17 at 19:54, Gavin Sinclair wrote:

On Monday, August 18, 2003, 8:35:30 AM, Aredridel wrote:

Definately don’t forget this:

array.map do |e|
“foo” << e << “foo”
end.sort

You can’t chain onto the end of a block easily without a delimiter.

Pythonistas would see that as bad style anyway.


Joe Wreschnig piman@sacredchao.net, bitter about Python code today

Coralsnake (http://www.santarosa.edu/lifesciences/coralsn1.gif)

Serpentine (http://www.gemcountryusa.com/gemstones/images5/57273.jpg)

martin

···

Frank Schmitt frank.schmitt@4sc.com wrote:

Jon_Aquino@shaw.ca (Jonathan Aquino) writes:

We could call it PyRuby :wink: The best of both worlds.

How about Pyby? Or Ruthon? :slight_smile:

Martin DeMello martindemello@yahoo.com wrote in message news:g5p1b.7717$ho5.107065@news2.telusplanet.net

···

Frank Schmitt frank.schmitt@4sc.com wrote:

Jon_Aquino@shaw.ca (Jonathan Aquino) writes:

We could call it PyRuby :wink: The best of both worlds.

How about Pyby? Or Ruthon? :slight_smile:

Coralsnake (http://www.santarosa.edu/lifesciences/coralsn1.gif)

Serpentine (http://www.gemcountryusa.com/gemstones/images5/57273.jpg)

martin

Hey, I think there’s starting to be some serious interest here in
something we’ll call Coralsnake – a Ruby-Python hybrid. It will end
the Ruby-Python debate by combining the two. It follows the Japanese
idea of “kaizen” (continuous improvement). (Maybe “Ruthon” is
clearer…).

Parrot should cut that particular Gordian knot, no? I think the ideal
situation would be where we can call python code without needing to
change ruby (though I’d love to see native list comprehensions and
non-continuation-based generators :))

martin

···

Jonathan Aquino Jon_Aquino@shaw.ca wrote:

Hey, I think there’s starting to be some serious interest here in
something we’ll call Coralsnake – a Ruby-Python hybrid. It will end
the Ruby-Python debate by combining the two. It follows the Japanese
idea of “kaizen” (continuous improvement). (Maybe “Ruthon” is
clearer…).