lisp

Current memory usage in Lisp

房东的猫 提交于 2019-12-04 08:38:47
I need to find out, from within a Common Lisp program, how much memory is currently being used. I'm given to understand there is no portable method (the standard function room prints the information to standard output in text form instead of returning it as a value), but sb-kernel:dynamic-usage works in SBCL. What are the equivalents in other Common Lisp implementations? Or is there another way to solve this problem I should be looking at? It may not help you much, but anyway: You can capture the output of (room) and parse it. (with-output-to-string (*standard-output*) (room)) Above returns a

Eval-when uses?

為{幸葍}努か 提交于 2019-12-04 08:30:30
问题 After reading a lot of documentation regarding Lisp eval-when operator I still can't understand its uses, I know with this operator I can control the evaluation time of my expressions but I can't figure out any example where this may be applicable ? Best Regards, utxeee. 回答1: Compilation of a Lisp file Take for example the compilation of a Lisp file. The Lisp compiler processes the top-level forms. These can be arbitrary Lisp forms, DEFUNs, DEFMACROS, DEFCLASS, function calls,... The whole

Why does TCO require support from the VM?

牧云@^-^@ 提交于 2019-12-04 08:25:04
Some VMs, most notably the JVM, are said to not support TCO. As a result, language like Clojure require the user to use loop recur instead. However, I can rewrite self-tail calls to use a loop. For example, here's a tail-call factorial: def factorial(x, accum): if x == 1: return accum else: return factorial(x - 1, accum * x) Here's a loop equivalent: def factorial(x, accum): while True: if x == 1: return accum else: x = x - 1 accum = accum * x This could be done by a compiler (and I've written macros that do this). For mutual recursion, you could simply inline the function you're calling. So,

Common Lisp: compilation vs evaluation

北战南征 提交于 2019-12-04 08:18:32
On Emacs + Slime with sbcl, once I define a function (or more) in a file I have two choices: Evaluation : e.g. with C-M-x eval-defun Compilation : e.g. with C-c M-k compile-file The second one produces a .fasl file, too. What are the differences between the two? What's going on under the hood when I compile a definition / a file? What are the Pros and Cons of each one? First of all, there's a function eval [ 1 ], that allows to evaluate (i.e. execute) arbitrary CL form in the language runtime. CL implementations may have 2 different modes of operation: compilation mode and interpretation mode.

Language requirements for AI development [duplicate]

雨燕双飞 提交于 2019-12-04 07:50:36
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Why is Lisp used for AI? What makes a language suitable for Artificial Intelligence development? I've heard that LISP and Prolog are widely used in this field. What features make them suitable for AI? 回答1: Overall I would say the main thing I see about languages "preferred" for AI is that they have high order programming along with many tools for abstraction. It is high order programming (aka functions as first

Why is there no tail recursion optimization in Emacs lisp, not but like other scheme?

落花浮王杯 提交于 2019-12-04 07:48:25
Emacs lisp is a dialect of LISP and especially Scheme. Most of scheme interpreters do have a optimization of Tail Recursion, but emacs lisp doens't. I searched the reason in `info elisp' for a while, but I fail to find it. P.S. Yes, there is other iteration syntax in elisp like `while', but I still cannot find a good reason why they didn't implement tail recursion like other scheme interpreters. Emacs Lisp was created in the 1980's. The Lisp dialect that the Emacs author (Richard Stallman) was most familiar with at the time was MIT Maclisp, and Emacs Lisp is very similar to it. It used dynamic

Python Macros: Use Cases?

筅森魡賤 提交于 2019-12-04 07:44:08
问题 If Python had a macro facility similar to Lisp/Scheme (something like MetaPython), how would you use it? If you are a Lisp/Scheme programmer, what sorts of things do you use macros for (other than things that have a clear syntactic parallel in Python such as a while loop)? 回答1: Some examples of lisp macros: ITERATE which is a funny and extensible loop facility CL-YACC/FUCC that are parser generators that generate parsers at compile time CL-WHO which allows specifying html documents with

Best Common Lisp IDE [closed]

社会主义新天地 提交于 2019-12-04 07:36:50
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I've used Slime within Emacs as my primary development environment for Common Lisp (or Aquamacs on OS X), but are there other

What is your opinion on Clojure? [closed]

一曲冷凌霜 提交于 2019-12-04 07:33:47
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not

Which dialect of Lisp should I learn? [closed]

廉价感情. 提交于 2019-12-04 07:28:50
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . I know there are a few different dialects of Lisp. Having decided that learning Lisp would be a new intellectual experience, I would like to know which Lisp dialect to learn, and why. Is there one which is more popular than the others? Is any one of them more "complete", as