Michael Lazzaro wrote:3) If an "untyped" var is used for a typed parameter, a simple dataflow analysis is used to determine whether the compiler can guarantee that, at that point, an "untyped" var will _always_ contain values of a known, specific type. If so, the type is inferred (silently or with a warning, according to pragma?) Otherwise, it is a compile-time error.
I was suggesting something slightly more subtle:
* If the dataflow says its definitely wrong, then its an error
* If the dataflow says its definitely OK, it is OK -- no warning, nor error, nor run-time check
* Otherwise (silently or with warning), defer to run-time check
The coercsion aspect makes it slightly more complex, but not significantly so.
Sorry -- I agree 100% with that. As a language feature, it has problems, as Luke & Angel both pointed out. As a mere optimization of case #2, it's fine, and there's not really any language implications. In tight loops, etc., it would probably speed up the runtime quite a bit, in fact.
The optional warning if it falls through to the runtime check is important, IMO, because even lazy one-off scripts sometimes need to be fast. :-/
It would still mean that, in 'non-strict' mode, you might get different "deferring to runtime typechecking" warnings on different versions of P6, but I don't see that as a big issue, if it's just an optional warning.
MikeL