What is Native and how is it used? #56
-
I've noticed morphir-elm now includes something called |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Very timely question. @piyush-gupta1999, our most productive contributor just told me yesterday that we should document this. I'll give a high-level description here and will add code comments as well. Functions in the Native module are called by the interpreter when it hits an SDK function. Things like adding or comparing two numbers cannot be implemented using the Morphir IR itself so we call the built-in SDK functions but we are working with Does that answer your question? |
Beta Was this translation helpful? Give feedback.
Very timely question. @piyush-gupta1999, our most productive contributor just told me yesterday that we should document this. I'll give a high-level description here and will add code comments as well.
Functions in the Native module are called by the interpreter when it hits an SDK function. Things like adding or comparing two numbers cannot be implemented using the Morphir IR itself so we call the built-in SDK functions but we are working with
Value
s in the interpreter so we have to unwrap, get the literal value out. invoke the SDK function and wrap the result back to aValue
before returning. The Native module contains types that describe the interface for native functions and also help…