Autrijus convinced me that we have to really nail down the semantics
of type annotation without "use static".   Let's first nail down what
I meant by "semantics" in that sentence.  Basically, when do various
things get checked?  Run time or compile time (not coercion; I have a
proposal for that coming).

Oh, I'm asking p6l here, not Larry in particular.  This part of the
language is yet-undesigned, so some arguments one way or the other
would be nice to hear.

So we're in line one of a Perl program, with static typing/inference
disabled (or at least inference *checking* disabled; perl may still
use it for optimization).  When do the following die: compile time
(which includes CHECK time), run time, or never?

    my Array $a = 97;      # dies eventually, but when?
    my Int   $b = 3.1415;  # dies at all?

    sub foo (Int $arg) {...}
    foo("hello");          # should die at the latest when foo() is called

    sub bar (Int $arg --> Str) {...}

    sub static  (Code $code, Array $elems --> Array) {
        [ ${ $code($_) } ]
    sub dynamic ($code, $elems) {
        [ ${ $code($_) } ]
    static({ $_+1 }, dynamic("notcode", [1,2,3,4,5]));
    dynamic("notcode", static({ $_+1 }, [1,2,3,4,5]));

That should cover most of the interesting cases.


Reply via email to