Array element type: CLISP / SBCL

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.

Array element type: CLISP / SBCL

Postby redrise » Sat Nov 10, 2012 9:46 am

Hi all,
glad to be a fresh new member of this forum. I'm pretty sure to spend a lot of time reading it!

here is my question:
I'm trying to understand differences between array in CLISP and SBCL.
It appears that the following 2 lines work well in CLISP but raise type-error in SBCL (SBCL doesn't allow to replace a matrix element by an expression, nor a integer, etc...)

(setq x (make-array '(10 3) :element-type 'double-float) )
(setf (aref x 0 0) 'foo)


Is really CLISP so user-friendly?
It seems to be a real difference, leading to (i guess) significative performance difference too!
redrise
 
Posts: 1
Joined: Sat Nov 10, 2012 9:30 am

Re: Array element type: CLISP / SBCL

Postby Paul » Sat Nov 10, 2012 8:21 pm

What you really mean is that it doesn't work in CLISP -- you've asked that the array only be able to hold double-floats, and then tried to put a symbol into it. Since a symbol is not a double-float, this should be an error. But no Lisp can have specialized arrays for every possible type, so you can usually put something more into the array than you asked for. E.g., if you make an array with :element-type '(integer 8 42) you're asking it to only accept integers between 8 and 42, but for sure it'll be able to store more than that. Obviously in CLISP an array of type double-float is equivalent to an array of type T (i.e., you can store anything at all in it...such as symbols).
Paul
 
Posts: 106
Joined: Tue Jun 02, 2009 6:00 am


Return to Homework

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest