Entries tagged lisp
The downfall of Soviet microprocessor technology and Lisp
8 February 2010 (programming lisp)There used to be an old joke about Soviet high-tech, that the downfall of microelectronics technology in the Soviet Union was caused by the finished products not fitting through the factory gate.
I've discovered the exact same problem with Lisp the other day.
The last time I looked for a good binding of GTK+ for Lisp, I came out empty-handed, but now I've discovered a new project called CL-GTK2 that seems really promising. It installed without problems using ASDF-Install (which is, sadly, not a given for most other GTK+ bindings), and even comes with Cairo binding.
So the idea was to rewrite Goblin using Lisp, as an exercise and a test of CL-GTK2's usability. The first playable version, a straight rewrite of the original Python code, came out at about two hundred lines of code. Before making any wild refactorings and adding new features, I've decided to try creating a standalone executable using SBCL and cl-launch, following these instructions.
So it seems deploying standalone executables to end users is still not a realistic option. And no, web apps are not the answer. They may be answers, but to totally different questions.
Eliminating magic strings from ELisp's (interactive)
17 March 2009 (programming language lisp)If you hate magic string API's as much as I do, you'll like this macro replacing Emacs's (interactive) declaration. It allows you to rewrite the following function definition:
"Foobarize the current cursor position and some text entered by the user at the prompt"
(interactive "d\nsPlease enter a value for str: "
(foobarize pos str)))
into the much cleaner form below:
"Foobarize the current cursor position and some text entered by the user at the prompt"
(foobarize pos str)))
It currenty only supports :pos, :region and strings entered at the prompt, but the code is trivial to extend to other initializers.
Type inference for CLazy
22 January 2009 (programming language lisp) (1 comment)CLazy now features Hindley-Milner type inference, the type calculus all the cool guys use. For example, given the following recursive definition of map:
nil)
(defun map (f (cons x xs))
(cons (f x) (map f xs)))
the type inference engine of CLazy correctly reconstructs the following type signature:
Still to come: virtual functions like Haskell's typeclasses. The plan is to define abstract functions like (+ a) :: (fun a a a) and collect requirements for functions in the form of "this function has type (fun a b) as long as an overload for (+ a) exists".
CLazy interpreter and compiler
12 January 2009 (programming language lisp) (2 comments)CLazy is my toy functional programming language featuring a Lisp-like syntax, lazy evaluation, and not much else at the moment. To get a taste of it, here's the definition of map in CLazy, using pattern matching:
(deftype list (t) nil (cons t (list t))) (defun map (f nil) nil) (defun map (f (cons x xs)) (cons (f x) (map f xs)))
I've written the interpreter (in Lisp) back in November, and now I had this idea of writing a compiler. This compiler, instead of generating e.g. x86 assembly code, generates C# which is then compiled into .NET IL.
To do the actual code generation, instead of outright outputting text, the compiler (also written in Lisp) generates an s-expr representation of C# code. For example, the code generated for the type list, as defined above, is represented as the following:
Continue reading »Tooltips for SLIME
25 May 2008 (programming lisp)I came across tooltip-help.el while browsing EmacsWiki for useful SLIME scripts. I tried it out with elisp and it's really great, so I wanted to do something similar for SLIME.
First, you need a trivial change to tooltip-help.el so that the result can come from any buffer, not just *Help*. The problem, then, is that SLIME's slime-describe-symbol is an asynchronous operation, so the *SLIME Description* buffer is not yet ready when th-elisp-get-help-text tries to read the description from it. So here's a synchronous version:
(defun slime-describe-symbol-sync (symbol-name) (unless symbol-name (error "No symbol given")) (with-current-buffer (slime-output-buffer) (slime-with-output-end-mark (slime-mark-output-start))) (let ((package (slime-current-package)) (result (slime-eval `(swank:describe-symbol ,symbol-name)))) (with-current-buffer (slime-output-buffer) (slime-show-last-output) (slime-show-description result package)))) (defun th-lisp-mode-handler () (th-elisp-get-help-text #'slime-describe-symbol-sync (current-word) "*SLIME Description*"))