RE: Private contracts?

2002-10-03 Thread Trey Harris
In a message dated Thu, 3 Oct 2002, Garrett Goebel writes: > Michael G Schwern: > > On Thu, Oct 03, 2002 at 05:30:49PM -0400, Trey Harris wrote: > > > In a message dated Thu, 3 Oct 2002, Michael G Schwern writes: > > > > > > > On Thu, Oct 03, 2002 at 03:59:08PM -0400, Mike Lambert wrote: > > > >

Re: Private contracts?

2002-10-03 Thread Mike Lambert
Michael G Schwern wrote: > How exactly does one "weaken" a precondition? Say I define a mathematical mod() function in my parent number class. precondition: $a > 0, $b > 0, $b is int mod( $a, $b ) Then in my subclass, I want to make it work in a wider variety of contexts. I change the definiti

Re: Delegation syntax?

2002-10-03 Thread Michael G Schwern
On Fri, Oct 04, 2002 at 12:28:29AM -0400, Trey Harris wrote: > I think my point here is that there are clearly places where we need > stronger built-in support in Perl of some OO concepts. Delegation may not > be one of them--it's easy enough to graft on, and TMTOWTDI may be good > here. Delegat

Re: Delegation syntax? (was: Re: Private contracts)

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 07:59:33PM -0600, John Williams wrote: > Reaction #2: Inheritance would automatically delegate all those > methods, so again, in what way does inheritance _not_ solve the problem? I don't think p6l is the right place to discuss the merits of delegation, let's just say it'

Re: Delegation syntax?

2002-10-03 Thread Trey Harris
In a message dated Thu, 3 Oct 2002, Michael Lazzaro writes: > On Thursday, October 3, 2002, at 04:25 PM, Michael G Schwern wrote: > > Class::Delegation? > > Yeah, it's one of the best I've seen: it makes sense, does everything I > want, and is easy to explain even to newbies. The perl5 hash-bas

Re: Private contracts?

2002-10-03 Thread Trey Harris
In a message dated Thu, 3 Oct 2002, John Williams writes: > On Thu, 3 Oct 2002, Trey Harris wrote: > > > Incidentally, has there been any headway made on how you DO access > > multiple classes with the same name, since Larry has (indirectly) promised > > us that? I.e., I import two classes "Link

Re: Private contracts?

2002-10-03 Thread John Williams
On Thu, 3 Oct 2002, Trey Harris wrote: > Incidentally, has there been any headway made on how you DO access > multiple classes with the same name, since Larry has (indirectly) promised > us that? I.e., I import two classes "LinkedList" and "BTree", both of > which define a "Node" class? Hopeful

Re: Private contracts?

2002-10-03 Thread John Williams
On Thu, 3 Oct 2002, Allison Randal wrote: > On Thu, Oct 03, 2002 at 03:00:21PM -0400, Michael G Schwern wrote: > > On Thu, Oct 03, 2002 at 02:46:38PM -0400, Michael G Schwern wrote: > > > class ATV is Car, interface { > > > > Hmmm. That should probably be > > > > class ATV isa Car is i

Re: Delegation syntax? (was: Re: Private contracts)

2002-10-03 Thread John Williams
On Thu, 3 Oct 2002, Michael Lazzaro wrote: > > 1) Delegation through inheritance: > (a.k.a. "mixin" classes, "hard delegation", "concrete interfaces", > etc., etc.) > > Example: I want to say that a class DataManager has the capabilities > of the interfaces DataStrategy and Cache

Re: Delegation syntax?

2002-10-03 Thread Michael Lazzaro
On Thursday, October 3, 2002, at 04:25 PM, Michael G Schwern wrote: > On Thu, Oct 03, 2002 at 03:54:09PM -0700, Michael Lazzaro wrote: >> I have no *good* syntax proposals for this, I don't think I've ever >> seen the problem solved with syntax that I really ever liked. > > Class::Dele

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 07:23:14PM -0400, Michael G Schwern wrote: >invar { .shoulders == .knees == .toes == 2 } This may explain why I can only count to 12 with my shoes off. As this is my 3rd reply to myself in the thread, I'll call it a night. :) -- Michael G. Schwern <[EMAIL PR

Re: Delegation syntax? (was: Re: Private contracts)

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 03:54:09PM -0700, Michael Lazzaro wrote: > I have no *good* syntax proposals for this, I don't think I've ever > seen the problem solved with syntax that I really ever liked. Class::Delegation? -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 06:46:14PM -0400, Michael G Schwern wrote: > I see us already smashing too many things into the method signature as it > is. It will rapidly get messy if you have a method with a complex signature > and a handful of attributes and preconditions. I think I have my own coun

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 04:47:26PM -0500, Garrett Goebel wrote: > > And if we make pre/post conditions and class invariants > > always enforced... > > no. > > post-conditions and invariants are always enforced, but pre-conditions are > different. Right, right. > A derived interface can loose

RE: Private contracts?

2002-10-03 Thread Garrett Goebel
Michael G Schwern: > On Thu, Oct 03, 2002 at 05:30:49PM -0400, Trey Harris wrote: > > In a message dated Thu, 3 Oct 2002, Michael G Schwern writes: > > > > > On Thu, Oct 03, 2002 at 03:59:08PM -0400, Mike Lambert wrote: > > > > With pre/post conditions, a subclass is allowed to weaken the > > > >

Delegation syntax? (was: Re: Private contracts)

2002-10-03 Thread Michael Lazzaro
On Thursday, October 3, 2002, at 03:18 PM, Paul Johnson wrote: >> (As a lame aside, are we going to have a concept of "private" vs. >> "protected" vs. "public", or just private/public? > > No protected. Even Stroustrup admits it was a mistake in D&E. Oh, thank God. I was hoping people would sa

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 05:30:49PM -0400, Trey Harris wrote: > In a message dated Thu, 3 Oct 2002, Michael G Schwern writes: > > > On Thu, Oct 03, 2002 at 03:59:08PM -0400, Mike Lambert wrote: > > > With pre/post conditions, a subclass is allowed to weaken the > > > preconditions or strengthen th

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 02:29:57PM -0700, Michael Lazzaro wrote: > Do you think it's sufficiently clear to newbies that the pre { } is > associated with the "signature" of the turn() interface method, and not > just the _implementation_ of turn() in Vehicle? The rule would be pretty simple to t

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 05:23:08PM -0500, Jonathan Scott Duff wrote: > I don't know, but I think it's supposed to be like this: > > # part of the signature > method turn($dir,$ang) is pre { $ang <= 20 } { > ... > } > > # part of the implementation > method tur

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 04:54:13PM -0500, Garrett Goebel wrote: > Garrett Goebel: > > Michael G Schwern: > > > But I don't want my subclasses to be constrained by that. > > > It's just an implementation detail that I only wish to > > > enforce upon ATV and not it's children. > > implementation

Re: Private contracts?

2002-10-03 Thread Jonathan Scott Duff
On Thu, Oct 03, 2002 at 02:29:57PM -0700, Michael Lazzaro wrote: > One question I still have is the syntax of pre/post conditions, e.g: > > > method turn($direction, $how_sharp) { > > pre { $how_sharp <= 20 } is private; > > ...implementation... > >

Re: Private contracts?

2002-10-03 Thread Paul Johnson
On Thu, Oct 03, 2002 at 02:29:57PM -0700, Michael Lazzaro wrote: > (As a lame aside, are we going to have a concept of "private" vs. > "protected" vs. "public", or just private/public? No protected. Even Stroustrup admits it was a mistake in D&E. -- Paul Johnson - [EMAIL PROTECTED] http://ww

RE: Private contracts?

2002-10-03 Thread Garrett Goebel
Garrett Goebel: > Michael G Schwern: > > But I don't want my subclasses to be constrained by that. > > It's just an implementation detail that I only wish to > > enforce upon ATV and not it's children. implementation details don't belong in interfaces

Re: Private contracts?

2002-10-03 Thread Trey Harris
In a message dated Thu, 3 Oct 2002, Allison Randal writes: > So far, classes are uppercase and properties are lowercase, but that's > convention, not law. Do runtime (value) properties and compile-time (variable) properties share the same namespace? That is, to go back to an earlier discussion,

RE: Private contracts?

2002-10-03 Thread Garrett Goebel
Michael G Schwern: > > I've been mucking about a bit more with this whole interface thing. > > So if we make method signatures only enforced on subclasses > if the parent class or method has the interface property... > > except private methods, obviously. > > And if we make pre/post condi

Re: Private contracts?

2002-10-03 Thread Allison Randal
On Thu, Oct 03, 2002 at 05:14:22PM -0400, Michael G Schwern wrote: > On Thu, Oct 03, 2002 at 03:45:33PM -0500, Allison Randal wrote: > > On Thu, Oct 03, 2002 at 03:00:21PM -0400, Michael G Schwern wrote: > > > On Thu, Oct 03, 2002 at 02:46:38PM -0400, Michael G Schwern wrote: > > > > class ATV

Re: Private contracts?

2002-10-03 Thread Trey Harris
In a message dated Thu, 3 Oct 2002, Michael G Schwern writes: > On Thu, Oct 03, 2002 at 03:59:08PM -0400, Mike Lambert wrote: > > With pre/post conditions, a subclass is allowed to weaken the > > preconditions or strengthen the postconditions. > > How exactly does one "weaken" a precondition? Yo

Re: Private contracts?

2002-10-03 Thread Michael Lazzaro
> Makes sense, no? I like that quite a lot. One question I still have is the syntax of pre/post conditions, e.g: > method turn($direction, $how_sharp) { >pre { $how_sharp <= 20 } is private; >...implementation... > } This is obvious

Re: Private contracts?

2002-10-03 Thread Trey Harris
In a message dated Thu, 3 Oct 2002, Allison Randal writes: > However they're defined, they will be clearly marked internally as > properties, so there's little risk of confusing property attachment with > inheritance. except that they seem to share a single namespace, since both user-defined

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 03:59:08PM -0400, Mike Lambert wrote: > With pre/post conditions, a subclass is allowed to weaken the > preconditions or strengthen the postconditions. How exactly does one "weaken" a precondition? -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~sc

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 03:45:33PM -0500, Allison Randal wrote: > On Thu, Oct 03, 2002 at 03:00:21PM -0400, Michael G Schwern wrote: > > On Thu, Oct 03, 2002 at 02:46:38PM -0400, Michael G Schwern wrote: > > > class ATV is Car, interface { > > > > Hmmm. That should probably be > > > >

Re: Private contracts?

2002-10-03 Thread Allison Randal
On Thu, Oct 03, 2002 at 03:00:21PM -0400, Michael G Schwern wrote: > On Thu, Oct 03, 2002 at 02:46:38PM -0400, Michael G Schwern wrote: > > class ATV is Car, interface { > > Hmmm. That should probably be > > class ATV isa Car is interface { That's: class ATV is Car is interf

Re: Private contracts?

2002-10-03 Thread Allison Randal
On Thu, Oct 03, 2002 at 02:46:38PM -0400, Michael G Schwern wrote: > > attr _tilt is private; BTW, that's: attr $.tilt; Attributes are private by default. Allison

Re: Private contracts?

2002-10-03 Thread Mike Lambert
> I've been mucking about a bit more with this whole interface thing. > > So if we make method signatures only enforced on subclasses if the parent > class or method has the interface property... > > except private methods, obviously. > > And if we make pre/post conditions and class invariants

Re: Private contracts?

2002-10-03 Thread Michael G Schwern
On Thu, Oct 03, 2002 at 02:46:38PM -0400, Michael G Schwern wrote: > class ATV is Car, interface { Hmmm. That should probably be class ATV isa Car is interface { -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROT

Private contracts?

2002-10-03 Thread Michael G Schwern
I've been mucking about a bit more with this whole interface thing. So if we make method signatures only enforced on subclasses if the parent class or method has the interface property... except private methods, obviously. And if we make pre/post conditions and class invariants always enfor