* Arg-module: Float-Args also accept integer values @ 2006-08-08 20:57 Oliver Bandel 2006-08-08 21:19 ` [Caml-list] " William D. Neumann 0 siblings, 1 reply; 9+ messages in thread From: Oliver Bandel @ 2006-08-08 20:57 UTC (permalink / raw) To: caml-list Is this a wanted behaviour? It's an implicit conversion from the integer value in the cli-string to float. Even if this is very convenient for a user, it is not completely following OCaml's philosophy (regarding types). Any idea on this?! Ciao, Oliver ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-08 20:57 Arg-module: Float-Args also accept integer values Oliver Bandel @ 2006-08-08 21:19 ` William D. Neumann 2006-08-08 21:33 ` Oliver Bandel 0 siblings, 1 reply; 9+ messages in thread From: William D. Neumann @ 2006-08-08 21:19 UTC (permalink / raw) To: Oliver Bandel; +Cc: caml-list On Tue, 8 Aug 2006, Oliver Bandel wrote: > Is this a wanted behaviour? > It's an implicit conversion from the integer value in the cli-string > to float. Even if this is very convenient for a user, it is not > completely following OCaml's philosophy (regarding types). Not really. It's the same behavior as float_of_string (because it uses float of string). # float_of_string "42";; - : float = 42. William D. Neumann --- "There's just so many extra children, we could just feed the children to these tigers. We don't need them, we're not doing anything with them. Tigers are noble and sleek; children are loud and messy." -- Neko Case Life is unfair. Kill yourself or get over it. -- Black Box Recorder ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-08 21:19 ` [Caml-list] " William D. Neumann @ 2006-08-08 21:33 ` Oliver Bandel 2006-08-08 21:40 ` Sachin Shah 0 siblings, 1 reply; 9+ messages in thread From: Oliver Bandel @ 2006-08-08 21:33 UTC (permalink / raw) To: caml-list On Tue, Aug 08, 2006 at 03:19:15PM -0600, William D. Neumann wrote: > On Tue, 8 Aug 2006, Oliver Bandel wrote: > > >Is this a wanted behaviour? > >It's an implicit conversion from the integer value in the cli-string > >to float. Even if this is very convenient for a user, it is not > >completely following OCaml's philosophy (regarding types). > > Not really. It's the same behavior as float_of_string (because it uses > float of string). > > # float_of_string "42";; > - : float = 42. > [...] Ah, ok, I see. Thanks! (But.... shouldn't throw this an eception, because it's an int, not a float?!) Ciao, Oliver ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-08 21:33 ` Oliver Bandel @ 2006-08-08 21:40 ` Sachin Shah 2006-08-08 22:12 ` Oliver Bandel 0 siblings, 1 reply; 9+ messages in thread From: Sachin Shah @ 2006-08-08 21:40 UTC (permalink / raw) To: Oliver Bandel; +Cc: caml-list On 8/8/06, Oliver Bandel <oliver@first.in-berlin.de> wrote: > On Tue, Aug 08, 2006 at 03:19:15PM -0600, William D. Neumann wrote: > > On Tue, 8 Aug 2006, Oliver Bandel wrote: > > > > >Is this a wanted behaviour? > > >It's an implicit conversion from the integer value in the cli-string > > >to float. Even if this is very convenient for a user, it is not > > >completely following OCaml's philosophy (regarding types). > > > > Not really. It's the same behavior as float_of_string (because it uses > > float of string). > > > > # float_of_string "42";; > > - : float = 42. > > > [...] > > Ah, ok, I see. > > Thanks! > > (But.... shouldn't throw this an eception, because it's > an int, not a float?!) > > Ciao, > Oliver No, because 42 is a valid int and a valid float. Since integers are a proper subset of floating-point numbers, this is the correct behavior for float_of_string. Regards, Sachin. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-08 21:40 ` Sachin Shah @ 2006-08-08 22:12 ` Oliver Bandel 2006-08-09 3:25 ` Jonathan Roewen 0 siblings, 1 reply; 9+ messages in thread From: Oliver Bandel @ 2006-08-08 22:12 UTC (permalink / raw) To: caml-list On Tue, Aug 08, 2006 at 02:40:58PM -0700, Sachin Shah wrote: > On 8/8/06, Oliver Bandel <oliver@first.in-berlin.de> wrote: > >On Tue, Aug 08, 2006 at 03:19:15PM -0600, William D. Neumann wrote: > >> On Tue, 8 Aug 2006, Oliver Bandel wrote: > >> > >> >Is this a wanted behaviour? > >> >It's an implicit conversion from the integer value in the cli-string > >> >to float. Even if this is very convenient for a user, it is not > >> >completely following OCaml's philosophy (regarding types). > >> > >> Not really. It's the same behavior as float_of_string (because it uses > >> float of string). > >> > >> # float_of_string "42";; > >> - : float = 42. > >> > >[...] > > > >Ah, ok, I see. > > > >Thanks! > > > >(But.... shouldn't throw this an eception, because it's > > an int, not a float?!) > > > >Ciao, > > Oliver > > No, because 42 is a valid int and a valid float. Since integers are a > proper subset of floating-point numbers, this is the correct behavior > for float_of_string. > [...] =========================================== 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 # =========================================== Ciao, Oliver ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-08 22:12 ` Oliver Bandel @ 2006-08-09 3:25 ` Jonathan Roewen 2006-08-09 3:30 ` Jonathan Roewen 2006-08-09 5:54 ` Oliver Bandel 0 siblings, 2 replies; 9+ messages in thread From: Jonathan Roewen @ 2006-08-09 3:25 UTC (permalink / raw) To: Oliver Bandel; +Cc: caml-list > =========================================== > 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. Jonathan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-09 3:25 ` Jonathan Roewen @ 2006-08-09 3:30 ` Jonathan Roewen 2006-08-09 5:54 ` Oliver Bandel 1 sibling, 0 replies; 9+ messages in thread From: Jonathan Roewen @ 2006-08-09 3:30 UTC (permalink / raw) To: oliver; +Cc: caml-list > > =========================================== > > 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. Oops, I should clarify: float_of_string doesn't use the ocaml lexing tools that are used in the toplevel, and the compilers themselves. That's why it parses integers. Jonathan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-09 3:25 ` Jonathan Roewen 2006-08-09 3:30 ` Jonathan Roewen @ 2006-08-09 5:54 ` Oliver Bandel 2006-08-09 6:13 ` Jonathan Roewen 1 sibling, 1 reply; 9+ messages in thread From: Oliver Bandel @ 2006-08-09 5:54 UTC (permalink / raw) To: caml-list 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Caml-list] Arg-module: Float-Args also accept integer values 2006-08-09 5:54 ` Oliver Bandel @ 2006-08-09 6:13 ` Jonathan Roewen 0 siblings, 0 replies; 9+ messages in thread From: Jonathan Roewen @ 2006-08-09 6:13 UTC (permalink / raw) To: Oliver Bandel; +Cc: caml-list > 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). Okay then. How about usability? Do you want your end-users to be picky over adding a decimal point in order to provide a floating point arg? The decimal point requirement is for the programmers, not the users; therefore, the float_of_string design is sensible. w.r.t the sql example, it is possible (cf. linq for C#, or one of those pgocaml libs which does compile time checking of sql queries). Jonathan ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-08-09 6:13 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2006-08-08 20:57 Arg-module: Float-Args also accept integer values Oliver Bandel 2006-08-08 21:19 ` [Caml-list] " William D. Neumann 2006-08-08 21:33 ` Oliver Bandel 2006-08-08 21:40 ` Sachin Shah 2006-08-08 22:12 ` Oliver Bandel 2006-08-09 3:25 ` Jonathan Roewen 2006-08-09 3:30 ` Jonathan Roewen 2006-08-09 5:54 ` Oliver Bandel 2006-08-09 6:13 ` Jonathan Roewen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox