Ruby doesn't implement x++ for Fixnum's because ???

R

Rick DeNatale

=A0 =A0 =A0 =A0blahblahblah.each do |args|
=A0 =A0 =A0 =A0 =A0lots of stuff lots of stuff
=A0 =A0 =A0 =A0 =A0if condition
=A0 =A0 =A0 =A0 =A0 =A0count +=3D 1
=A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0 =A0end

I'd rather see "++count". =A0It's easier for me to read.

Hey, I might 'rather' have C allow if statement modifiers.

And I might 'rather' have French do away with all those pesky gender
agreements and thinking of towers as feminine and a lap around a track
as masculine.

But they don't, and I find I can live with that, and I certainly have
been much happier with Ruby even without a++ or ++a than I ever was in
C/C++, and I am, or at least was, competent enough in C to do things
like writing compilers in it, and reading and understanding the Ruby
source code etc.

This whole thread is reminding me of Mark Twain's complaint about the
stupidity of the French, because he "never could get them to
understand their own language!"

--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
M

Marnen Laibow-Koser

Rick said:
Hey, I might 'rather' have C allow if statement modifiers.

And I might 'rather' have French do away with all those pesky gender
agreements and thinking of towers as feminine and a lap around a track
as masculine.

But they don't, and I find I can live with that,

Ce n'est pas la même situation. Nous anglophones ne pouvons pas changer
la langue française tout d'un coup. Mais nous pouvons changer Ruby si
nous en avons besoin.
and I certainly have
been much happier with Ruby even without a++ or ++a than I ever was in
C/C++,

Mais oui!

Best,
 
S

Seebs

But they don't, and I find I can live with that, and I certainly have
been much happier with Ruby even without a++ or ++a than I ever was in
C/C++, and I am, or at least was, competent enough in C to do things
like writing compilers in it, and reading and understanding the Ruby
source code etc.

I'd rather use Ruby without those features than C++ with them. (Not quite
so sure about C, but certainly there's plenty of things for which I'd rather
use Ruby than C.) But on the other hand, I really do like the syntactic
sugar.

My favorite syntactic sugar ever was Icon's swap operator. Sure, you don't
need it often, but it sure is nice to be able to express it so clearly.

-s
 
A

Aldric Giacomoni

Marnen said:
Would you? Or would you rather see
count = blahblahblah.count do |args|
lots_of_stuff
condition
end

Marnen - I tried to do this:
a = [1,2,3,4]
a.each do |b|
puts b
b % 2 == 0
end

But it .. Predictably .. (?) showed me 1, 2, 3, 4, each on a separate
line. Was your example sarcasm, or is that actually a Ruby construct?

Je vous en prie, ne nous moquons pas de la langue francaise, qui est une
langue, apres tout, tres belle et subtile, et qui peut etre imbue de
douceur comme de violence avec de simples changements de nuance.
 
M

Marnen Laibow-Koser

Aldric said:
Marnen said:
Would you? Or would you rather see
count = blahblahblah.count do |args|
lots_of_stuff
condition
end

Marnen - I tried to do this:
a = [1,2,3,4]
a.each do |b|
puts b
b % 2 == 0
end

But it .. Predictably .. (?) showed me 1, 2, 3, 4, each on a separate
line.

Because you used a different method than I did.
Was your example sarcasm, or is that actually a Ruby construct?

No sarcasm. You just failed to notice that I wasn't using .each. :)
Je vous en prie, ne nous moquons pas de la langue francaise, qui est une
langue, apres tout, tres belle et subtile, et qui peut etre imbue de
douceur comme de violence avec de simples changements de nuance.

Je ne me moquais point de la langue française ! Je ne voulais que dire
qu'il est beaucoup plus possible de changer la langue Ruby que de
changer la langue française.

Best,
 
A

Aldric Giacomoni

a = [1,2,3,4]
b = 0
# 'nip' is undefined outside the block
irb(main):393:0> b = a.size do |nip|
irb(main):394:1* puts nip * 2
irb(main):395:1> nip > 6
irb(main):396:1> end
=> 4
irb(main):397:0> b = a.size do |nip|
irb(main):398:1* puts nip * 2
irb(main):399:1> nip < 6
irb(main):400:1> end
=> 4

I don't understand this block.
Aussi, si je puis me permettre - le Francais est une langue, et Ruby est
un langage (de programmation). Yet another one of those french
subtleties!
 
M

Marnen Laibow-Koser

Aldric said:
a = [1,2,3,4]
b = 0
# 'nip' is undefined outside the block
irb(main):393:0> b = a.size do |nip|
irb(main):394:1* puts nip * 2
irb(main):395:1> nip > 6
irb(main):396:1> end
=> 4
irb(main):397:0> b = a.size do |nip|
irb(main):398:1* puts nip * 2
irb(main):399:1> nip < 6
irb(main):400:1> end
=> 4

I don't understand this block.

You're using Array#size. I'm using Enumerable#count. They're not
interchangeable.
Aussi, si je puis me permettre - le Francais est une langue, et Ruby est
un langage (de programmation). Yet another one of those french
subtleties!

