Jump to content

  • Log In with Google      Sign In   
  • Create Account


RivieraKid

Member Since 27 Feb 2007
Offline Last Active Jul 19 2014 03:40 AM
-----

#5133501 F# to C++ Translator, feedback requested

Posted by RivieraKid on 22 February 2014 - 06:03 AM

Hello all,

 

I am in the process of making a library to convert F# to C++.

Here is an example:

[<ReflectedDefinition>] 
module Functions =

    //must declare delegate with same name as let bound function
    type Add = delegate of int * int -> int      
    let Add(a,b) = a + b

open Functions
module Host =
    let main() =
        //get function pointer to exported C++ function
        let m = FunctionPointer<Add>
        Assert.AreEqual(m.Invoke(1,2),Add(1,2))

As you can see it is quite straight forward to use.

 

So how does this work?

F# allows you to read the definition of a function / member at runtime so in the above example it reads an AST of the form "let Add(a,b) = a + b".

Within the FunctionPointer definition that AST is transformed into a C++ AST and  then outputs the code into a template project, runs MSBuild, copies the dll to the program folder, dynamically loads the dll and gets the exported function.

 

I can then call this function directly from F#.

I am not finished.

 

Why am I doing this?

1. It is fun.

2. Maybe it will be useful.

 

Does anyone here think this is useful?

If so what would you use it for?

What functionality would make it more useful for you?

 

Thank you for your time.

Kind Regards

James




#4874009 Beautiful code

Posted by RivieraKid on 18 October 2011 - 01:11 PM

code that looks like the problem being solved is beautiful because anyone can understand it and its easy to maintain.

Layers of abstraction for abstractions sake are the devil.


#4841698 What's the largest number you can come up with?

Posted by RivieraKid on 28 July 2011 - 10:45 AM

a bazzilion gillion zillion


#4833772 Should I choose hardware engineer or software engineer or programmer as my ca...

Posted by RivieraKid on 11 July 2011 - 09:31 AM

bound to be places where you can do all 3.


#4815200 What do you guys do at work, when not working?

Posted by RivieraKid on 24 May 2011 - 11:15 AM

you should never have free time. Always ask for more work if your done. First be sure you are super done and all the cuffs are ironed out. Sometimes its a good idea to let your boss know when your nearly done so he can prepare good work for you to do.

if they are disorganized enough so that they can't give you any work you want to be doing something which will make you better at your tasks. What is your process like? Is there anything you could do that would make life easier for you or your colleagues?


#4813812 How Gamestop Reduces Developers' Sales

Posted by RivieraKid on 21 May 2011 - 05:06 AM

sounds worse than piracy!

in the UK you dont get much for returning games and the preowned section generally isnt much cheaper. Exactly how many sales are they loosing?


To be fair, if the game is worth returning then it wasnt worth $50 to begin with so it kind of balances out.




#4800465 Fastest way to get started in the Computer Science field with only a High Sch...

Posted by RivieraKid on 19 April 2011 - 01:10 PM

And once you have a degree and have had a job or two, I think experience overshadows the degree


Man it's easier for you to say that when you already have a degree. I am currently going back for a bachelors in comp sci but I had an associates + work examples and still got turned down for jobs that required bachelors degrees. So I know you are full of crap. Convo's probably went like this:

HR: Sir you are not qualified.
Me: Maam, believe me I KNOW this field. I live it and breate it.
HR: Sorry sir, you need a bachelors for this position.
Me: blah blah - check out this work - blah blah - comparable to any bachelors candidate you will find -blah blah
HR: Sir, I need to end this call


use linkedIn.
get talking to recruiters with the inside ear. Recruiters tend to have some technical knowledge so they can get the right people.
starting blogging about stuff you know


#4785728 is John Carmack's opinion still as "relevant" in the industry?

Posted by RivieraKid on 14 March 2011 - 02:05 PM

super inteliigent mathmatician he may be but i wouldnt ask him to work with a team of web developers. His code is a total mess. EPIC wrote clean modular slower maintainable code.

if he didn't spearhead his own company with his enthusiasm he would have been that guy who just hacks shit together which nobody else can understand. 6 months down the line the code breaks because carmack got another job.

he is still awesome though.


#4783333 You Know What I Wish?

Posted by RivieraKid on 08 March 2011 - 05:43 PM

i also think this is not funny but at least hes confident and doesnt pause looking like a tool.
the material is really bad.


#4774277 Duke Nukem Fornever

Posted by RivieraKid on 14 February 2011 - 04:56 PM

who gives a crap what one subjective reviewer thinks?

he doesnt break the gameplay down or give any real reason as to WHY it sucks. He just says "I dont like it" many times in different ways. Perhaps hes just a miserable sod. Could be that being negetive gets him more hits ffs.


#4762134 Proof God doesn't exist?

Posted by RivieraKid on 20 January 2011 - 06:10 PM

remember you dont have to be a christian to beleive in god.


PARTNERS