[DGD] Shouldn't this be a type error?

Felix A. Croes felix at dworkin.nl
Mon Feb 2 17:08:09 CET 2004


Noah Gibbs <noah_gibbs at yahoo.com> wrote:

> I have a function in its own file.  I'm running it
> with the Kernel Library, unmodified.  I compile the
> object and run this function.  Everything works just
> fine.  My question:  shouldn't this give a type error
> when I assign the result of "allocate()" to an "int*"?
>  Shouldn't I have to use allocate_int when I'm in
> typechecking mode 2?

You should.

The problem is that DGD's typechecking is still fairly simplistic.
allocate() returns an array of nil values.  The array could be used
to hold strings, objects, and so on.  The only type there is to
represent this mixed capability is 'mixed'; you assign a value of
type mixed* to a variable of type int*.  There is no separate type
to represent "any type but int or float".

Another example of this is call_other(), which takes a string or an
object as its first argument.  The only type to represent this
combination is mixed, so again there is no typechecking at compile
time and the first argument for call_other() can be of any type
(there will be a runtime error if it isn't an object or a string).

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list