On Tue, Aug 02, 2005 at 12:49:06PM +1000, Brad Bowman wrote:
> > 1. Asserted
> >
> > The usual case for Perl 6 functions, due to its default "Item"
> > signature for parameters. In the example below, I assume that ::*
> > cannot
> > be changed freely to do away with ::*IO at runtime. (If it could, then
> > assertions won't be of much use in general.)
> >
> > sub f (IO $x) { $x.close }
> > f(open('/etc/passwd'));
> >
> > As both &f and &open may be rebound at runtime, we cannot guarantee that
> > this will not go wrong. However, we can insert an runtime assertion
> > for $x
> > in &f's scope, so we can avoid doing the same assertion in &*IO::close
> > again. If IO is declared as final, then &*IO::close can also be
> > resolved
> > statically.
>
> Could this be implemented optimistically, with disabled
> assertions which are enabled at runtime if either &f or &open
> are rebound?Yes, it is conceivable to hoist assertions whereever possible, and reactivate them if the earlier assertion no longer hold due to rebind. I'll prototype it a bit and see if it works. Thanks, /Autrijus/
pgpqpQfSQcRj8.pgp
Description: PGP signature
