SJS wrote:
> begin  quoting David Brown as of Sun, Jan 06, 2008 at 05:29:12PM -0800:
>   
>> C# is kind of enough to consider use before initialization to be a static
>> compilation error.  Most other languages just consider it a warning.
>>     
>
> Well, C# is just a Java ripoff. That's nothing new.
>   
I hate it when people say this. C# is a language in its own right, and
distinct in lots of interesting ways. Java might well have a lot to do
with the motivations for creating the language, but it is important and
useful to evaluate each language in its own right.

Of course... Java *does* detect use before initialization at compile
time, where possible. ;-)
>> I still think something like:
>>
>>   auto foo = new LongArduousType(...);
>>
>> is much cleaner.
>>     
>
> It's cleaner than never declaring foo at all, just using it. I'll go
> with that.  And it *seems* like it would be cleaner than always having
> to declare a type even for something where you Just Don't Care.
>
> But it also seems to open the door for auto-return-types.
>
> auto foo( auto input ) {
>    auto bar = processInput( input );
>    ...
>    return bar;
> }
>   
That certainly wouldn't work in C++ 0x.
If it did though, it wouldn't be *too* bad a thing, until you looked at
the declaration for "foo":

auto foo(auto input);

That makes no sense whatsoever. Typically in C++ you can use some
standard template idioms to accomplish much the same thing though:

template <typename T>
typename tr1::result_of<processInput(T)>::type foo(T input);

Which roughly translates to: "the return type of foo(T) is whatever the
return type of processInput(T) is".
> At the moment, I'm actually wondering about heading in the other
> direction.  What if objects _have_ a type, but do not _define_ a type?
> What if, to define an type, you had to define an interface, and
> variables (and parameters, and return-types) could _only_ be
> interefaces?
>   
I've seen people hack on things like this to Smalltalk, and Objective-C
kind of has stuff like this. In practice it does produce some extra
typing (you basically have a type system and then behavior binding to it
which is entirely orthogonal, and you have a lot of simple cases where
the distinction creates redundant definitions).  In the end, I found it
not as nice as I'd thought it would be.

--Chris

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to