RE: Dichotomy between functions and type constructors?

From: Don Syme (dsyme@microsoft.com)
Date: Mon Feb 21 2000 - 19:02:54 MET

  • Next message: Manuel Fahndrich: "RE: Still strange GC problems with OCaml and C: OCaml 2.04 bug?"

    I believe it's got something to do with cross module optimization. However,
    I've always wondered why the restriction is not lifted at least inside the
    module where the constructor is declared.

    Cheers,
    Don

    -----Original Message-----
    From: David McClain [mailto:dmcclain@azstarnet.com]
    Sent: 21 February 2000 17:09
    To: caml-redistribution@pauillac.inria.fr
    Subject: Dichotomy between functions and type constructors?

    I am curious about the apparent dichotomy between normal functions and type
    constructors, and why this disparity exists?

    Say I have a type

    type thing =
       T1 of int * float
    | ....

    I can create such a type as T1(5, 3.14) but I cannot create such a type on a
    tuple result of a function call:

    let doit x = (x, float_of_int x)

    let myT1 = T1(doit x)

    This gives rise to a type checking error wherein the constructor T1 demands
    two arguments, instead of demanding a tuple of two elements.

    SML does not appear to impose this same requirement on the programmer, so
    what is the origin of the OCaml requirement?

    TIA,

    David McClain, Sr. Scientist
    Raytheon Systems Co.
    Tucson, AZ



    This archive was generated by hypermail 2b29 : Mon Feb 21 2000 - 19:05:35 MET