<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=SV link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Yes, all subterms of a compound term must belong to the same env as the top term.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>/Sverker<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='margin-left:65.2pt'><b><span lang=EN-US>From:</span></b><span lang=EN-US> Harris, Robert <robert.harris@alertlogic.com> <br><b>Sent:</b> den 23 februari 2021 19:14<br><b>To:</b> Sverker Eriksson <sverker.eriksson@ericsson.com><br><b>Cc:</b> erlang-questions@erlang.org Questions <erlang-questions@erlang.org><br><b>Subject:</b> Re: Different environments in NIF API calls<o:p></o:p></span></p></div></div><p class=MsoNormal style='margin-left:65.2pt'><o:p> </o:p></p><p class=MsoNormal style='mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:65.2pt'>Thank you for the reply.<br><br>Is it fair to assume that the value populated by enif_get_map_value()<br>will belong to the env of the map?<br><br>Regards,<br><br>Robert<br><br>> On 23 Feb 2021, at 17:56, Sverker Eriksson <<a href="mailto:sverker.eriksson@ericsson.com">sverker.eriksson@ericsson.com</a>> wrote:<br>><br>> The ‘env’ argument of functions that only read supplied terms (like enif_get_* functions) is not used in current implementation. And as we have introduced functions like enif_compare that lacks ‘env’ arguments, it is now impossible to do an implementation of the API where ERL_NIF_TERM’s are not self contained.<br>><br>> So, yes you can use enif_get_map_value with map and key argument from different environment. The same goes for enif_compare and all other functions with term arguments that are only read and not referred by new constructed terms.<br>><br>> /Sverker<br>><br>><br>> From: erlang-questions <<a href="mailto:erlang-questions-bounces@erlang.org">erlang-questions-bounces@erlang.org</a>> On Behalf Of Harris, Robert<br>> Sent: den 23 februari 2021 13:21<br>> To: <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a> Questions <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>> Subject: Different environments in NIF API calls<br>><br>> Hello,<br>><br>> I'm trying to understand the full implications of<br>><br>> "All API functions that read or write terms has the environment<br>> that the term belongs to as the first function argument."<br>><br>> For example, can enif_get_map_value() be called with a map from<br>> a process-bound environment and a key from a process-independent<br>> one? If so, which environment would be used?<br>><br>> Similarly, does enif_compare require that its arguments share<br>> the same environment?<br>><br>> Regards,<br>><br>> Robert<br>><br>> Confidentiality Notice | This email and any included attachments may be privileged, confidential and/or otherwise protected from disclosure. Access to this email by anyone other than the intended recipient is unauthorized. If you believe you have received this email in error, please contact the sender immediately and delete all copies. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.<br>><br>><br>> Disclaimer<br>><br>> The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.<br>><br>> This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.<br>><br><br>Confidentiality Notice | This email and any included attachments may be privileged, confidential and/or otherwise protected from disclosure. Access to this email by anyone other than the intended recipient is unauthorized. If you believe you have received this email in error, please contact the sender immediately and delete all copies. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.<br><br><o:p></o:p></p><p style='margin-left:65.2pt'><b><span style='font-size:10.0pt;font-family:"Verdana",sans-serif;color:#666666'>Disclaimer</span></b><span style='font-size:10.0pt;font-family:"Verdana",sans-serif;color:#666666'><o:p></o:p></span></p><p style='margin-left:65.2pt'><span style='font-size:8.0pt;font-family:"Verdana",sans-serif;color:#666666'>The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.<br><br>This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.<o:p></o:p></span></p></div></body></html>