
A Cosmac1802 Emulator in 300 Lines of Common Lisp - lisper
https://github.com/rongarret/gll-mag-patch/blob/master/sim1802
======
reikonomusha
This is very neat and a true piece of Lisp history!

Folks unfamiliar with Common Lisp should know that this style of Common Lisp
is quite eclectic. It’s very, very terse and avoids directly using standard CL
functionality like CLOS. The DEFINE-CLASS and DEFINE-METHOD aren’t “standard”,
you won’t be able to find their definition in Lisp’s specification. (They
probably wrote their own little OO system appropriate for the application
domain.)

I contend that using the same old Lisp, this code could be written much more
readably, without sacrificing efficiency (not that you need extreme efficiency
to emulate such a tiny instrument). This would be done by way of using the
standard CLOS functionality, using appropriate names (e.g., DUMP-MEMORY
instead of DM), adding doc strings, and avoiding abbreviation (e.g., the
MACROLET at the end).

~~~
lisper
DEFINE-CLASS and DEFINE-METHOD are very thin wrappers over DEFCLASS and
DEFMETHOD. Rewriting the code using standard CL would not make it
substantially longer. All those macros really do is rearrange the parens
(because I can never remember where the parens go in the standard versions).

DM is called DM rather than DUMP-MEMORY because it was used for debugging and
typing DM over and over was a lot less annoying than typing DUMP-MEMORY.

As for the use of MACROLET, there is nothing non-standard or unconventional
about it.

The definitions of DEFINE-CLASS and DEFINE-MACRO, along with documentation
(and a whole bunch of other stuff) can be found here:

[https://github.com/rongarret/ergolib](https://github.com/rongarret/ergolib)

Specifically:

[https://github.com/rongarret/ergolib/blob/master/core/ergocl...](https://github.com/rongarret/ergolib/blob/master/core/ergoclos.lisp)

~~~
reikonomusha
To be clear, I am not saying any of the decisions were irrational. As a CL
programmer myself, I could read it just fine. But things like “thin wrappers”
and abbreviations to accommodate personal taste lead to an eclectic and
unidiomatic style.

~~~
lisper
CL itself is rather eclectic, so I guess I'll take that as a compliment :-)

------
varjag
(A development tool for patching around the failure in Galileo space probe
magnetometer instrument)

