On Fri, Jul 29, 2005 at 06:36:45PM +0200, "TSa (Thomas Sandla�)" wrote: > you wrote: > >Interested readers can consult Manfred Widera's similar work for Scheme, > >in his "Complete Type Inference in Functional Programming" paper. > > Uih, you call a 300 page book a paper? I'm impressed.
Well, it's his dissertation, and Dissertation.does(Paper), including book-length ones. :-) > If that is the thing you read between tramp stations here's one of my > favorites which is the thesis of Vassily Litvinov. It's about CBP. > > http://www.cs.washington.edu/research/projects/cecil/www/Papers/vass-thesis.html Yes, I'm aware of Theta's static where clauses, but Perl 6's where clause is much more dynamic and almost always undecidable. In Litvinov's paper, where clauses are determinisitic at compile time, as a way to encode structural subtyping (aka duck typing). In Perl 6 pseudo-syntax, it would be something like this: sub foo ( $obj where { .can( name => 'bar', signature => :(() returns Int), ) } ) returns Int { $obj.bar(); } It's a bit verbose, but I don't know if there is a way to express named methods to .can succintly. A long name in .can(&bar:(() returns Int)) won't do, as &bar would have been a variable lookup. =begin digression As an aside, arguably we could have dropped the braces and write: Any $obj where .can(...) Except this is yet another violation of no-auto-bracing rule that can result in ambiguous parses; I think it's a misfeature to allow Str where /^[isnt⎪arent⎪amnot⎪aint]$/; This is much more consistent: Str where { /^[isnt⎪arent⎪amnot⎪aint]$/ }; =cut The important difference is that the .can() call in Perl 6 would be a runtime call. It has to be that way, because .can is not a special form; it's just a normal method returning a boolean. If you really want static treatment, that needs a special form: sub foo ( $obj can bar:(() returns Int) ) returns Int { $obj.bar(); } It will allow constructs such as this: my subtype Duck has $.half_life can doom:() can quake:(() returns Wolfenstein); # Automagically satisfied iff $obj's interface is compatible $obj.does(Duck); Such implicitly-declared Roles is certainly powerful, and we can apply the same inferencing treatment as for nominal subtyping violations -- fatal error under closed/finalized, raise warning by default. I think it's cute, and adds real power of row polymorphism to the language, iff Perl 6 indeed adopts a compile-time inferencing engine. > BTW, have we as a list considered approaching Universities for assistence? > E.g. I regard Perl6 as a worthwhile research subject and/or platform. > After all Manfred Widera's thesis was done at a German University. It seems to me that to approach researchers for assistance, one need to give a formal treatment of the language, or at least a specification that can lead to unambiguous implementations. Which is why I'd like to formalize the internal language (PIL), basic types and meta-object protocol, after all... :-) Thanks, /Autrijus/
pgppN7W1Hwxa1.pgp
Description: PGP signature