The Artima Developer Community
Sponsored Link

Java Buzz Forum
Perl 6 OO: Not as much of a hack ;)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Perl 6 OO: Not as much of a hack ;) Posted: Apr 16, 2004 8:49 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Perl 6 OO: Not as much of a hack ;)
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
Larry Wall has come out with Apocalypse 12 which details how you will define and use OO in Perl 6. This is great to see, especially after also being up on the discussions for Groovy on how to handle certain things (e.g. properties). What does a Perl 6 simple class / use look like now? class Point { has $.x; has $.y is rw; method clear () { $.x = 0; $.y = 0; } } my $point = Point.new(x => 2, y => 3); $a = $point.y; # okay $point.y = 42; # okay $b = $point.x; # okay $point.x = -1; # illegal, default is read-only $point.clear; # reset to 0,0 Thank god for the keywords of class (and method). Finally it doesn't feel like OO is bolted on (even though Larry thinks it was bolted through). It is interesting that there is no constructor, yet "my $point = Point.new(x => 2, y => 3);" still does the right thing. And moving from "->" to "." is nice too. You may wonder what the "$.x" is all about. This is an interesting use... if you said "$:x" that would make it private! Sneaky huh. You can make private classes via "class :MyPrivateClass {...}", and private methods via "method :think (Brain $self: $thought)" Another interesting thing is the part of "roles". E.g. class Dog { is Mammal; does Pet; does Servant; does Best::Friend[Man]; does Drool; ... } I also enjoyed seeing this Groovy/Ruby/...-ish looking code: @thumbs.each { .twiddle } Whatever you think of this document, anyone can see that a LOT of thought has been put into this (as is always the case with Larry), and there are many things in which we can learn from (are you reading this Groovy guys?). Great stuff. Hopefully we will see Perl 6 in the next 5 years ;)

Read: Perl 6 OO: Not as much of a hack ;)

Topic: Jini and Web Services: Judy Project Overview Previous Topic   Next Topic Topic: Jen Chapin

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use