Merci ! Je ne le savais pas.

Best,
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

On the other hand, it's also plain impossible to implement, for various
reasons listed numerous times prior to this humble message.

The only reasons it's impossible are cultural, not technical. If you think
there's a valid technical reason why it's "impossible" to implement perhaps
you'd care to state it.
 
S

Seebs

The only reasons it's impossible are cultural, not technical. If you think
there's a valid technical reason why it's "impossible" to implement perhaps
you'd care to state it.

It's impossible to implement as a method. You could introduce it as
syntactic sugar, but it's not so clear that this would be worth the
trouble. In particular, incrementing is inefficient in Ruby because
it would involve creating many new objects to iterate.

-s
 
A

Aldric Giacomoni

Tony said:
The only reasons it's impossible are cultural, not technical. If you
think
there's a valid technical reason why it's "impossible" to implement
perhaps
you'd care to state it.

Tony, as I said: I am merely a fledgling Ruby enthusiast. I'm reading
"Best Practices in Ruby" and had to tape my jaw to my skull so it would
stop falling off.
This being said, YOU are welcome to implement the '++' operator and let
us know how it works. I can tell you're vastly more knowledgeable than I
am (yet! I will catch up to you! mwa ha ha!), so please show us.
 
D

David A. Black

Hi --

a = [1,2,3,4]
b = 0
# 'nip' is undefined outside the block
irb(main):393:0> b = a.size do |nip|
irb(main):394:1* puts nip * 2
irb(main):395:1> nip > 6
irb(main):396:1> end
=> 4
irb(main):397:0> b = a.size do |nip|
irb(main):398:1* puts nip * 2
irb(main):399:1> nip < 6
irb(main):400:1> end
=> 4

I don't understand this block.
Aussi, si je puis me permettre - le Francais est une langue, et Ruby est
un langage (de programmation). Yet another one of those french
subtleties!

http://dablog.rubypal.com/2007/4/17/the-l-in-dsl-langue-ou-langage

:) (Not the same topic obviously but your comment made me think of
it.)


David

--
The Ruby training with D. Black, G. Brown, J.McAnally
Compleat Jan 22-23, 2010, Tampa, FL
Rubyist http://www.thecompleatrubyist.com

David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)
 
T

TonyMc

Tony Arcieri said:
I still find this most appropriate:

OK, that gets you killfiled. Getting ruby wrong is not so bad, you just
need to learn from the other posts in this thread. Getting real life
wrong is another, and much more serious.

Tony
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

OK, that gets you killfiled. Getting ruby wrong is not so bad, you just
need to learn from the other posts in this thread. Getting real life
wrong is another, and much more serious.

Psst, it's a joke, and a self-deprecating one at that.

That said, this thread is pretty much a dead horse at this point.
 
R

Rick DeNatale

I don't understand this block.
Aussi, si je puis me permettre - le Francais est une langue, et Ruby est
un langage (de programmation). Yet another one of those french
subtleties!

Actually I think the subtleties are similar between French and English here

In French une langue denotes the same concept as tongue in English.
The primary meaning is that muscle in the middle of a mouth. It can
also mean a language, in the same sense that tongue can in English
phrases such as "His native tongue." or "Speaking in tongues."
Although such usage is more frequent in French than in English. This
is a secondary meaning though, from "Le Dictionnaire de l'Acad=E9mie
Fran=E7aise":

LANGUE d=E9signe aussi l=92Idiome d=92une nation, d=92une race

And the French word idiome (another slightly false cognate) means The
language of a Nation, or province.

The French un Langage is first what is used by humans to express their
thoughts and sentiments by means of "articulations of the voice", by
extension it also can mean written language, the 'language' of animals
(bird song, dog's barking etc.) and finally a system of communication
by any means "The symbolic language of flowers." "Pantomime is a
silent language." these last being translated examples from Le
Dictionnaire.

--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
A

Aldric Giacomoni

Rick said:
In French une langue denotes the same concept as tongue in English.
The primary meaning is that muscle in the middle of a mouth. It can
also mean a language

Okay, I knew that...
The French un Langage is first what is used by humans to express their
thoughts and sentiments by means of "articulations of the voice", by
extension it also can mean written language, the 'language' of animals
(bird song, dog's barking etc.) and finally a system of communication
by any means "The symbolic language of flowers." "Pantomime is a
silent language." these last being translated examples from Le
Dictionnaire.

By Jove! Getting lessons in my mother idiom (*grin*) on a Ruby forum. I
knew I was following you on Twitter for a reason.
 
R

Rick DeNatale

Just so you know I wasn't dissing La langue belle. I try to maintain
a basic fluency. Not sure if my French or my C is more rusty! <G>

Okay, I knew that...


By Jove! Getting lessons in my mother idiom (*grin*) on a Ruby forum. I
knew I was following you on Twitter for a reason.



--=20
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
A

Aldric Giacomoni

Rick said:
Just so you know I wasn't dissing La langue belle. I try to maintain
a basic fluency. Not sure if my French or my C is more rusty! <G>

Hah! No worries, I wasn't insulted.
So .. Friend++ ?
Warning: incrementing a constant!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top