Subject: Re: Declaring type of top-level (special) variables?
From: Erik Naggum <erik@naggum.net>
Date: Fri, 12 Apr 2002 14:36:29 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3227610988977654@naggum.net>

* Adam Warner
| Quick question. I'm trying to set a top-level variable of type integer
| (in the expectation that when I perform a division upon the variable I
| will obtain an integer result):

  This expectation cannot possibly be satisfied by a type declaration.  You
  will have to use a division operator that always returns an integer, such
  as floor, ceiling, truncate, or round.

| (defparameter *variablename* 1)
| 
| Now variablename has type FIXNUM.  I'd like to set that to INTEGER.

  This makes no sense, actually.

  The value held in *variablename* is a (or has type) fixnum, but the
  *variablename* does not.  This is not how Common Lisp works.

| I've tried declare but the compiler complains about it being in the top
| level (CMUCL: Error: Misplaced declaration).

  Top-level declarations are done with proclaim or declaim, not declare,
  for whatever it might be worth.  I think many other confusions need to be
  dispelled, so this although it might have been a quick question, the
  full answer is going to be quite lengthy...

///
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg