pixel ([info]pinterface) wrote,
@ 2009-07-17 04:49:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Current mood: amused
Entry tags:lisp, portacl, programming

Announcing PortaCL: The Most Pointless Lisp Library To Date?

  1. .ASD Portability
  2. Extensible Feature Tests
  3. Feature-expression control flow
  4. Give it a Try

While Common Lisp has no shortage of portability libraries to smooth over the differences between implementations, to my knowledge it lacks a wide array of portability library libraries. (The only one I can think of off-hand is trivial-features.)

No more! Now, with PortaCL, portability libraries are a no-brainer!

.ASD Portability

Take this example from trivial-features.asd:

(#+allegro    (:file "tf-allegro")
 #+clisp      (:file "tf-clisp")
 #+cmu        (:file "tf-cmucl")
 #+cormanlisp (:file "tf-cormanlisp")
 #+ecl        (:file "tf-ecl")
 #+lispworks  (:file "tf-lispworks")
 #+openmcl    (:file "tf-openmcl")
 #+sbcl       (:file "tf-sbcl")
 #+scl        (:file "tf-scl")
 #+abcl       (:file "tf-abcl"))
Using portaCL, it becomes:
((:port-file "tf-~/implementation/"))

And adding support for yet-another-obscure-lisp requires nothing more than adding the appropriately-named file.¹

Still not convinced? How about this, from closer-mop.asd:

(:module
 #+allegro "allegro"
 #+clisp "clisp"
 #+ecl "ecl"
 #+lispworks "lispworks"
 #+(or clozure-common-lisp openmcl mcl) "mcl"
 #+(or cmu sbcl) "pcl")
becomes
(:port-module "~/implementation/"
 :alternate-file "pcl")
and
:depends-on (#+allegro "allegro"
             #+clisp "clisp"
             #+ecl "ecl"
             #+lispworks "lispworks"
             #+(or clozure-common-lisp openmcl mcl) "mcl"
             #+(or cmu sbcl) "pcl")
becomes:
depends-on ("~/implementation/")
No muss, no fuss.

Of course, if you've got somewhat lackluster code organization, things get a bit hairier. Take acl-compat.asd, for instance.

Regardless, as you can see, portaCL offers some fairly nice reductions in system definition size for a certain very specific use case. On the other hand, it also increases the magic, making automatic checking of .asd files that much more difficult. But this is Lisp and Lispers hate redundancy.

Extensible Feature Tests

Common Lisp provides and, or, and not feature tests for use in read-time conditionals. I'm fairly certain that's enough, but if it isn't, you can now add your own. For instance, after defining the only-one feature test:

(define-feature-test (only-one :only-one) (&rest rest)
  (= 1 (count-if #'featurep rest)))
you could—assuming you've set up *readtable* properly—, do this:
#-(only-one a b (or c d)) (error "You can't have them all!")

That's right, turing-complete reader-conditionals. And accidental FEXPRs. The insanity! The horror!

Feature-expression control flow

Why do

#+sbcl sbcl-form
#+clisp clisp-form
#-(or sbcl clisp) not-support-form
when you can do
(feature-econd
  (:sbcl sbcl-form)
  (:clisp clisp-form))

Oh, right, because you wanted to use symbols in packages that might not exist in other implementations. Well, so much for that, then.

Give it a Try

Is it useful to you? Is there another style of porting you'd like it to support? Is my code just plain awful? Are you convinced this has to be a joke? Let me know!

For more information, check the project website, notes file, or darcs get http://repo.kepibu.org/portaCL/

  1. And probably pestering me to add support for that lisp to portaCL. Why must there be so many‽



Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…