Ruby could be wildly more popular if it had

“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message news:60107.203.185.214.34.1059543084.squirrel@webmail.imagineis.com

···

On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:

My solution is to use {} for one line blocks and do…end for more
complicated things.

I tried this style for a while. But then every time I added lines to a
one-line block, I had to change {} to do/end.

Today I normally used {} on all blocks, except in Rake files.

My take is: {} are for functional blocks; do…end for procedural blocks.
That shows me which expressions are important for their results, and which
are not.

Gavin

This sounds very interesting. Can you expand upon this a little?
What do you take as the difference between procedural blocks and
funcitonal blocks? Can you provide an example?

Thanks,

Arthur

Vim can match do/end blocks, and folding is already done by it.

-austin

···

On Thu, 31 Jul 2003 01:37:46 +0900, Garance A Drosihn wrote:

At 12:29 PM +0900 7/30/03, Aredridel wrote:
The one nice thing about brackets is that editors know how to match them
up. Ie, I can select a section of code by just double-clicking on the
initial or ending bracket.


austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.08.01
* 13.09.40

Oh. :frowning: Now you offended me and my goatee.

/Madsen

···

On Thu, 31 Jul 2003 06:47:38 +0900 why the lucky stiff ruby-talk@whytheluckystiff.net wrote:

Moustaches and goatees.

Brackets of the mouth.

               Anders K. Madsen 
               http://lillesvin.linux.dk                 |

There are 10 types of people in the world… |
Those who understand binary - and those who don’t.
- http://bash.org |

[snip “all the fun stuff”]

ROFLMAO!
Brilliant, but wouldn’t it make Ruby be just a little too much like languages
like Whitespace, BrainFuck and the likes?

/Madsen

···

On Thu, 31 Jul 2003 09:50:11 +0900 Florian Frank flori@nixe.ping.de wrote:

On 2003-07-31 05:59:42 +0900, james_b wrote:

Becauae of the obvious criitcal differences between ( ) and { }.

I don’t like either of them. Because of the motto “Ruby makes
programming fun again”, we should opt for something like that instead:

               Anders K. Madsen 
               http://lillesvin.linux.dk                 |

There are 10 types of people in the world… |
Those who understand binary - and those who don’t.
- http://bash.org |

Yes, but have you seen what a guy with a do…end around his mouth looks
like? Trust me, it’s not a pretty sight!

martin

···

why the lucky stiff ruby-talk@whytheluckystiff.net wrote:

Moustaches and goatees.

Brackets of the mouth.

Hi,

A programmer’s feeling is important to him/herself… It does not mean
that PHP is bad because I think it is bad :slight_smile:

I don’t know any PHP debugger. I write A LITTLE php directly on Apache
and debug in IE.

Your reason defending the ; is not well established :slight_smile: Please note ruby
also support ; if you want to write multiple lines of code on one line.
Javascript also support OPTIONAL ;

So it is better on this regard. By the way, I have never seen a
programmer who write code in Microsoft Word, so, the statement that a “;”
is usuful to the program that it will “survive a word processor” sounds
strange to me.

Shannon

···

On Thu, 31 Jul 2003 13:33:45 +0900 “maillist@bestworldweb.homelinux.commaillist@bestworldweb.homelinux.com wrote:

I have used PHP… it is Sh*t… mainly because of the “;”. A lot of

Have you used a PHP debugger? Or do you just click the refresh button in
Mozilla? You cant say a language is s**h just because you use ; . In PHP
the ; is very useful eg.

<?php $result=$db->getOne(); echo $value+$othervalue ?>

as opposed to

<?php $result=$db->getOne() echo $value+$othervalue ?>

“Nothing is more stubborn than a programmer defending a language” :wink:


Xiangrong Fang xrfang@hotmail.com

“Arthur” arthur8@boardermail.com schrieb im Newsbeitrag
news:16e0bc53.0307310222.11587422@posting.google.com

“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message
news:60107.203.185.214.34.1059543084.squirrel@webmail.imagineis.com

My solution is to use {} for one line blocks and do…end for more
complicated things.

I tried this style for a while. But then every time I added lines
to a
one-line block, I had to change {} to do/end.

Today I normally used {} on all blocks, except in Rake files.

My take is: {} are for functional blocks; do…end for procedural
blocks.
That shows me which expressions are important for their results, and
which
are not.

Gavin

This sounds very interesting. Can you expand upon this a little?
What do you take as the difference between procedural blocks and
funcitonal blocks? Can you provide an example?

I guess he means

(0…10).each do |i|; puts i; end
(0…10).map {|i| i+i}

robert
···

On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:

I don’t know any PHP debugger. I write A LITTLE php directly on Apache

http://dd.cron.ru/dbg/

Your reason defending the ; is not well established :slight_smile: Please note ruby
also support ; if you want to write multiple lines of code on one line.

Maybe so, but then if you care to use the ; in ruby, that defeats your
whole argument that

···

PHP… it is Sh*t… mainly because of the “;”. A lot of

Xiangrong Fang xrfang@hotmail.com writes:

Hi,

So it is better on this regard. By the way, I have never seen a
programmer who write code in Microsoft Word, so, the statement that a “;”
is usuful to the program that it will “survive a word processor” sounds
strange to me.

maybe there is a code snippet somewhere at the home of a programmer and
his/her non programming wife/husband sends you the snipped pasted in a
html email or pasted into word as attachment?

Isn’t independence of white space treatment also an argument for
SGML, XML?

Of course IMO it can be masochistic to program/write in space ignoring
languages (i.e. XSL).

···


Fritz Heinrichmeyer FernUniversitaet, LG ES, 58084 Hagen (Germany)
tel:+49 2331/987-1166 fax:987-355

Precisely. Some blocks are called to do something, and some are
called to evaluate to something (or, to return something). That’s
a high-level difference that is important to understanding high-level
program flow, so providing a visual signal in the code is some help to
me.

It turns out that most functional blocks are one-liners, like:

set.find { |e| e.satisfies condition }

But then you get some larger ones:

set.map { |e|
if something
e.x
else
e.y
end
}

do…end looks silly on one line, though, so I always spread that out:

people.each do |p|
process(p)
end

I figure the concept there is worth devoting three lines to.

Cheers,
Gavin

···

On Thursday, July 31, 2003, 8:58:48 PM, Robert wrote:

“Arthur” arthur8@boardermail.com schrieb im Newsbeitrag
news:16e0bc53.0307310222.11587422@posting.google.com

“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message
news:60107.203.185.214.34.1059543084.squirrel@webmail.imagineis.com

On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:

My solution is to use {} for one line blocks and do…end for more
complicated things.

I tried this style for a while. But then every time I added lines
to a
one-line block, I had to change {} to do/end.

Today I normally used {} on all blocks, except in Rake files.

My take is: {} are for functional blocks; do…end for procedural
blocks.
That shows me which expressions are important for their results, and
which
are not.

Gavin

This sounds very interesting. Can you expand upon this a little?
What do you take as the difference between procedural blocks and
funcitonal blocks? Can you provide an example?

I guess he means

(0…10).each do |i|; puts i; end
(0…10).map {|i| i+i}

robert

“Gavin Sinclair” gsinclair@soyabean.com.au schrieb im Newsbeitrag
news:1074470277.20030801003703@soyabean.com.au…

“Arthur” arthur8@boardermail.com schrieb im Newsbeitrag
news:16e0bc53.0307310222.11587422@posting.google.com

“Gavin Sinclair” gsinclair@soyabean.com.au wrote in message

news:60107.203.185.214.34.1059543084.squirrel@webmail.imagineis.com

My solution is to use {} for one line blocks and do…end for
more
complicated things.

