Re: weirdness

From: Erik Ostrom <>
Date: Sun, 12 Feb 95 15:23:11 -0500

> I am having a little trouble with some class names in STklos that I'd
> like to resolve. It is probably just a lack of comprehension on my
> part. I've got a list of class names, bound to a scheme variable
> leaf-classes.
> STk> (display leaf-classes)
> (<transmission-line> <primary-distribution-line> ... <spot>)#[undefined]

This is exactly right: What you have here is a list of class _names_,
in the form of symbols. What you _want_ is a list of _classes_.

When you evaluate this, the argument is a variable which is evaluated
to a class:
> STk> (class-name <transmission-line>)
> <transmission-line>

... and it returns a symbol.

When you evaluate this, the argument is a symbol:
> STk> (class-name (car leaf-classes))

And it doesn't make sense to ask for the class-name of a symbol in STklos.
It's as if you'd done (class-name '<transmission-line>).

The right way to solve this is probably in the construction of your
leaf-classes. I don't know how you're doing it now, but for example,
instead of

  (define leaf-classes '(<class1> <class2> <class3>))

you would use

  (define leaf-classes (list <class1> <class2> <class3>))

. The second form creates a list of the various class objects pointed to
by the variables named <class1>, <class2>, and <class3>; the first
form basically gives you a list of symbols.

As sort of an aside, I talked once to a guy at Xerox PARC who had taught
a Scheme class at a nearby college; he said that the hardest thing for
the students to get a grasp on was `quote'. I think the common confusion
of symbols with the variables they name is closely linked to this, and
it's one of my least favorite things about Scheme.
Received on Tue Feb 14 1995 - 20:02:19 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST