Re: RFC 95 (v1) Object Classes

2000-08-13 Thread Damian Conway

No, I don't want to tighten up anything about Perl's existing package
and blessed reference system.  It's fine the way it is.  I *ALSO* 
want a more formally defined OO system for times when I'm feeling more 
structured, or when the scale or scope of the project I'm working on 
demans it.  This should definately, absolutely, without doubt be an 
"as well as" option and not "instead of".  Hence the new kind of package, 
and the new kind of operator, rather than messing around with the old ones.

Have you played with Class::Contract? I think it would give you as much
formality as you need, and it's just a module built over Perl's existing
OO mechanism.

I intend to propose features that will extend the current mechanism to
make the 'hoops' easier to jump through, but I'm incredibly leery of
putting two distinct OO mechanisms into Perl. That *won't* satisfy the
OO purists or those who need guaranteed security.

And I'm *really* against . as an attribute access mechanism :-)

But that's okay, since I don't have the final say. If I were you, I'd make
the RFC *more* sweeping -- propose your approach as a *replacement* for
the current one (then you could claim -, and not have to overload .)

Damian



Re: RFC 95 (v1) Object Classes

2000-08-12 Thread Andy Wardley

 Couldn't:
my $u = User.new('abw', 'Andy Wardley', '[EMAIL PROTECTED]');
 just be
my $u = User-new('abw', 'Andy Wardley', '[EMAIL PROTECTED]');
 
 And:
$foo.bar.baz = 10;
 Just be:
$foo::bar::baz = 10;

Yes, but the semantics change.  A key feature of this proposal is that
object/class variable and methods are indistinguishable to the user.
The dot operator does the right thing to call a method (if defined), 
or instead access a variable, or follow a delegation reference, etc.
i.e. 
$foo.bar

is something like (assuming a blessed hash)

UNIVERSAL::can($foo, 'bar') ? $foo-bar() : $foo-{'bar'};

'-' and '::' won't do that, and shouldn't.  If we tried to overload 
'::' or '-' to be more magical then we would break things all over 
the place.

 There are also tons of methods of inheritance in Perl's existing object
 and package structure as-is, through SUPER, CORE, and many other
 methods.

Yes, there's nothing that you can't already do in Perl in one way or 
another.  Perl 5's OO is very elegantly bolted onto the side of the 
language.  It's very powerful, flexible and reasonable easy to use.
On the other hand, you sometimes have to jump through lots of hoops
to do some very simple OO stuff that in other OO langugages is taken
for granted.  

 If you just want to tighten up certain aspects of packaging and
 classing, it seems like this could be done with a pragma or a couple new
 keywords, instead of redoing the entire package structure of Perl, which
 I quite like.

No, I don't want to tighten up anything about Perl's existing package
and blessed reference system.  It's fine the way it is.  I *ALSO* 
want a more formally defined OO system for times when I'm feeling more 
structured, or when the scale or scope of the project I'm working on 
demans it.  This should definately, absolutely, without doubt be an 
"as well as" option and not "instead of".  Hence the new kind of package, 
and the new kind of operator, rather than messing around with the old ones.


A




Re: RFC 95 (v1) Object Classes

2000-08-12 Thread Tony Olekshy

Andy ~

Since you didn't mention it in your references, you may want to
check out RFC 92, Extensible Meta-Object Protocol -- Method Search
at http://tmtowtdi.perl.org/rfc/92.pod

RFC 92 considers an existing Perl 5 module we have that allows
us to write code like the following, and it considers how to make
Perl 6 better support this kind of extensibility via modules (rather
than via new core functionality forced on us all).

package MyClass; use Prothos::Class ISA = ParentClass;

ivar Foo = Public,Write   = Private;
ivar Bar = Private,   Default = "Hello, World";
ivar Baz = Protected, Default = {};  # Hash ivar.

method HelloWorld = Public, sub
{
my ($I, %A) = @_;

$I-Baz(Name = $A{Name}); # Ivar accessor.

print $I-Baz("Name"), " says \"", $I-Bar, ".\n";
};

method Cogitate = Private, sub
{
...
};

method OverrideMe = Protected, Bind = Virtual, sub
{
...
};

Our little class generator does the things we need, without taxing
our conceptual notion of what Perl OO looks like.  As far as I can
tell, RFC 95 doesn't do the things we need, while taxing our notion
of what Perl OO looks like.  So I guess you can chalk up my comment
to be "skeptical", at least for now.

Yours, c, Tony Olekshy



Re: RFC 95 (v1) Object Classes

2000-08-12 Thread Randal L. Schwartz

I'm still saving the proposal for further digestion, but wanted
to get this out quickly:

 "Perl6" == Perl6 RFC Librarian [EMAIL PROTECTED] writes:

Perl6 The existing Cnew keyword can be used to create new object instances
Perl6 of a given class.

There is no existing "new" keyword in Perl.  There's a convention that
the C++ people use when coming into Perl to call the simplest
constructor "new", but any name can be used for a constructor in Perl.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: RFC 95 (v1) Object Classes

2000-08-12 Thread Andy Wardley

 Since you didn't mention it in your references, you may want to
 check out RFC 92, Extensible Meta-Object Protocol -- Method Search
 at http://tmtowtdi.perl.org/rfc/92.pod

I saw it after I posted the RFC.  Yes, this is exactly the kind 
of support that we need in the core to allow us to do things like 
this.

A