Methods as infix operators WAS: Defending Ruby's OOP

S

Sammy Larbi

John Joyce wrote, On 5/15/2007 4:21 PM:
Hmm... there could be some bizarre and interesting possibilities.
For example, instead of if,
why not a construct called 'perhaps' or 'maybe' to include randomness
or other interesting side-effects.
Or even 'occasionally' or 'usually' for weighted randomness.
Adverbs could make very interesting control structures, which could of
course be def'd more (or less) precisely.
Imagine the expressive possibilities of: often, quickly, slowly,
monthly, quarterly, hourly, randomly, quietly, obsequiously,
obscenely, derisively, politely, privately, publicly, etc...
'unless' could be 'other_than' or 'except_if'
'if' itself could be semantically described as the same as 'when' in
many human languages.
Rather than simply being declarative like java keywords, many
constructs could become more descriptive.
This is one of Ruby's biggest strengths, its expressiveness in a very
natural way.

Once it has got the native unicode thing happening, it will be
possible to begin to write Ruby in languages other than English!
Even in Japanese (which would by its grammar, make a very good
programming language)

Some abstraction is bad because it continues to slow things down, but
processing power is still increasing, while human limits are pretty
constant.

I like this idea. I was thinking

when a==1 someCode

is quite easy, but we need infix on methods to do

somecode when a==1

This isn't the first time I've wished we could have methods acting as
infix operators. Anyone else up for that, and are there any plans to
add it to Ruby? Assuming there is a way to do it that wouldn't muck up
everything else syntactically, would such a feature be desired and have
a possibility of being accepted into the language if someone were to
code it?

Regards,
Sam
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top