On Fri, May 02, 2008 at 11:34:33AM +0200, TSa wrote: > My idea is that foo:( Foo &f ) should mean the same as > foo:( Foo $x ), that is the variables have to contain a > value that does Foo.
No, I think &f should be treated more like @f and %f as a composite object with a normal return type for the standard usage of the object. Just as @ already implies "Array of" and % already implies "Hash of", so too & already implies "Function of". > Note that this implies that > > sub mysub {...} > > occupies two slots in the surrounding namespace &mysub and > ::mysub. The latter is a type that can be used as > > sub mysubuser ( mysub &f ) {...} > > sub yoursub does mysub {...} > > mysubuser( &yoursub ); # OK > > sub blahh (Int $x) does mysub {...} # composition error I don't think most people want to think of functions as types--it just clutters up the type namespace. They can already say: sub mysubuser ( &f where &mysub.sig ) {...} or some such to do explicit smartmatching against the &f object. Alternately if they really want the type they can say subset mysub of Code where &mysub.sig; sub mysubuser ( &f where mysub ) {...} # note & sub mysubuser ( mysub $f ) {...} # note $ Larry