begin  quoting David Brown as of Sun, Jan 06, 2008 at 02:57:27PM -0800:
> On Sun, Jan 06, 2008 at 02:32:45PM -0800, Chuck Esterbrook wrote:
[snip]
> >I agree. Cobra does not do Hindley-Milner type-inference. It's
> >type-inference is a shortcut for declarations, as you pointed out. Its
> >support for dynamic binding enables it to act like Python or Smalltalk
> >where variables and expressions do not have compile-time types.
> 
> I don't mean to be disparaging.  Declaration inference is immensely useful.
> Having to declare types of every variable and argument is a lot of what
> makes most static-type programming so tedious.
> 
>    LongArduousType foo = new LongArduousType(..);
> 
> I think distracts from readability.

Hm. If I were typing with one hand, say, I think that would be tedious.
Otherwise, I'd be wondering why LongArduousType was considered a good
name.  Long, arduous names are typically a sign, to me, that I haven't
thought about the name or the class/type very much.

That's not to say that I haven't seen LongArduousType-style classes
(XMLBuilderFactory comes to mind as a recent WTF?) elsewhere. It
happens.

Then again, putting all the variable declarations at the top of the
method/function gives you much of what you want.

function name( args ... ) {
   LongArduousType foo; 
     . . .
   foo = new LongArduousType(...);
     . . .
}

Granted, if you're averaging three to six lines per function/method,
then you're growing the line count for no good reason.

Also, I've been told that a distressingly large amount of ADA code is
handling the types properly.

>                                      It's much better to only declare the
> type there when it is going to be different.

Hm?

/me ponders

I'm guessing you mean that

Foo foo = new Foo();

is redundant, you want to write

foo = new Foo();

But if you want to use Bar, which happens to extend Foo, then

foo = new Bar();

would make foo of type Bar, so then you might be inclined to write

Foo foo = new Bar();

Yes? No? Sorta-kinda?

-- 
Language that have type magic and Oh Oh Pee
Are like a combination lock, and a key.
Stewart Stremler

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

Reply via email to