Front page | perl.perl6.language |
Postings from December 2003
Roles and Mix-ins?
Thread Next
From:
cdutton
Date:
December 13, 2003 03:41
Subject:
Roles and Mix-ins?
Message ID:
000401c3c10e$bbda88b0$919a5718@borg
I'm still digesting the vocabulary thread, but while I do, let me ask a
question that's probably crystal clear to everyone else.
Do roles act as a form of mix-in, as Ruby modules may, and Objective-C
protocols do?
Would the following two snippets be at all equivalent?
# Perl6
role Talk {
method say_hello {
print "Hello world!\n"
}
}
class Foo does Talk { ... }
Foo.new.say_hello;
# Ruby
module Talk
def say_hello
puts "Hello world!"
end
end
class Foo
include Talk
end
Foo.new.say_hello
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 11/27/2003
Thread Next
-
Roles and Mix-ins?
by cdutton