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

Re: dynamic vs. static typing



On 2003-11-24T08:53:56-0800, Steve Dekorte wrote:
> Yes, and the only union may be introspection methods. In which case we 
> might be able to validly send any method that the introspection API 
> reveals to us, even though our type system (which restricted us to the 
> introspection methods) wouldn't allow it.

Maybe -your- type system wouldn't allow it, but mine does:

    import Char (ord)

    data Union = A Char | B Int

    unionToInt :: Union -> Int
    unionToInt (A c) = ord c
    unionToInt (B i) = i

Here I send the "ord" message, which only characters respond to, to a
value that introspection reveals at runtime is a character rather than
an integer.  This has already been explained on this thread at

    Message-ID: <20031120022752.GB14598@proper.eecs.harvard.edu>

See also dynamic_cast in C++.

	Ken

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Sexy types in action: http://www.eecs.harvard.edu/~ccshan/cs252/usage.pdf
new journal Physical Biology: http://sansom.biop.ox.ac.uk/images/physbio.gif
What if All Chemists Went on Strike? (science fiction):
http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html

Attachment: signature.asc
Description: Digital signature