Perspectives for Ruby 2.0

A

arcadiorubiogarcia

Hi,

I'm quite new to Ruby. First of all I must say that Ruby has shocked
me ever since I discovered it. IMO Ruby has the elegant message
passing of Smalltalk, some of the dynamism of Dylan and some great
functional features. Everything with a compact Perl-like synthax,
clean and readable though.

I would like to pose two questions regarding features I think Ruby
should include in the future:

1. Are there any plans to introduce function currying? It's a very
useful feature for function expressions, and it won't be very
difficult to add. In fact, far I've seen a few implementations of it
out there. They seem to be more or less ok, but it would be great to
have it on the standard distribution.


2. What about aspect-oriented programming on Ruby? I know about
AspectR. However, the project seems to be no more on active
development. Am I right?

Ruby community has always been very receptive to new ideas. It would
be great to build a solid AOP extension. This could position Ruby with
a clear advantage over many languages.

IMO, AspectJ, which is the defacto AOP language is dead end. I worked
on the AspectJ Compiler project some time ago, and it's a nightmare.
Things become *SO* complex and buggy when trying to deal with
generics. And I don't want to think about future closures of Java 1.7.
In contrast, an AOP extension for Ruby could be very several levels of
magnitude easier.


Thanks,

Arcadio
 
A

Alexey Verkhovsky

2. What about aspect-oriented programming on Ruby?

AOP is a creative, massively complex workaround for the constraints of
static languages.

In Ruby, you can solve all the problems AOP solves, using just Ruby
interpreter and no external tools and libraries. Moreover, this
capability so naturally fits with the rest of the language, it doesn't
even need a name.

Welcome.
 
G

Gregory Brown

(e-mail address removed) wrote:
triple = lambda { |a| multiply(a,3) }

puts triple.call(10)

I believe you are saying that you'd like the last line to be:

puts triple(10)

We can already do puts triple[10], which gets you close.
 
T

Tomas Pospisek's Mailing Lists

So, just so I understand, take the following example:

def multiply(a,b)
a * b
end

triple = lambda { |a| multiply(a,3) }

puts triple.call(10)

I believe you are saying that you'd like the last line to be:

puts triple(10)

Is that right? If so, then I agree that would be nice. I'm guessing that it's
difficult to achieve in ruby due to the fact that functions can be called
without the parentheses. So, for example if I defined the following
uninteresting lambda:

six = lambda { multiply(2,3) }

then the following would be ambiguous:

puts six

Am I trying to invoke the lambda, or am I trying to print the value of the
object? To resolve the ambiguity I cannot invoke a lambda with the above
syntax. Instead I need to do:

puts six.call()

I'd like to hear from the experts if that is the reason or whether there is
something more fundamental. I'm still learning ruby (and liking it BTW), so
others will likely have a clearer perspective.

The ambiguity is there allready

If I write:

puts nuts

Then nuts can either be a variable that will return its value, or it can
be a function call that will return the result of calling it. In that
sense being able to call (from your example above):

puts six

would be IMHO perfectly sensible, since it would be neither more nor less
ambiguous then ruby's default behaveour.
*t
 
C

Chris Carter

The ambiguity is there allready

If I write:

puts nuts

Then nuts can either be a variable that will return its value, or it can
be a function call that will return the result of calling it. In that
sense being able to call (from your example above):

puts six

would be IMHO perfectly sensible, since it would be neither more nor less
ambiguous then ruby's default behaveour.
*t

--

Yes, but a method is not an object, whereas a Proc is. So we don't
know if we want to inspect or call the Proc, it can be reasonably
assumed you want to call the method because, there is no way to
inspect the method without trapping it.
 
K

Ken Bloom

So, just so I understand, take the following example:

def multiply(a,b)
a * b
end

triple = lambda { |a| multiply(a,3) }

puts triple.call(10)

I believe you are saying that you'd like the last line to be:

puts triple(10)

Is that right? If so, then I agree that would be nice.

The choice of syntax for calling the function also has nothing to do with
currying.
 

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,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top