9

Do you know where can I get the source of a predicate in Common Lisp? (The content of the predicate, if you prefer.) For example, source code of setq, string= etc.

Thanks !

lilawood
  • 333
  • 2
  • 4
  • 10
  • 3
    This is generally a feature of the Lisp dev environment (such as SLIME) you're using. You'd also have to install your Lisp distribution's source code in order to be able to navigate to it. – Bozhidar Batsov May 09 '11 at 08:38

3 Answers3

4

Common Lisp development environments typically provide a way to look up definitions in the file with the source code.

Alternatively, FUNCTION-LAMBDA-EXPRESSION might be able to recover the source of a predicate and other functions, if the Lisp environment has been configured to save the definitions.

You can also search in the lisp files of open source lisp implementations. For example, in Clozure CL setq is defined in the compiler/nx1.lisp file of the distribution. A tip is to place a space in the front of the search word to bypass matches like (setq.

Terje Norderhaug
  • 3,649
  • 22
  • 25
  • Thanks ! I don't use SLIME but I will try. – lilawood May 09 '11 at 18:08
  • This gives code source of predicate like setq, string-compare etc ? – lilawood May 09 '11 at 21:56
  • I checked using the MCLIDE lisp development environment (same back-end as SLIME) with four different Common Lisp implementations: Clozure CL, SBCL, CLISP and MCL. Neither could look up the definition of `SETQ` (even if Clozure has a definition in compiler/nx1.lisp). Only Clozure and MCL were able to find the definition of `STRING=`. You may have better luck going beyond core functions. – Terje Norderhaug May 09 '11 at 23:13
1

For at least SBCL, SLIME can look up the definitions by pressing "M-.", however you need to have compiled SBCL from source for this to work, as the path to the source definitions are embedded in the binary, and if you use a binary distribution you are probably not going to have the source files in the same location.

Elias Mårtenson
  • 3,820
  • 23
  • 32
0

SETQ is not a predicate. It is not even a function, which is why you couldn't find it through the IDE. STRING= is a predicate and a function, so works better.

Do you mean "primitive?" for "predicate"?

mtraven
  • 179
  • 1
  • 7