On Mar 29, 9:24 am, Michele Simionato <[email protected]>
wrote:
> Uhm ... But what's the rationale for deferring the error so
> late? I must confess that I am dubious
> about this "feature". What it is you opinion?
> Should the standard allow smart compilers, able to
> evaluate at compile time (some of) the definitions
> to reject invalid programs or not?
> In the case of the zero-division-error we are discussing
> there is no way this can ever be a valid program, so
> why to make acceptable something which will never run?
> To be clear: I want to understand if the current
> behavior is the way it is just for performance
> reasons, for simplicity reasons (we don't want
> to require too smart compilers), or if there is
> something else I am missing.
>

It's not about smart compilers. The spec says, the procedure must
check its arguments when applying the procedure. This application must
still happen at runtime, regardless, if even bogus or incorrect arity,
etc. So given the arguments are correct, we can still deliver the
exact required semantics but using constant folding (almost
guaranteeing the program is correct).

The best we (implementers) can do, is raise a 'syntax warning'
perhaps.

>
> BTW, I have another question, is the Ikarus compiler
> smart enough to find errors like this one even in
> internal definitions.
> In principle definitions of the kind
>
> (define x <some expression depening only on names known
>            at compile time>)
>
> could be evaluated at compile time everywhere in the
> program, not only at top level.

Depending on the constant analysis, it could detect such an error at
compile time. If there is no error, the optimization can take place.

Depending on type analysis, it could even detect incorrect argument
types. Again, if no error, perhaps a specialized/unsafe version of a
procedure can be used.

Also, then procedural integration can take place, helping the above
mentioned, even further.

This all helps optimizing correct programs. It seems 'we' are not to
care about optimizing incorrect ones.

Cheers

leppie




Reply via email to