Re: Object or <T> parameters

[email protected] Mon, 23 Feb 2004 18:51:12 -0600
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Shouldn't the type system ensure that the following example doesn't compile:

void my_println(Object o) {
	println(o);
}

void main(String [] args) {
	let a = () => "hello";
	my_println(a);
}

It seems like we are much more likely to want to have written:

void main(String [] args) {
	let a = () => "hello";
	my_println(a());
}

In particular, I think that arrow types should not be considered subtypes of
Object. Then, we have:
     void soSomething(Object);      // no functional values as parameters
     <Object T> void doSomething(); // same as above
     <Any T> void doSomething(T);   // also allows functional vlaues.

In other words, Object <: Any, T -> T <: Any, but not T -> T <: Object.

If you try to compile a function like:
    <Object T> void doSomething() { }
The compiler reports:
    Object is not a class
This is strange because "Any" is not a class either but it is allowed. Isn't
"Any" the same kind of thing "Object" is?

By the way, this example is a modification of the example posted by Isaac in the
Dev/BlockCallSyntax wiki entry.

- Brian




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click