Ralf Hemmecke wrote:
>
> >> Can you point me to where exactly I have broken the contract?
> >>
> >> x exquo y ==
> >> zero? y => "failed"
> >> z := (INTEXQUO(x, y)$Lisp) pretend %
> >> -- or better this?
> >> -- z: % := (INTEXQUO(x, y)$Lisp) pretend %
> >> NULL(z)$Lisp => "failed"
> >> z
> >
> > '%' is Integer here. Using 'pretend' you promise that result
> > of 'INTEXQUO' really is an integer. But 'INTEXQUO' may
> > return Lisp NIL, which is not an integer.
>
> I know, but does that really matter? I then test whether INTEXQUO
> returned NIL and I do this basically via the LISP NULL function, so the
> actual type should not matter at all. In the end my promise "pretend %"
> *is* true (just that the compiler actually should return
> Union(%,"failed") and not % is somewhat a miracle to me).
>
> So, yes, I break it temporarily, but not in a really dangerous way.
Sorry, it is very dangerous. Basically once you promised that
z is an integer _Lisp_ compiler has full right to drop the
NULL test -- after all there result is "staticaly known based on
types". This is not the case here, the compiler is too weak
to do such reasoning in this case, but such things happen
in other cases. With gcl this normally leads to "memory is
corrupted error". By default sbcl behaves nicer and tells you
that there is type error (more precisely by dafault sbcl
insert checks to make sure that you keep your promise),
but at safety 0 the result is similar.
With LLVM backend if you provide wrong information, the compiler
can do really weid things.
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.