[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Typing and semantics [dynamic vs. static typing]

On 2003-12-18T08:46:30-0500, John Clements wrote:
> >>No one seems to be refuting the point that a difference between ML and
> >>Haskell is the inability to formulate a reduction semantics that
> >>ignores the type proof.
> >Right.  C++ is similar to Haskell in this regard.
> I'm sorry, I don't see that.  Can you give me that example again?  In 
> fact, I don't see how this can arise without type inference.

My earlier example was:

    struct A { A() { cout << "Constructing A" << endl; }
    struct B { B() { cout << "Constructing B" << endl; }
    int main() { A x; }

C++ does have a little bit of compile-time type inference, in the form
of overloading resolution (and partial template specialization) (but I
am not including virtual method dispatch).

> The step that confuses me is where (in Haskell) I have to make a
> control-flow decision based on type information associated with code
> that hasn't yet been executed.

If it's the "code that hasn't yet been executed part" that alarms you,
then C++ alarms you too:

    int f(char()) { return 1; }
    int f(bool()) { return 2; }

Though Haskell type classes have coherence guarantees that C++ lacks.

Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Remember 9/11 * "It's untidy. And freedom's untidy. And free people are free 
to make mistakes and commit crimes and do bad things." -- Donald Rumsfeld
China has listed the organization behind http://www.uygur.org/ as terrorist.

Attachment: signature.asc
Description: Digital signature