Thanks! Ok, from a type inferencing perspective...

Nathan Torkington wrote:
> 
> Symbolic references are used for dynamic function generation:
>    foreach my $func (qw(red green blue)) {
>      *$func = sub { "<FONT COLOR=$func>@_</FONT>" }
>    }

Probably have to punt on checking user code in a main routine that does
this. But if it's in a module, the inferencer should just get fired up
after all use's and other BEGIN's have been processed so the names and
code for all of those are known.

If you want user code to still get some inference, then you can have no
strict 'refs' everywhere but right here and have a pragma
assume_sub_in_source_is_never_overridden, so that $x = unknown_sub()
pollutes all package vars and all lexical vars captured anywhere by
anything. Though that's tough to verify. But subs would be okay. And
eval"", as usual, would kill pretty much everything.

> Also lazy function generation (similar thing but from within an
> AUTOLOAD).

Same, except known subs will never be overridden.

> Class::Struct does it to mechanically create the subroutines for a
> class.

Same.

> Any object code that gets a class name (package) as an argument and
> uses it to inspect variables in the package does it.

"Inspect", as in, read-only access? Then it's not bad. Does accessing
$p=<>;$x=${"${p}::foo"} activate $foo's tied FETCH? I suppose so. Then
it's bad.

> (off the top of my head)

That's a nasty set of things that I was planning on looking at later to
see what can be salvaged (probably not much), but I was wondering more
about uses of $$x as a symbolic ref access as opposed to scalar
dereferencing. General symbol table manipulation is probably just going
to make the inferencer assume that any function call can rewrite all
other subroutines and piss on all visible variables, file descriptors,
etc., but scalar and array symbol table manipulation may be more
survivable.

I guess it doesn't matter that much, you just don't get any type
inferencing if you don't use strict 'refs' or you do use runtime eval""
or require. But maybe

my $Bob : might_be_accessed_symbolically

would be convenient enough to enable the type inferencer for more
programs.

Reply via email to