HaloO,

Autrijus Tang wrote:
Yes, I'm aware of Theta's static where clauses, but Perl 6's where
clause is much more dynamic and almost always undecidable.

I know, but what does that buy the programmer? I see a type system
as support of a declarative programming style. Thus the dynamic part
of the type system, that is method dispatch and type instanciation,
has to play in a frame set by the programmer. This is very similar to
regular expressions and grammars. They declare the interpretation of
a string/stream of chars/data. The type system goes on from there to
watch over constraints while this data is processed.


In Litvinov's paper, where clauses are determinisitic at compile time,
as a way to encode structural subtyping (aka duck typing).

Huch, who has coined 'duck typing'? I never heard that before.


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);

Yes, I like that. I also proposed an object special form for
classless instances in namespace.

    # 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

What is 'row polymorphism'?


language, iff Perl 6 indeed adopts a compile-time inferencing engine.

I would call it a bit different, but yes please! My idea is, that the
programmer of Perl 6 can 'store' a lot of information in name/type space
that is later---even at runtime---used by the code generation, class
composition, type instanciation and dispatch system without forcing the
programmer to rummage in the guts, which might actually be very difficult
to do platform independently if not even Parrot is fixed as the underlying
VM!

BTW, is 'special form' a fixed term? I just started using it to decribe
things like sub, class, role, etc. declarations/definitions.
--
$TSa.greeting := "HaloO"; # mind the echo!

Reply via email to