[question]types

Richard A. O'Keefe ok at atlas.otago.ac.nz
Wed Jun 21 00:08:13 UTC 2000


Karl Ramberg <karl.ramberg at chello.se>
suggests initialising variables with a polymorphic nil that
behaves like false, 0, '', or an empty collection or whatever
depending on what you do to it.  He claims that

    from a beginner's perspective it makes sense.
	
No, it is precisely beginners who would be most harmed by this.
In languages like Pascal, C, and Ada, once beginners manage to
get their code through the compiler, the top two errors are
    - uninitialised variable (including unallocated pointer)
    - subscript off-by-one (including loop bound)
This kind of change would *conceal* uninitialised variable errors,
but it would not *correct* them.  It would just turn *un*initialised
variables into *wrongly* initialised variables, which would be even
harder for beginners to find and fix.

If anyone has any experience teaching beginners to use Lisp, Scheme,
or Smalltalk that's relevant to the interpretation of uninitialised
variables, it would be kind to share it.  For what I've seen of teaching
Lisp or Scheme to 3rd- and 4th-year students, they have much the same
trouble with uninitialised variables that beginners do with Pascal or C.

It's not like me to say a good word about Java, but in my view one
of the things Java got *right* that makes it attractive as a beginner's
language (possibly the only thing) is that the compiler works quite hard
to detect uninitialised variables.

Noting that Squeak 2.7 defines Number +, Point +, String +, and Collection +
I have to say that (polymorphic nil) + (something) would have a hard time
figuring out what to pretend to be.





More information about the Squeak-dev mailing list