Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: cheesy hack...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 2821 of 2841
Post > Topic >>

Re: cheesy hack to get first class polymorphism?

by Jon Harrop <jon@[EMAIL PROTECTED] > Apr 28, 2008 at 02:43 PM

raould wrote:
> Not that you need such a hack since there seems to have been a slew of
> folks coming up with extentions to HM that play nice. But I was
> wondering if one could approximate
> 
> /* horrible pseudocode */
> id x = x : 'a -> 'a.
> foo i:int s:string = Pair(id i, id s) : int -> string ->
> Pair(int,string).
> 
> in regular old non-System-F supporting HM systems by generating (sorta
> like C++ template expansion) a new version of id for every type it is
> applied to in foo. Sort of a macro expansion.

Yes. F#'s structurally-typed "inline" functions do exactly this. These
functions are stored as CIL metadata and instantiated by the F# compiler
when used before being type-specialized at JIT compile time by the CLR.

-- 
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u




 5 Posts in Topic:
cheesy hack to get first class polymorphism?
raould <raould@[EMAIL   2008-04-24 16:24:01 
Re: cheesy hack to get first class polymorphism?
Paul Rubin <http://phr  2008-04-24 19:06:13 
Re: cheesy hack to get first class polymorphism?
torbenm@[EMAIL PROTECTED]  2008-04-25 09:27:37 
Re: cheesy hack to get first class polymorphism?
Jon Harrop <jon@[EMAIL  2008-04-28 14:43:27 
Re: cheesy hack to get first class polymorphism?
Jon Harrop <jon@[EMAIL  2008-04-28 14:43:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 20:42:58 CDT 2008.