Daml Primitive
- Brian_WeirOP
Hi Team,
I curious to understand what happens under the hood when Daml executes such statements involving
primitivefrom the GHC, such as :import GHC.Types (primitive) explode : Text -> [Text] explode = primitive @"BEExplodeText"Also, is there a performance impact or benefit of calling such lower level primitive functions ?
Thanks in advance!
Brian - Stephen 1
In our implementation of the Daml-LF runtime, for example,
BEExplodeTextlands here.Executing hand-written Scala code is faster than evaluating Daml-LF expressions. However, this style of primitive implementation essentially places a barrier that prevents tail-call optimization across that barrier, making primitives poor candidates for higher-order functions, though we have permitted some exceptions as a compromise, each requiring some complicated special-casing in the interpreter in order to avoid this problem.
If you mean “is there a performance benefit to using
primitivedirectly instead of invoking thisexplodefunction”, no, there isn’t.