Posts: 783
Threads: 12
Joined: Jan 2014
Thanks: 2
Given 73 thank(s) in 61 post(s)
It sounds interesting, but rather off topic. I'm just curious about what you mean by any language? Because I'm pretty sure that there are language sets that are impossible in general. For example how can Haskell call a c++ varadic template?
Posts: 254
Threads: 16
Joined: Oct 2013
Thanks: 3
Given 20 thank(s) in 18 post(s)
Without more experience with how Haskell works and is implemented, I cannot give you an answer.
Posts: 254
Threads: 16
Joined: Oct 2013
Thanks: 3
Given 20 thank(s) in 18 post(s)
06-16-2015, 04:27 AM
(This post was last modified: 06-16-2015, 04:38 AM by SamJBarney.)
I'm going to write up a little bit about how UPE works so that you can have a general idea of how it works.
Templates have been something that I have been struggling with implementing without header files, due to the fact that they only exist within the compiler itself; when you output the code, there is no template function, just copies of it for the specific types used.
Haskell doesn't need to know about templates, only the compiler has to know that it is. So, when it is compiling, it locates the function and determines that it is a template. It duplicates the code, specializes it for the type coming in, and pops that code into the file that was calling it. That, of course is in an ideal setting where the type coming in fulfills the requirements for the template.
As for C# not having return type inference, the compiler handles that all, making sure that the right function/method is used, and C# doesn't have to worry about it.
One thing that I haven't even considered yet is cross-language inheritance. I'm going to have to give that some thought.
Posts: 254
Threads: 16
Joined: Oct 2013
Thanks: 3
Given 20 thank(s) in 18 post(s)
06-16-2015, 05:00 AM
(This post was last modified: 06-16-2015, 05:01 AM by SamJBarney.)
Sorry, you're going to have to explain that line to me. I'm not familiar with Haskell syntax
I assume that is a function call where f and x are arguments to foo.
Posts: 783
Threads: 12
Joined: Jan 2014
Thanks: 2
Given 73 thank(s) in 61 post(s)
No. First it is a function call to the parameter f, with the parameter x. Then foo is called on the result.
Posts: 254
Threads: 16
Joined: Oct 2013
Thanks: 3
Given 20 thank(s) in 18 post(s)
06-16-2015, 05:08 AM
(This post was last modified: 06-16-2015, 05:10 AM by SamJBarney.)
At runtime (UPE is a JIT engine), we query UPE for function foo. Foo is defined as a template, so we generate a specialized function for the arguments requested, and pass back a reference to that function. So Haskell doesn't need to know that it is a template, it just needs to know that it is calling a function called foo.
Hmm... that does make it a bit difficult since we cannot determine what the return type of f is, unless all Haskell types have a base type.
Posts: 783
Threads: 12
Joined: Jan 2014
Thanks: 2
Given 73 thank(s) in 61 post(s)
Haskell, Prolog, Verilog and Common Lisp would make extremely good test cases for your system, as they are all extremely different from most mainstream languages.