In C, if I want to see a function that how to work, I open the library which provides the function and analyze the code. How can be implementations of the lisp functions seen? For example, intersection function
-
3In C, you can only do that if the library is free software. For a proprietary library, you are stuck.... And on Linux, for system calls, most of the job is done inside the kernel, so it is much harder than what you believeBasile Starynkevitch– Basile Starynkevitch2015-10-15 06:39:22 +00:00Commented Oct 15, 2015 at 6:39
-
wow I didn't know it. thanks @BasileStarynkevitchSoner from The Ottoman Empire– Soner from The Ottoman Empire2015-10-15 06:47:05 +00:00Commented Oct 15, 2015 at 6:47
-
2This is a very low quality question. The question is a poor fit for Stackoverflow (it is not about an actual programming problem) and the author has shown no effort.Rainer Joswig– Rainer Joswig2015-10-15 07:37:30 +00:00Commented Oct 15, 2015 at 7:37
-
1@itsnotmyrealname: it's not about me. It's about you. You should at least have described which functions's source code in what implementation on what operating system you have tried to find and what you tried. Lisp is a group of languages. Finding source code of the actual language implementation might be different.Rainer Joswig– Rainer Joswig2015-10-15 07:42:58 +00:00Commented Oct 15, 2015 at 7:42
-
intersection implemented with equal I try to solve the problem stackoverflow.com/questions/33125889/… @Rainer JoswigSoner from The Ottoman Empire– Soner from The Ottoman Empire2015-10-15 07:44:57 +00:00Commented Oct 15, 2015 at 7:44
2 Answers
You can also look at the source code of lisp functions.
For example, the source files for CLISP, one Common Lisp implementation, are available here: http://www.clisp.org/impnotes/src-files.html
If you want to examine the implementation of functions related to lists, you can look at the file: http://clisp.cvs.sourceforge.net/viewvc/clisp/clisp/src/list.d
Comments
The usual answer is "M-."
Assuming you have a properly configured IDE, and the source code of the function, clicking on its name and pressing M-. (that's Meta, or Alt or Option or Escape, and dot/period; or whatever key your IDE uses) should reveal its definition (or, for a generic function, definitions, plural; including any compiler macros that might optimize out some cases). Sometimes it's on a right-click or other mouse menu or toolbar.
If the source isn't available, you can often see the actual compiled form by evaluating (disassemble 'function)
Most IDE's, including perennial favourite Emacs+Slime, have other Inspection operations on the menu as well.
In a non-IDE environment, most compilers have reflection tools of their own (compiler-dependant) which are usually also mapped by the Swank library that Slime uses; one might find useful function in that package.
And this really should be documented in your IDE's manual.
I should postscript this that:
You really shouldn't care about the implementation of the core library functions; their contractual behavior is very well documented in the CLHS standard, which is available online and eg, Quicklisp has an utility to link it to Slime (C-c C-d h on a symbol in the COMMON-LISP package); for all well-written Lisp libraries, there should be documentation attached to functions, variables, classes, etc. accessible via the documentation function in the REPL or the IDE's menus and Inspection windows.
Core library functions are often highly optimized and far more complex than most user-level code should want to be, and often call down into compiler-specific "guts" that one should avoid doing in application code.