lisp

Is Lisp the only language with REPL?

你说的曾经没有我的故事 提交于 2019-11-29 23:35:46
There are languages other than Lisp (ruby, scala) that say they use REPL (Read, Eval, Print, Loop), but it is unclear whether what is meant by REPL is the same as in Lisp. How is Lisp REPL different from non-Lisp REPL? The idea of a REPL comes from the Lisp community. There are other forms of textual interactive interfaces, for example the command line interface . Some textual interfaces also allow a subset of some kind of programming language to be executed. REPL stands for READ EVAL PRINT LOOP: (loop (print (eval (read)))). Each of the four above functions are primitive Lisp functions. In

Examples of what Lisp's macros can be used for

醉酒当歌 提交于 2019-11-29 22:48:37
I've heard that Lisp's macro system is very powerful. However, I find it difficult to find some practical examples of what they can be used for; things that would be difficult to achieve without them. Can anyone give some examples? Source code transformations. All kinds. Examples: New control flow statements : You need a WHILE statement? Your language doesn't have one? Why wait for the benevolent dictator to maybe add one next year. Write it yourself. In five minutes. Shorter code : You need twenty class declarations that almost look identical - only a limited amount of places are different.

Understanding how to implement once-only lisp macro

荒凉一梦 提交于 2019-11-29 21:50:31
In Peter Seibel's book "Practical Common Lisp", we can find the definition of the very complicated macro once-only (see the bottom of page http://www.gigamonkeys.com/book/macros-defining-your-own.html ). I'm reading this macro definition for the 10th times in last 3 weeks and cannot understand how it works. :( Worse, I cannot develop this macro on my own, even though I understand its purpose and how to use it. I'm especially interested in systematic "derivation" of this notoriously hard macro, step by step! Any help? Are you looking at this: (defmacro once-only ((&rest names) &body body) (let

What does it mean that “Lisp can be written in itself?”

我的未来我决定 提交于 2019-11-29 21:34:36
Paul Graham wrote that "The unusual thing about Lisp-- in fact, the defining quality of Lisp-- is that it can be written in itself." But that doesn't seem the least bit unusual or definitive to me. ISTM that a programming language is defined by two things: Its compiler or interpreter, which defines the syntax and the semantics for the language by fiat, and its standard library, which defines to a large degree the idioms and techniques that skilled users will use when writing code in the language. With a few specific exceptions, (the non-C# members of the .NET family, for example,) most

What does # mean in LISP

匆匆过客 提交于 2019-11-29 20:41:38
For example, #'functionname , is it necessary? #'functionname in Common Lisp Common Lisp and some other Lisp dialects have more than one namespace. Here the ones for functions and values are different. To get the function value of a name, we need to write: (function functionname) Since that is a bit long to write, there is a shorter notation: #'functionname To show the effect see this: (let ((foo 42)) (flet ((foo () 'bar)) (list foo (function foo) #'foo (foo)))) Above defines a local variable FOO and a local function FOO . The list statement returns the value of FOO , then the function value

Definition of “lisp form”?

老子叫甜甜 提交于 2019-11-29 20:27:18
What exactly the definition of a "Lisp form"? As far as I know, it's "either an atom or a list that has a symbol as its first element". But then, this (in Scheme) would not be a form: ((lambda () 42)) ;; The answer to Life, the Universe and Everything. Because the first element of the list is itself another list. And after it's evaluated it will be a procedure (not a symbol). I can find several different websites and tutorials talking about Lisp forms, but none which gives a complete and detailed definition. Where can I find one? A lisp form is a lisp datum that is also a program, that is, it

Why Clojure over other JVM Lisps: Kawa, Armed Bear or SISC?

我只是一个虾纸丫 提交于 2019-11-29 19:56:19
The JVM already had three Lisps before Clojure arrived on the scene: Kawa , Armed Bear and SISC . What gap does Clojure fill that was left by those Lisps? dnolen Kawa, ABCL, and SISC are reimplementations of existing languages that are quite long in the tooth. They are excellent if for some reason you want to use standard Scheme or standard Common Lisp on the JVM. Clojure is a new language. It doesn't fill a gap . It adds entirely new possibilities. It favors a purely functional approach- Scheme and CL are both multi-paradigm. Clojure borrows heavily from the design of various FP languages (ML

How to write an interpreter?

做~自己de王妃 提交于 2019-11-29 19:55:28
I have decided to write a small interpreter as my next project, in Ruby. What knowledge/skills will I need to have to be successful? I haven't decided on the language to interpret yet, but I am looking for something that is not a toy language, but would be relatively easy to write an interpreter for. Thanks in advance. You will have to learn at least: lexical analysis (grouping characters into tokens) parsing (grouping tokens together into structure) abstract syntax trees (representing program structure in a data structure) data representation (assuming your language will have variables) an

How to live with Emacs Lisp dynamic scoping?

雨燕双飞 提交于 2019-11-29 19:50:33
I've learned Clojure previously and really like the language. I also love Emacs and have hacked some simple stuff with Emacs Lisp. There is one thing which prevents me mentally from doing anything more substantial with Elisp though. It's the concept of dynamic scoping. I'm just scared of it since it's so alien to me and smells like semi-global variables. So with variable declarations I don't know which things are safe to do and which are dangerous. From what I've understood, variables set with setq fall under dynamic scoping (is that right?) What about let variables? Somewhere I've read that

Lazy Evaluation vs Macros

守給你的承諾、 提交于 2019-11-29 19:43:11
I'm used to lazy evaluation from Haskell, and find myself getting irritated with eager-by-default languages now that I've used lazy evaluation properly. This is actually quite damaging, as the other languages I use mainly make lazily evaluating stuff very awkward, normally involving the rolling out of custom iterators and so forth. So just by acquiring some knowledge, I've actually made myself less productive in my original languages. Sigh. But I hear that AST macros offer another clean way of doing the same thing. I've often heard statements like 'Lazy evaluation makes macros redundant' and