# Lesson XV Change the ink while the brush is still. See what remains. Then the line can be trusted. ## Try ```prolog ?- E = kernel, run(E, [push(real(2.5)), push(int(1)), cast(real), add], [], Stack). Stack = [real(3.5)]. ?- E = kernel, run(E, [push(real(2.9)), cast(int)], [], Stack). Stack = [int(2)]. ?- E = kernel, infer(E, [cast(real), add], Scheme). Scheme = scheme([], effect([int, real|S], [real|S])). ``` ## Lesson Casts are added as explicit primitives instead of changing arithmetic to coerce implicitly. Preserving the previous same-type arithmetic rows matters: conversion remains a word in the object language, so programs expose where representation changes happen. ```prolog word(kernel, cast(real), [A::int|S] -- [B::real|S], [], B is float(A)). word(kernel, cast(real), [A::real|S] -- [A::real|S], [], true). word(kernel, cast(int), [A::real|S] -- [B::int|S], [], B is truncate(A)). word(kernel, cast(int), [A::int|S] -- [A::int|S], [], true). ``` [[14_lesson|Prev]] | [[16_lesson|Next]]