[DGD]Type checking.

John West McKenna john at ucc.gu.uwa.edu.au
Tue Apr 11 12:02:15 CEST 2000


I've just spent a few minutes most perplexed by an interesting quirk in
DGD's typechecking.  The driver will complain about type mismatches as
early as it can, but it seems to be rather slack - errors that I thought
would be raised at compile-time can be raised at run-time (thinking about
it, maybe that's deliberate - the return value of a function can be nil,
and it's quite legal to assign that to any type of variable, so the
compiler can't know that it's an error).

But that's not all.

string *foo;

void bar(string frog) {
  /* do something with frog */
}

void create() {
  foo=({ this_user() });
  bar(foo);
}

Does not give a run-time error when you assign ({ this_user() }) to foo.
The error comes when you try to call bar().

It seems that checking the type of every element of an array is too hard -
the driver just says "I want an array, and yep, that's an array".

So just be warned - if it complains that it wants a string, don't sit there
shouting at it "BUT IT IS A STRING YOU STUPID MACHINE!  SEE THE VARIABLE
DECLARATION?  STRING!!!".  It might not be a string.

(Dworkin: this isn't a complaint.  After a little thought, I think I
understand why things are done the way they are.  I just thought I'd warn
others of this little gotcha)

John West
who is very happy with the shiny new 1.1.75 networking package.

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list