Subject: Re: newbie question
From: Erik Naggum <>
Date: Thu, 27 Jun 2002 22:01:59 GMT
Newsgroups: comp.lang.lisp
Message-ID: <>

* alinabi <>
| How should I set a to make the previous test return nil?

  The type you want is one of the float types.  The superclass float is not
  useful for specialization.  One of the types short-float, single-float,
  double-float, or long-float is what you want.  You must specify it with
  :element-type if you want the array to be specialized for that type.  (This
  is pretty clear from the specification.  Please do not try to guess how
  things work when there is a specification available.)  An array does not
  become specialized just because you stuffed it with objects of a particular
  type at one point -- the Common Lisp runtime system has no way of determining
  what you wuold like to do with it and whether specializing it without your
  request would break something.  Neither does it know that a specialized array
  you have just created will be the only binding of the variable -- it could
  figure it out, but it is easier for you to tell it if you know, anyway.

  Note that if you try to mix a floating point number and a string in an array
  that you have specialized for some floating-point type, you have lied to the
  compiler.  How and when it will exact its revenge is not specified.  Again,
  see the specification.  Even if you can lie to some compilers all of the time
  and all compilers some of the time, you cannot lie to all compilers all of
  the time.

  Note that the variable *read-default-float-format* holds the type that the
  Common Lisp reader returns if you use an unadorned floating point number.

  As a general observation, however, you are probably barking up the wrong tree
  and need some readjustment to your expectations.  Please consider a textbook
  on Common Lisp which can clear up the confusions that led to where you asked
  this question.
  Guide to non-spammers: If you want to send me a business proposal, please be
  specific and do not put "business proposal" in the Subject header.  If it is
  urgent, do not use the word "urgent".  If you need an immediate answer, give
  me a reason, do not shout "for your immediate attention".  Thank you.