Forum: Ruby Perspectives for Ruby 2.0

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7b00965686932462eb7c765b65c580c4?d=identicon&s=25 unknown (Guest)
on 2007-05-26 18:21
(Received via mailing list)
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
38a02bf7121a81be5be6f3d488ce23b5?d=identicon&s=25 Alexey Verkhovsky (Guest)
on 2007-05-26 20:33
(Received via mailing list)
On 5/26/07, arcadiorubiogarcia@gmail.com <arcadiorubiogarcia@gmail.com>
wrote:
> 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.
83668557add122451315d38b24a9fe62?d=identicon&s=25 Michael Hollins (Guest)
on 2007-05-27 12:35
(Received via mailing list)
arcadiorubiogarcia@gmail.com wrote:

>
> 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.

what would you want beyond the following?

http://moonbase.rydia.net/mental/blog/programming/...
7b00965686932462eb7c765b65c580c4?d=identicon&s=25 unknown (Guest)
on 2007-05-27 16:01
(Received via mailing list)
On May 27, 12:31 pm, Michael Hollins <m...@hollins.id.au> wrote:
> http://moonbase.rydia.net/mental/blog/programming/...
Well I would want something more implicit, like in Groovy for
instance:
http://www.ibm.com/developerworks/java/library/j-p...
83668557add122451315d38b24a9fe62?d=identicon&s=25 Michael Hollins (Guest)
on 2007-05-28 16:41
(Received via mailing list)
arcadiorubiogarcia@gmail.com wrote:
>> http://moonbase.rydia.net/mental/blog/programming/...
>
> Well I would want something more implicit, like in Groovy for
> instance:
> http://www.ibm.com/developerworks/java/library/j-p...
>
>

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.

cheers,
mick
851acbab08553d1f7aa3eecad17f6aa9?d=identicon&s=25 Ken Bloom (Guest)
on 2007-05-28 17:10
(Received via mailing list)
On Sun, 27 May 2007 06:58:55 -0700, arcadiorubiogarcia wrote:

>>
>> http://moonbase.rydia.net/mental/blog/programming/...
>
> Well I would want something more implicit, like in Groovy for instance:
> http://www.ibm.com/developerworks/java/library/j-p...

class Proc
   def curry *curryargs
      lambda{|*args| self.call(*(curryargs+args))}
   end
end
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2007-05-28 17:27
(Received via mailing list)
On 5/28/07, Michael Hollins <mick@hollins.id.au> wrote:
> arcadiorubiogarcia@gmail.com 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.
38ed06ce1dd79b986574e9c7b7b374f8?d=identicon&s=25 Tomas Pospisek's Mailing Lists (Guest)
on 2007-05-28 17:52
(Received via mailing list)
On Mon, 28 May 2007, Michael Hollins wrote:

>>>
>  def multiply(a,b)
>
>
> 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

--
96931bfe0c2948f47a98e15ae52e5637?d=identicon&s=25 Chris Carter (cdcarter)
on 2007-05-28 18:45
(Received via mailing list)
On 5/28/07, Tomas Pospisek's Mailing Lists <tpo2@sourcepole.ch> wrote:
> >>>> have it on the standard distribution.
> > So, just so I understand, take the following example:
> >
> >
> > others will likely have a clearer perspective.
>
> -----------------------------------------------------------
>
>

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.
10d9ed7ab11115b081bb36f56a7a13bc?d=identicon&s=25 John Wilger (jwilger)
on 2007-05-28 18:55
(Received via mailing list)
On May 28, 9:44 am, "Chris Carter" <cdcar...@gmail.com> wrote:
> Yes, but a method is not an object

Well...it kind of is... http://ruby-doc.org/core/classes/Method.html

--
Regards,

John Wilger
851acbab08553d1f7aa3eecad17f6aa9?d=identicon&s=25 Ken Bloom (Guest)
on 2007-05-28 21:43
(Received via mailing list)
On Tue, 29 May 2007 00:36:27 +1000, Michael Hollins wrote:

>>>
>      a * b
> 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.
83668557add122451315d38b24a9fe62?d=identicon&s=25 Michael Hollins (Guest)
on 2007-05-29 13:36
(Received via mailing list)
Ken Bloom wrote:
>
> class Proc
>    def curry *curryargs
>       lambda{|*args| self.call(*(curryargs+args))}
>    end
> end
>

Please excuse my being slow, but how exactly would I use the above?
96931bfe0c2948f47a98e15ae52e5637?d=identicon&s=25 Chris Carter (cdcarter)
on 2007-05-29 13:46
(Received via mailing list)
On 5/29/07, Michael Hollins <mick@hollins.id.au> wrote:
>
>

add = proc {|x,y| x+y}
add_two = add.curry(2)
add_two[2] # => 4
This topic is locked and can not be replied to.