caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Why + vs +. but "fake" parametric polymorphism for <
@ 2006-10-12  5:19 Carlos Pita
  2006-10-12  5:41 ` [Caml-list] " Carlos Pita
  0 siblings, 1 reply; 18+ messages in thread
From: Carlos Pita @ 2006-10-12  5:19 UTC (permalink / raw)
  To: caml-list

Hi all!

I would like to implement some number crunching inner loops for dsp
stuff with ocaml. I'm a newcomer to the language with strong
scheme/python background and trying to come into terms with type
inference, parametric polymorphism and structural subtyping. One thing
than I'm pretty fond of is the difference between floating point and
integer basic mathematical operators. I guess the compiler is able to
generate specific and more efficient code for each case without further
analysis. But then I found out that comparison operators offer some kind
of adhoc polymorphism in the guise of parametric one:

# (<);;
- : 'a -> 'a -> bool = <fun>

Is there any reason for this apparently inconsistent design? Would the
generality of < be against performance if for example, say, my critical
inner loops check against a top limit value thousands of times per
second? I'm afraid that the implementation of such a generic operator,
which is so different for numerical integer comparison than v.gr for
string lexicographical comparison, would incur into some run time
overhead. But, as I've said at the beginning, I'm just a newbie and most
probably there is a coherent explanation for all this confusion.

Thank you in advance.
Best regards,
Carlos




	
	
		
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Why + vs +. but "fake" parametric polymorphism for <
@ 2006-10-12  5:18 Carlos Pita
  2006-10-12  5:45 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 18+ messages in thread
From: Carlos Pita @ 2006-10-12  5:18 UTC (permalink / raw)
  To: caml-list

Hi all!

I would like to implement some number crunching inner loops for dsp
stuff with ocaml. I'm a newcomer to the language with strong
scheme/python background and trying to come into terms with type
inference, parametric polymorphism and structural subtyping. One thing
than I'm pretty fond of is the difference between floating point and
integer basic mathematical operators. I guess the compiler is able to
generate specific and more efficient code for each case without further
analysis. But then I found out that comparison operators offer some kind
of adhoc polymorphism in the guise of parametric one:

# (<);;
- : 'a -> 'a -> bool = <fun>

Is there any reason for this apparently inconsistent design? Would the
generality of < be against performance if for example, say, my critical
inner loops check against a top limit value thousands of times per
second? I'm afraid that the implementation of such a generic operator,
which is so different for numerical integer comparison than v.gr for
string lexicographical comparison, would incur into some run time
overhead. But, as I've said at the beginning, I'm just a newbie and most
probably there is a coherent explanation for all this confusion.

Thank you in advance.
Best regards,
Carlos



	
	
		
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2006-10-13 14:16 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-12  5:19 Why + vs +. but "fake" parametric polymorphism for < Carlos Pita
2006-10-12  5:41 ` [Caml-list] " Carlos Pita
2006-10-12  5:49   ` Basile STARYNKEVITCH
2006-10-12  5:53   ` Jonathan Roewen
2006-10-12  6:10     ` Carlos Pita
  -- strict thread matches above, loose matches on Subject: below --
2006-10-12  5:18 Carlos Pita
2006-10-12  5:45 ` [Caml-list] " Jacques Garrigue
2006-10-12  5:58   ` Carlos Pita
2006-10-12  6:08     ` Jonathan Roewen
     [not found]       ` <452DF46C.802@fmf.uni-lj.si>
2006-10-12 14:26         ` Carlos Pita
2006-10-13 11:56       ` Diego Olivier FERNANDEZ PONS
2006-10-13 12:14         ` Gerd Stolpmann
2006-10-13 12:46           ` Diego Olivier FERNANDEZ PONS
2006-10-13 13:01             ` Luc Maranget
2006-10-13 13:15               ` Diego Olivier FERNANDEZ PONS
2006-10-13 13:15               ` skaller
2006-10-13 13:36                 ` Luc Maranget
2006-10-13 13:53             ` Gerd Stolpmann
2006-10-13 14:16               ` Luc Maranget

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).