I tried this style for a while. But then every time I added
lines
to a
one-line block, I had to change {} to do/end.

Today I normally used {} on all blocks, except in Rake files.

My take is: {} are for functional blocks; do…end for procedural
blocks.
That shows me which expressions are important for their results,
and
which
are not.

Gavin

This sounds very interesting. Can you expand upon this a little?
What do you take as the difference between procedural blocks and
funcitonal blocks? Can you provide an example?

I guess he means

(0…10).each do |i|; puts i; end
(0…10).map {|i| i+i}

robert

Precisely. Some blocks are called to do something, and some are
called to evaluate to something (or, to return something). That’s
a high-level difference that is important to understanding high-level
program flow, so providing a visual signal in the code is some help to
me.

It turns out that most functional blocks are one-liners, like:

Interestingly we seem to reach approximately the same formatting because
of different reasons. :slight_smile:

set.find { |e| e.satisfies condition }

But then you get some larger ones:

set.map { |e|
if something
e.x
else
e.y
end
}

Know your ternary operator: :slight_smile:
set.map { |e| something ? e.x : e.y }

do…end looks silly on one line,

Yep.

though, so I always spread that out:

people.each do |p|
process(p)
end

I figure the concept there is worth devoting three lines to.

A do;end for me is always a multiliner, too.

Cheers

robert
···

On Thursday, July 31, 2003, 8:58:48 PM, Robert wrote:

On Tue, 2003-07-29 at 22:30, Robert Klemme wrote:

But then you get some larger ones:

set.map { |e|
if something
e.x
else
e.y
end
}

[Robert:]
Know your ternary operator: :slight_smile:
set.map { |e| something ? e.x : e.y }

I know my ternary operator, but:

  • in my code snippet, “something”, “e.x”, and “e.y” were placeholders
    for something far bigger than you or I could imagine
  • sometimes there is multi-part processing do be done before arriving
    the “return value” for the block

Gavin

Also

  • The ternary operator is idiomatic of expert (or expert-wannabe) use
    of the C family of languages and likely to confuse and even scare away
    novice Ruby users who aren’t from that segment of the population, or
    only have limited experience with C.

Chris

···

On Thursday, July 31, 2003, at 5:40 PM, Gavin Sinclair wrote:

But then you get some larger ones:

set.map { |e|
if something
e.x
else
e.y
end
}

[Robert:]
Know your ternary operator: :slight_smile:
set.map { |e| something ? e.x : e.y }

I know my ternary operator, but:

  • in my code snippet, “something”, “e.x”, and “e.y” were placeholders
    for something far bigger than you or I could imagine
  • sometimes there is multi-part processing do be done before arriving
    the “return value” for the block

“Gavin Sinclair” gsinclair@soyabean.com.au schrieb im Newsbeitrag
news:36035.203.185.214.34.1059698367.squirrel@webmail.imagineis.com

But then you get some larger ones:

set.map { |e|
if something
e.x
else
e.y
end
}

[Robert:]
Know your ternary operator: :slight_smile:
set.map { |e| something ? e.x : e.y }

I know my ternary operator, but:

No offense intended. Sorry, if that sounded a bit aggressive.

  • in my code snippet, “something”, “e.x”, and “e.y” were placeholders

I see.

for something far bigger than you or I could imagine

Wow… (Robert silences in awe.) :slight_smile:

  • sometimes there is multi-part processing do be done before arriving
    the “return value” for the block

Yep. In Ruby anyway you can easily replace ?: with the far more readable

set.map { |e| if something then e.x else e.y end }

so it’s still a one liner in this case. :slight_smile:

Cheers

robert

“Chris Thomas” chris@m-audio.com schrieb im Newsbeitrag
news:65B2946A-C3D2-11D7-88FA-000393942016@m-audio.com

