[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] lispdoc
From: |
Kai Kaminski |
Subject: |
Re: [Axiom-developer] lispdoc |
Date: |
Wed, 16 May 2007 12:18:44 +0200 |
On May 16, 2007, at 11:20 AM, Martin Rubey wrote:
Ralf Hemmecke <address@hidden> writes:
see <http://planet.lisp.org>
I think that won't help me much. But could someone tell me about a
few
conventions used in naming identifiers.
A quick overview of the common conventions (and some not so common
ones) can be found at http://www.cliki.net/Naming%20conventions.
I already know that |blah| keeps blah from being capitalized, but
are the bars
part of the identifier?
no.
When do people use identifiers that are surrounded by *, for example
*default-pathname-defaults*.
*this-is-a-special-variable*
The stars are only a convention, as you noticed already.
A special variable is dynamically scoped - as opposed to the usual
lexical
scoping in lisp. It is introduced via (defvar *this-is-a-special-
variable*)
Or (defparameter *foo* ...). There is a subtle difference, which you
probably don't care for, unless you develop your Lisp in an
interactive way, which is somewhat difficult with the Axiom sources.
Think of a special variable as a global variable.
What about a colon in front of an identifier? For example,
(array-element-type (make-array 10 :element-type 'character))
As far as I know this is also a convention, namely for keyword
arguments.
This isn't quite correct. A symbol that starts with a colon is always
interned in the KEYWORD package, rather than the current package.
Keyword symbols are used for keyword arguments in functions:
(defun foo (bar &key baz (bam 3))
...)
(foo 3 :bam 7 :baz 9)
You couldn't write (foo 3 bam 7 baz 9) instead, hence it is not a
convention in this case.
Keyword symbols are also often used (this is by convention) for
things like
(defun find-extremum (list max-or-min)
...)
(find-extremum '(1 2 3 4 5) :max)
Finally keyword symbols are often used in DSLs, like this example
from cl-who (http://weitz.de/cl-who/):
(with-html-output (*http-stream*)
(:html
(:head (:title "My Homepage"))
(:body (:h1 "hello world"))))
Kai