home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / mcl / 1291 < prev    next >
Encoding:
Text File  |  1992-08-21  |  2.8 KB  |  96 lines

  1. Newsgroups: comp.lang.lisp.mcl
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!mips!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!fauern!dec16!NewsWatcher!user
  3. From: poeck@informatik.uni-wuerzburg.de (karsten poeck)
  4. Subject: Re: simple vector
  5. Message-ID: <poeck-210892143155@132.187.103.165>
  6. Followup-To: comp.lang.lisp.mcl
  7. Sender: news@informatik.uni-wuerzburg.de (USENET News account)
  8. Organization: university of wuerzburg
  9. References: <9208191110.AA03726@area.shpcsl.sharp.co.jp>
  10. Date: Fri, 21 Aug 1992 12:32:36 GMT
  11. Lines: 83
  12.  
  13. In article <9208191110.AA03726@area.shpcsl.sharp.co.jp>,
  14. ueda@shpcsl.sharp.co.jp (UEDA masaya) wrote:
  15. > Dear MCLers:
  16. > I got confused about simple vector.
  17. > I'm using MCL 2.0 final. I can make a simple vector of which
  18. > :element-type is 'integer and can refer it's elements by svref.
  19. > --------------------
  20. > ? (setq foo (make-array 10 :element-type 'integer :initial-element 0
  21. >                         :adjustable nil :fill-pointer nil :displaced-to nil))
  22. > #(0 0 0 0 0 0 0 0 0 0)
  23. > ? (svref foo 0)
  24. > 0
  25. > ?
  26. > --------------------
  27. > But when I make a vector of which :element-type is fixnum, referrence
  28. > by svref causes an error as follows.
  29. > --------------------
  30. > ? (setq bar (make-array 10 :element-type 'fixnum :initial-element 0
  31. >                         :adjustable nil :fill-pointer nil :displaced-to nil))
  32. > #(0 0 0 0 0 0 0 0 0 0)
  33. > ? (svref bar 0)
  34. > > Error: value #<VECTOR 10 type (SIGNED-BYTE 32), simple> is not of the expected type SIMPLE-VECTOR.
  35. > > While executing: CCL::TOPLEVEL-EVAL
  36. > > Type Command-. to abort.
  37. > See the RestartsI menu item for further choices.
  38. > 1 > 
  39. > Aborted
  40. > ?
  41. > --------------------
  42. > Why make-array returns simple vector when :element-type is 'integer
  43. > and dose not return simple vector when :element-type is 'fixnum? I
  44. > feel it queer because fixnum is a subtype of integer, but Sun4 Allegro
  45. > Common Lisp causes same error...
  46. > And MCL says me that bar is array and vector and simple-array, but not
  47. > simple-vecotor.
  48. > --------------------
  49. > ? (typep bar 'array)
  50. > T
  51. > ? (typep bar 'vector)
  52. > T
  53. > ? (typep bar 'simple-array)
  54. > T
  55. > ? (typep bar 'simple-vector)
  56. > NIL
  57. > ?
  58. > --------------------
  59. > I referred CLtL2 but I can not understand these results well. Any
  60. > suggestions are welcome.
  61. > --- Thanks ---
  62. > Masaya UEDA
  63. > Information System R&D Center, SHARP Co.
  64. > 2613-1 Ichinomoto, Tenri, Nara 632, JAPAN
  65.  
  66. I am also quite surprised by the array construction routines
  67.  
  68. For example
  69.  
  70.  
  71. (time
  72.  (type-of (make-array 200 :element-type '(unsigned-byte *))))
  73. --> (SIMPLE-VECTOR 200), 1320 bytes of memory allocated
  74.  
  75. and 
  76.  
  77. (time
  78.  (type-of (make-array 200 :element-type '(unsigned-byte 8))))
  79.  
  80. (TYPE-OF (MAKE-ARRAY 200 :ELEMENT-TYPE '(UNSIGNED-BYTE 8)))
  81.  
  82. --> (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (200)); 240 bytes of memory allocated
  83.  
  84. Karsten Poeck
  85.