[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby annoyances ... mine is line continuation, what's yours?

scooterm@hotmail.com

1/16/2008 7:42:00 PM

Just thinking how really smart Ruby is in most areas makes it all the
more surprising when some of its "warts" start showing. Admittedly,
the ones that appear are pretty minor, but still a tad irritating
nonetheless.

Line continuation is probably the biggest annoyance for me so far.

Consider:

puts 'cat :: dog :: elephant :: mouse :: gorilla'.
split('::').
map{|str| str.strip() }.
select{|str| str['o']}.
join("\n")

If you ask "why is this an annoyance" ... it's because you have
to put the period at the *end* of each item, even though some
prefer to put it at the beginning. Why? Because it makes it easier
to remember to put in the code, you dont have to scan a bunch
of varying-length lines to see if you remembered to put the
dot at the end, ... and don't even think about adding "line
continuation escapes" like a backslash ... they're ugly and
they suck.

Anyone else have an annoyance they want to share? ... or better
yet, a fix for this one? Speak up, get it off your chest.

--salutations
10 Answers

James Gray

1/16/2008 7:52:00 PM

0

On Jan 16, 2008, at 1:44 PM, scooterm@hotmail.com wrote:

> Consider:
>
> puts 'cat :: dog :: elephant :: mouse :: gorilla'.
> split('::').
> map{|str| str.strip() }.
> select{|str| str['o']}.
> join("\n")
>
> If you ask "why is this an annoyance" ... it's because you have
> to put the period at the *end* of each item, even though some
> prefer to put it at the beginning. Why?

> Anyone else have an annoyance they want to share? ... or better
> yet, a fix for this one?

Ruby 1.9 allows the period at the beginning of the line, so cheer up,
your complaint has already been fixed. :)

James Edward Gray II


Joshua Schairbaum

1/16/2008 7:54:00 PM

0

Don't all sentences _end_ with punctuation?

On Jan 16, 2008, at 2:44 PM, scooterm@hotmail.com wrote:

> Just thinking how really smart Ruby is in most areas makes it all the
> more surprising when some of its "warts" start showing. Admittedly,
> the ones that appear are pretty minor, but still a tad irritating
> nonetheless.
>
> Line continuation is probably the biggest annoyance for me so far.
>
> Consider:
>
> puts 'cat :: dog :: elephant :: mouse :: gorilla'.
> split('::').
> map{|str| str.strip() }.
> select{|str| str['o']}.
> join("\n")
>
> If you ask "why is this an annoyance" ... it's because you have
> to put the period at the *end* of each item, even though some
> prefer to put it at the beginning. Why? Because it makes it easier
> to remember to put in the code, you dont have to scan a bunch
> of varying-length lines to see if you remembered to put the
> dot at the end, ... and don't even think about adding "line
> continuation escapes" like a backslash ... they're ugly and
> they suck.
>
> Anyone else have an annoyance they want to share? ... or better
> yet, a fix for this one? Speak up, get it off your chest.
>
> --salutations
>


Tim Pease

1/16/2008 8:06:00 PM

0


On Jan 16, 2008, at 12:54 PM, Joshua Schairbaum wrote:

> Don't all sentences _end_ with punctuation?
>

Not the incomplete ones

TwP

Jean-François Trân

1/16/2008 8:21:00 PM

0

2008/1/16, scooterm@hotmail.com <scooterm@hotmail.com>:

> Line continuation is probably the biggest annoyance for me so far.
>
> Consider:
>
> puts 'cat :: dog :: elephant :: mouse :: gorilla'.
> split('::').
> map{|str| str.strip() }.
> select{|str| str['o']}.
> join("\n")
>
> If you ask "why is this an annoyance" ... it's because you have
> to put the period at the *end* of each item, even though some
> prefer to put it at the beginning. Why? Because it makes it easier
> to remember to put in the code, you dont have to scan a bunch
> of varying-length lines to see if you remembered to put the
> dot at the end, ... and don't even think about adding "line
> continuation escapes" like a backslash ... they're ugly and
> they suck.
>
> Anyone else have an annoyance they want to share? ... or better
> yet, a fix for this one?

You can insert spaces before or after the dot, so for instance,
you can format your code to make the dots vertically aligned.

See : http://pastie.caboo...

So it's easy to check if a dot is missing.

-- Jean-Fran=E7ois.

ara.t.howard

1/16/2008 8:42:00 PM

0


On Jan 16, 2008, at 12:44 PM, scooterm@hotmail.com wrote:

>
> puts 'cat :: dog :: elephant :: mouse :: gorilla'.
> split('::').
> map{|str| str.strip() }.
> select{|str| str['o']}.
> join("\n")

have fun debugging that one - the stack trace from any error on any
of those lines will come from the same line. fine for quick hacks,
but deep method chaining is evil if there is even a remote chance
that the error will bubble up to a logfile somewhere for some poor
soul to grok. anything that makes crazy line chaining even easier
would probably annoy me

btw

puts 'cat :: dog :: elephant :: mouse :: gorilla'.scan(/\w*o\w*/)

dog
mouse
gorilla

;-)

a @ http://draw...
--
sleep is the best meditation.
h.h. the 14th dalai lama




Karl von Laudermann

1/16/2008 8:51:00 PM

0

On Jan 16, 2:41 pm, "scoot...@hotmail.com" <scoot...@hotmail.com>
wrote:
>
> Consider:
>
> puts 'cat :: dog :: elephant :: mouse :: gorilla'.
> split('::').
> map{|str| str.strip() }.
> select{|str| str['o']}.
> join("\n")
>
> If you ask "why is this an annoyance" ... it's because you have
> to put the period at the *end* of each item, even though some
> prefer to put it at the beginning.

When splitting a long line across an operator, I've always preferred
to put the operator at the end, because it makes it obvious that the
line isn't finished. Not just for the Ruby interpreter, but for the
user as well. Even in Java, I prefer to write:

int val = Foo.someLongThing() +
Bar.otherLongThing();

even though Sun's official Java style guide dictates putting the + at
the start of the second line.

Chad Perrin

1/16/2008 9:05:00 PM

0

On Thu, Jan 17, 2008 at 04:54:20AM +0900, Joshua Schairbaum wrote:
> Don't all sentences _end_ with punctuation?

The case being discussed is not of a sentence ending with punctuation,
but a linewrap ending with punctuation.

--
CCD CopyWrite Chad Perrin [ http://ccd.ap... ]
Isaac Asimov: "Part of the inhumanity of the computer is that, once it is
completely programmed and working smoothly, it is completely honest."

Wincent Colaiuta

1/17/2008 10:56:00 AM

0

On Jan 16, 10:04 pm, Chad Perrin <per...@apotheon.com> wrote:
> On Thu, Jan 17, 2008 at 04:54:20AM +0900, Joshua Schairbaum wrote:
> > Don't all sentences _end_ with punctuation?
>
> The case being discussed is not of a sentence ending with punctuation,
> but a linewrap ending with punctuation.

Would you write in English like this:

Well, the unit was tall
, thin, blue, and had
, well, how would you say
? anomalies which were, er
, rather disturbing.

Or like this:

Well, the unit was tall,
thin, blue, and had,
well, how would you say?
anomalies which were, er,
rather disturbing.

W

Michal Suchanek

1/17/2008 10:59:00 AM

0

On 16/01/2008, Karl von Laudermann <doodpants@mailinator.com> wrote:
> On Jan 16, 2:41 pm, "scoot...@hotmail.com" <scoot...@hotmail.com>
> wrote:
> >
> > Consider:
> >
> > puts 'cat :: dog :: elephant :: mouse :: gorilla'.
> > split('::').
> > map{|str| str.strip() }.
> > select{|str| str['o']}.
> > join("\n")
> >
> > If you ask "why is this an annoyance" ... it's because you have
> > to put the period at the *end* of each item, even though some
> > prefer to put it at the beginning.
>
> When splitting a long line across an operator, I've always preferred
> to put the operator at the end, because it makes it obvious that the
> line isn't finished. Not just for the Ruby interpreter, but for the
> user as well. Even in Java, I prefer to write:
>
> int val = Foo.someLongThing() +
> Bar.otherLongThing();

It depends on the operator. `+' is quite easy to see but a `.' is not.

Note that in writing it is customary to put the operator both on the
line end and on the beginning of the next line so that it's clear
wherever you start reading. Indentation usually can serve that purpose
in electronic form so the operator at the start is less important for
understanding the program. However, you would need an editor that
automatically and correctly adjusts indentation to detect the missing
operator.

Thanks

Michal

Curt Sampson

1/19/2008 3:17:00 AM

0

On 2008-01-17 20:00 +0900 (Thu), Wincent Colaiuta wrote:

> Would you write in English like this:
>
> Well, the unit was tall
> , thin, blue, and had
> ...

No. But we're not discussing writing English, we're discussing writing
computer code.

cjs
--
Curt Sampson <cjs@starling-software.com> +81 90 7737 2974
Mobile sites and software consulting: http://www.starling-so...