Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a few basic mistakes/problems. But with only two small changes we can get your example to work in Common Lisp.</p> <ul> <li><p>Emacs Lisp's compatibility package for Common Lisp is not really a Common Lisp. It is generally preferable to use a real Common Lisp implementation. Emacs Lisp lacks a few basic things that are hard to emulate to make it compatible with Common Lisp - for example <strong>lexical closures</strong> (update 2014, the latest version of GNU Emacs now also supports lexical closures).</p></li> <li><p>Minor change: I changed your example so that the database does not contain Steve Jobs twice, but Steve Jobs and Steve Ballmer.</p></li> </ul> <p>Now, what would we need to change to make it work in Common Lisp?</p> <ul> <li><p>(getf employee :first-name) should really be (employee-first-name employee) . The DEFSTRUCT macro generates these accessor functions automatically. In Common Lisp you can't use GETF to access the fields of real structures.</p></li> <li><p>Your database has two objects with the name STEVE (a symbol), but you are searching for the name "steve" (a string). (equal 'steve "steve") is false. In general a symbol is not EQUAL to a string. So you should search with (select-by-first 'steve).</p></li> </ul> <p>In LispWorks then:</p> <pre><code>CL-USER 11 &gt; (select-by-first "steve") NIL CL-USER 12 &gt; (select-by-first 'steve) (#S(EMPLOYEE :AGE 53 :FIRST-NAME STEVE :LAST-NAME BALLMER :SEX MALE :CHILDREN NIL) #S(EMPLOYEE :AGE 43 :FIRST-NAME STEVE :LAST-NAME JOBS :SEX MALE :CHILDREN NIL)) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload