A Ruby WishList

  • Thread starter James, Roshan (Cognizant)
  • Start date
J

James, Roshan (Cognizant)

------=_NextPartTM-000-a83ec663-ada8-4c29-a4a9-a857c45bab5e
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi Folk,

I have been using Ruby for a some time now and I must say that I love
the language. While I have been reading mails here for some time now, I
have just joined this mailing list and this is my first post.

I recently wrote a blog entry about a WishList for Ruby and I would like
to get your responses about it. It is a rather lengthy entry, which is
why I am not posting th entire netry itself to the list.
http://pensieve.thinkingms.com/CommentView,guid,1a1045a1-bec1-45c7-97e9-
f3c9f7937cc7.aspx

To summarise briefly, I have mentioned:=20
- Threading support
- C/Cpp style operators
- Use of Curly braces/indentation to identify scope
- Ruby on .Net
- Currying of methods / partial evaluations
- Auto initialisation of variables

Awaiting opinions.=20

Regards,
Roshan James
http://www27.brinkster.com/sparksite/


------=_NextPartTM-000-a83ec663-ada8-4c29-a4a9-a857c45bab5e
Content-Type: text/plain;
name="InterScan_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="InterScan_Disclaimer.txt"


This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.

Visit us at http://www.cognizant.com


------=_NextPartTM-000-a83ec663-ada8-4c29-a4a9-a857c45bab5e--
 
M

Mauricio Fernández

To summarise briefly, I have mentioned:
- Threading support
- C/Cpp style operators
- Use of Curly braces/indentation to identify scope
- Ruby on .Net
- Currying of methods / partial evaluations
- Auto initialisation of variables

I tried to post a comment on your site but I keep getting
Server Error in '/' Application.

Here's what I was trying to send:
I wish ruby had real threads. The threading support currently provided
is really sad.

This is being worked on for Rite. Green threads aren't that bad anyway,
they're still very useful and are more portable (they work even on
DOS). But Rite will have native threads too.
I wish ruby had ++, --, += and that whole class of operators.

You can find a lot of postings about ++ and -- in ruby-talk, so I'm not
going to repeat that here. As for +=, once you define + you get += for
free, and a += b will *always* mean a = a + b. Same with other OP= things.
Use of Curly Braces { }

You could toy with a code filter (preprocessor) to try that, especially
if you want to try significant indentation too.

I rather like the fact that blocks can be spotted easily at the moment.
Auto Initialization of variables
When I write code like this
sum = 0
10.times{|n| sum = sum + n }

having sum be auto-initialized to 0 is *evil*. Should it be 0, '',
[], {}? How would Ruby know?

In Ruby 2.0, you'll be able to do
10.times{|n| (sum ||= 0) += n }
puts "Sum is #{sum}"
due to the new rules for block variables.

as for
10.times{|n| sum<0> += n; prod<1> *= n; }
there's no need to import clumsy syntax into Ruby IMHO.
Currying of Methods and Partial Evaluations
add = lambda{|x,y| x + y }
=> # said:
def curry(proc, *args); lambda{|*a| proc.call(*(args+a))} end => nil
add10 = curry(add, 10); add2 = curry(add, 2)
=> # said:
add10[1] => 11
add2[1]
=> 3

This could be done on methods too (without having to reify them with
method:)meth)) *if* parens. were needed (as in Python) to actually
do the method call. See
http://onestepback.org/index.cgi/Tech/Ruby/PythonAndRuby.rdoc.

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

And Bruce is effectively building BruceIX
-- Alan Cox
 
D

David Garamond

I'll comment on some.

James said:
I recently wrote a blog entry about a WishList for Ruby and I would like
to get your responses about it. It is a rather lengthy entry, which is
why I am not posting th entire netry itself to the list.
http://pensieve.thinkingms.com/CommentView,guid,1a1045a1-bec1-45c7-97e9-
f3c9f7937cc7.aspx

To summarise briefly, I have mentioned:
- Threading support

Coming in Rite or Cardinal (Ruby on Parrot). Rite might have both green
and OS threads.
- C/Cpp style operators

As Mauricio has mentioned, has been discussed many times.

http://www.ruby-talk.com/blade/2710
http://www.ruby-talk.com/blade/5961
- Ruby on .Net

There has been some efforts on this. This will require at least a
partial rewrite of Ruby probably to C#. I'd rather see Ruby being ported
to Parrot first though (Parrot will also run on Windows and a myriad
others that .NET/Mono won't).
- Auto initialisation of variables

If you don't declare variables first, Ruby can't know if it's a method
or a local variable:

def sum; ...; end
def sum=; ...; end
sum = sum+1 # this will invoke the sum and sum= methods.

sum = 2
sum = sum+1 # this will increment the sum local variable.

sum # now if you don't declare it first, what is sum? a
# method or a local variable

However, you don't need to predeclare $global or Constant because they
can't be confused with methods.
 
M

Mark Hubbart

Auto Initialization of variables
When I write code like this
sum = 0
10.times{|n| sum = sum + n }

having sum be auto-initialized to 0 is *evil*. Should it be 0, '',
[], {}? How would Ruby know?

Just a thought... What if there was a class:

class Nothing
def +(other)
other + self
end
def -(other)
other - self
end
#.....
def to_int
0
end
def to_str
""
end
#....
end

basically, this would be a class that would take on the empty version
of whatever was necessary.

This would probably only work with the basic classes, though... since
+, -, etc can be redefined, you can't assume that obj.+() requires an
argument of it's own kind; or that a+b == b+a, etc.

So I guess this wouldn't really wwork, after all. :)

cheers,
--Mark
 
C

Charles Comstock

There has been some efforts on this. This will require at least a
partial rewrite of Ruby probably to C#. I'd rather see Ruby being ported
to Parrot first though (Parrot will also run on Windows and a myriad
others that .NET/Mono won't).

I would imagine the code generation pass is different for ILASM then for
JAVA bytecode or Parrot bytecode, but there is no intervening C# pass
required. You could still write a self hosting ruby compiler on ILASM.

Charlie
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top