[Ecls-list] Type propagator and "bogus" existing code

Tobias C Rittweiler tcr at freebits.de
Sat Jun 19 15:01:13 UTC 2010


In article 
<AANLkTikYgy1xjiEH9CfkEVsIEDg8ZvwjyYJ1-H-vti3N at mail.gmail.com>,
 Juan Jose Garcia-Ripoll 
 <juanjose.garciaripoll at googlemail.com> wrote:

> I am greatly amazed at the improvements in type propagation -- which still
> can not be called liked that, but which does some minimal type inference --,
> probably because the stupid algorithm catches quite many problems already.
> 
> However, precisely due to the simplicity of the current algorithms, one
> thing that may be a showstopper is that there is code around that looks like
> this
>    (when (stringp foo)
>       (replace foo faa ...))
> 
> I am a bit lost here. On the one hand this is valid Lisp, even if FOO is
> inferred to have, say, an integer type. However the compiler will see that
> REPLACE gets arguments of the wrong type and will complain.

I'm not following. What's wrong in the call to REPLACE?

The compiler can infer that FOO inside the branch must have type STRING.
So it emits code accordingly (e.g. inlining REPLACE without general
sequence dispatch). If it  can decide elsewhere that FOO before the
branch actually has type INTEGER, then the _whole_ branch becomes dead
code and can be eliminated.

My point is that the call to REPLACE is never questionable. The WHEN 
form may.

  -T.





More information about the ecl-devel mailing list