On 10/7/05, chromatic <[EMAIL PROTECTED]> wrote:
> On Fri, 2005-10-07 at 15:22 -0600, Luke Palmer wrote:
> > But you are allowed to overload coersion. Essentially, every
> > expression gets a coerce:<as>($expr, $current_context) wrapped around
> > it (where these are optimized away when they do nothing). If you
> > allow definition of these at runtime, there are two side-effects:
> > 1) No typechecking can ever take place in any form.
> > 2) No coerce calls can ever be optimized away.
> > These are very unfortunate. So I'm inclined to say that you can't
> > overload coersion at runtime.
> No one can ever overload assignment or coercion at run time because you
> want theoretical programs you haven't yet to run VERY VERY FAST?
No, you can't overload assignment at runtime because you can't
overload assigment at any time, so says the language spec (well, not
any formal spec; so says Larry as far as I remember). I gathered that
the reason for this was not for speed, but for semantic consistency,
like in Perl 5. My perspective on the argument is that if you let
people overload assignment, then you make everyone uneasy about
assigning for fear that it will be "dwimmifully" overloaded and not do
the right thing. But I'm just taking that part from what I know.
Also, only the second of my two reasons had to do with speed, which I
agree can't be argued until we see some numbers (but I have a hunch,
because not optimizing away the _many_ do-nothing coersions, you are
effictively adding a complex trace condition in a debugger; and you
have seen how slowly those run). As for the first argument,
presumably people put type annotations on their code so that we can do
some reasoning and tell them about errors. If type annotations didn't
do that for my code, I wouldn't use type annotations (in fact, I
probably won't end up using them too much anyway). But by allowing
the definition of new coersions at runtime, you invalidate any error a
type checker might think it has found.
Not to say that a lexical pragma saying "keep all coersions in the
generated code" so that if you expect to be doing something nasty in a
scope, you can. But again, you kill any typechecking that code might
be wanting, and you probably reduce the code's speed by an order of
magnitude (again, just a guess).