a quick question from inexperienced LISP user:
what does the # symbol do, as in the following code:
(DO ((RULE-# 1 (+ 1 RULE-#))
(MAX-NUMB (KEYWD-NUMB-DECOMPS KEY)))
(( > RULE-# MAX-NUMB) NIL) ; End Test
thanx
Jonathan Wohlgelernter
In article <·········································@acis.mc.yu.edu>,
Jonathan Wohlgelernter <········@ymail.yu.edu> wrote:
>a quick question from inexperienced LISP user:
> what does the # symbol do, as in the following code:
>
>(DO ((RULE-# 1 (+ 1 RULE-#))
> (MAX-NUMB (KEYWD-NUMB-DECOMPS KEY)))
>
> (( > RULE-# MAX-NUMB) NIL) ; End Test
In Common Lisp '#' is used as a prefix character for a number of special
sequences, but that's obviously not going on here. It looks like it's
written in a dialect of Lisp where # is treated as an alphanumeric
character, since it's just using it as part of the variable name, as an
abbreviation for "number". In other words, it's equivalent to:
(DO ((RULE-NUMBER 1 (+ 1 RULE-NUMBER)) (MAX-NUMB (KEYWD-NUMB-DECOMPS KEY)))
(( > RULE-NUMBER MAX-NUMB) NIL) ; End Test
--
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin <······@genuity.net> writes:
> In article <·········································@acis.mc.yu.edu>,
> Jonathan Wohlgelernter <········@ymail.yu.edu> wrote:
> >a quick question from inexperienced LISP user:
> > what does the # symbol do, as in the following code:
> >
> >(DO ((RULE-# 1 (+ 1 RULE-#))
> > (MAX-NUMB (KEYWD-NUMB-DECOMPS KEY)))
> >
> > (( > RULE-# MAX-NUMB) NIL) ; End Test
>
>
> In Common Lisp '#' is used as a prefix character for a number of special
> sequences, but that's obviously not going on here. It looks like it's
> written in a dialect of Lisp where # is treated as an alphanumeric
> character, since it's just using it as part of the variable name, as an
> abbreviation for "number". In other words, it's equivalent to:
>
> (DO ((RULE-NUMBER 1 (+ 1 RULE-NUMBER)) (MAX-NUMB (KEYWD-NUMB-DECOMPS KEY)))
>
> (( > RULE-NUMBER MAX-NUMB) NIL) ; End Test
The dialect in which it's written is Common Lisp. ;-)
# does not create a token break. It only has its special meaning at the
start of a token.
I believe this was to acomodate the Zetalisp function ARRAY-#-DIMS or
something like that. Personally, I think it was an awful design decision,
and I always use \# instead of # when I put # in the middle of a token,
even though it's not needed, just because I wish we would one day fix it,
even though we probably never will (for the same reason as we're not fixing
some other hotly debated items). I note the LispWorks system printer (and
probably others) are also paranoid about this, and print such symbols
defensively with a \#.
* Jonathan Wohlgelernter
| a quick question from inexperienced LISP user:
| what does the # symbol do, as in the following code:
|
| (DO ((RULE-# 1 (+ 1 RULE-#))
| (MAX-NUMB (KEYWD-NUMB-DECOMPS KEY)))
|
| (( > RULE-# MAX-NUMB) NIL) ; End Test
# is a constituent character in that context. As such, it does
nothing (special) or exactly the same as the character -. (Note that
in the context of Lisp, "symbol" should not be confused with character
even though the two are sometimes interchangeable in other contexts.)
* Barry Margolin <······@genuity.net>
| In Common Lisp '#' is used as a prefix character for a number of special
| sequences, but that's obviously not going on here. It looks like it's
| written in a dialect of Lisp where # is treated as an alphanumeric
| character, since it's just using it as part of the variable name, as an
| abbreviation for "number".
Well, # is a non-terminating macro character in Common Lisp, so symbol
names like RULE-# are perfectly valid, although somewhat unusual, such
as because people think it is a terminating macro character...
#:Erik
--
ALGORITHM: a procedure for solving a mathematical problem in a finite
number of steps that frequently involves repetition of an operation.
ALGOREISM: a procedure for solving an electoral problem in a finite
number of steps that frequently involves repetition of an operation.