[Nickle]crashing nickle in <100 bytes

Carl Worth nickle@nickle.org
Wed, 24 Jul 2002 01:52:26 +0000


On Jul 23, Keith Packard wrote:
 > Around 18 o'clock on Jul 23, Carl Worth wrote:
 > 	typedef list;
 > 	typedef struct {
 > 	    list next;
 > 	} list;
 > 
 > For the programmers convenience, nickle automatically creates structures 
 > and unions when they aren't initialized explicitly.  This automatic 
 > initialization wasn't checking for recursive structures.

Thanks. I take it this hasn't been committed yet though, right?

With this change, will it actually be possible to implement list
structures without using pointer datatypes, (as in the definition
above)?  That might be quite nice, although then we'll definitely need
a new nil literal for terminating lists, (assigning 0 to a structured
value object current fails).

Hmm... with a new nil type, I wonder if it wouldn't make sense to
change what happens when objects are declared without
initializers. For example, currently primitive datatypes and
structured values behave slightly differently:

This is legal:

	> typedef struct {int val} sv;
	> sv s;
	> sv t = s
	val = <uninit>

While this causes an exception:

	> int i;
	> int j = i
	Unhandled exception "uninitialized_value"
        "Uninitialized value"

Oh, and allowing "sv t = s;" seems odd in light of the fact that
"sv t; t.val = s.val" causes an exception.

I do understand the current semantics, (now that Keith explained the
convenience creation of structures), but I'm wondering if another
approach might be more consistent. Perhaps all uninitialized data
could receive a value of nil? (The only difference would be that this
is a value that could appear as a literal for use in comparisons,
etc.)

Then, maybe the assignment operator would not raise an
"uninitialized_value" exception on nil values? (Other operators could
still raise the exception).

Maybe it would even make sense to eliminate the convenience creation
of structures and instead just initialize them to nil? (Especially
since the programmer can get the empty structure by simply adding an
empty initializer, "= {};")

But I don't have strong feelings or compelling reasons for much of
that if it is difficult or causes other complications.

One thing that I would like is if I could assign a structured value
without explicitly providing its type, (in the same style as the
initializer), such as:

	sv s;
	s = {val = 3};

rather than:

	sv s;
	s = (sv) {val = 3};

But I can understand why that might not be possible.

-Carl

-- 
Carl Worth                                        
USC Information Sciences Institute                 cworth@east.isi.edu
3811 N. Fairfax Dr. #200, Arlington VA 22203		  703-812-3725