c - LISP arithmetics implementation -


i'm making toy lisp interpreter d , don't know theory of lisp well.

i wondering if lisp can implement basic arithmetic functions (+, -, ×, ÷) itself. lisp/scheme dialects implemented builtins of c, java-like language , overload lisp code(duplicated implements?).

i want write arithmetic functions lisp code purely. possible?

unless want use church numerals or like, @ point you're going have hardware arithmetic instructions (add, sub, mul, div) 1 way or another.

if going down hardware instructions route, depending on lisp implementation, may implemented using c code (especially interpreter-based implementation), or instructions may emitted directly (for jit compiler-based implementation).

if you're trying first-principles possible, can implement multiplication , division using addition , subtraction instructions (in pinch, can implement them same way taught in school, though you're using word-sized digits—that is, 32-bit machine, each digit base-4294967296 instead of base-10).


Comments