Also

  • The ternary operator is idiomatic of expert (or expert-wannabe) use
    of the C family of languages and likely to confuse and even scare away
    novice Ruby users who aren’t from that segment of the population, or
    only have limited experience with C.

That’s possibly true. I faintly remember the times when I first saw ?:
and wondered what that might be. Nowadays I’ve become so acquainted with
this idom that I hardly notice this as something strange. Thanks for
reminding me!

Regards

robert

The ternary operator is useful, as evidenced by the fact that people
use it when equivalents exist.

martin

···

Chris Thomas chris@m-audio.com wrote:

  • The ternary operator is idiomatic of expert (or expert-wannabe) use
    of the C family of languages and likely to confuse and even scare away
    novice Ruby users who aren’t from that segment of the population, or
    only have limited experience with C.

The beauty of ruby is its tolerance. I use delphi heavily, also Java
Javascript and C. Everything works fine in Ruby. No surprise at all.

Ruby is pragmatic programming language. Don’t even think about grammar.

If you hate ternary, simply don’t use it.

···

On Fri, 1 Aug 2003 19:51:31 +0900 Marko Schulz 4mschulz@informatik.uni-hamburg.de wrote:

On Fri, Aug 01, 2003 at 07:48:54PM +0900, Martin DeMello wrote:

The ternary operator is useful, as evidenced by the fact that people
use it when equivalents exist.

???
Violence is useful, as evidenced by the fact that people
use it when equivalents exist.
???


marko schulz


Xiangrong Fang xrfang@hotmail.com

Saluton!

  • Marko Schulz; 2003-08-01, 12:37 UTC:

The ternary operator is useful, as evidenced by the fact that people
use it when equivalents exist.

???
Violence is useful, as evidenced by the fact that people
use it when equivalents exist.
???

Correct. The question is if being useful makes it acceptable. Some
people believe that a goal can justify any means while others believe
that this is not true.

I am pretty sure that there is an equivalent of German ‘Der Zweck
heiligt die Mittel’ in many languages…

Gis,

Josef ‘Jupp’ Schugt

···

On Fri, Aug 01, 2003 at 07:48:54PM +0900, Martin DeMello wrote:

N’attribuez jamais à la malice ce que l’incompétence explique !
– Napoléon

“The End Justifies the Means”, in English.

I disagree with it, believing that the means can corrupt the end.

-austin

···

On Sat, 2 Aug 2003 05:09:39 +0900, Josef ‘Jupp’ Schugt wrote:

Saluton!

  • Marko Schulz; 2003-08-01, 12:37 UTC:

On Fri, Aug 01, 2003 at 07:48:54PM +0900, Martin DeMello wrote:

The ternary operator is useful, as evidenced by the fact that
people use it when equivalents exist.
Violence is useful, as evidenced by the fact that people use it when
equivalents exist. ???
Correct. The question is if being useful makes it acceptable. Some people
believe that a goal can justify any means while others believe that this
is not true.

I am pretty sure that there is an equivalent of German ‘Der Zweck heiligt
die Mittel’ in many languages…


austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.08.02
* 10.15.26

Saluton!

  • Austin Ziegler; 2003-08-02, 21:17 UTC:

Violence is useful, as evidenced by the fact that people use it when
equivalents exist. ???
Correct. The question is if being useful makes it acceptable. Some people
believe that a goal can justify any means while others believe that this
is not true.

I am pretty sure that there is an equivalent of German ‘Der Zweck heiligt
die Mittel’ in many languages…

“The End Justifies the Means”, in English.

I disagree with it, believing that the means can corrupt the end.

Obviously even the UN Security Council does not share your (and mine)
opinion. They guarantee that a well-known country’s troops may commit
any crime of war without being punished for it by the international
community. I don’t think that they are going to commit such crimes
but that does not change the ethical implications of the decision.

Gis,

Josef ‘Jupp’ Schugt

···


N’attribuez jamais à la malice ce que l’incompétence explique !
– Napoléon