Version française
Home     About     Download     Resources     Contact us    
Browse thread
Arg-module: Float-Args also accept integer values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Arg-module: Float-Args also accept integer values
On Tue, Aug 08, 2006 at 08:25:42PM -0700, Jonathan Roewen wrote:
> > ===========================================
> > first:~ oliver$ ocaml
> >         Objective Caml version 3.09.2
> > 
> > # let floatingpoint_id (x:float) = x;;
> > val floatingpoint_id : float -> float = <fun>
> > # floatingpoint_id 42;;
> > This expression has type int but is here used with type float
> > # 
> > ===========================================
> 
> float_of_string doesn't use the ocaml type system ;-) Don't know about 
> impl details, but it's basically like atof (or whatever it's called) in 
> standard C libs. The two are completely separate.

I don't care about the implementation-details here,
and both ways of converting would make sense, IMHO.
But I want to have clear why this atof-like way was choosen.
So, it's a  design-decision-question (and one that could
reference to a bug, if the OCaml's type-system way was,
what initially was intended, but not implemented (for some reason).


To use the notation of OCaml's type system also for the connection with
the outer world could be one first step to have a more consistent way
of type system.

The same situation arises with database interfaces. If one uses the typical
way of connecting to databayses (e.g. sending SQL-statements of any possible
SQL (if syntactically correct)) this means that the type system breaks at
the boundary from in- to outside of the program.

IMHO it could make sense to have a limited set of SQL-statements, but that
they provide a consistent way of OCaml's types to the outer world.

And this could also be done when interfacing via command line interface.


Ciao,
   Oliver