<div dir="auto">Thanks a lot Micael. <div dir="auto"><br></div><div dir="auto">I will explore the "ifdef" attribute in that case, for me its a perception as of yet .</div><div dir="auto"><br></div><div dir="auto">1. Does it mean "net" module itself will be gone in future, once "socket" is official?</div><div dir="auto"><br></div><div dir="auto">2. In this particular case of type specification, the only difference is in one of the parameters of the function. I was also wondering if we could have used a union instead to write the same type spec, it would have been simpler?</div><div dir="auto">For example, </div><div dir="auto">Instead of writing a type spec like this </div><div dir="auto"><br></div><div dir="auto">-ifdef(SOME_PRAGMA_CONDITION)</div><div dir="auto">          SomeVar :: xxx_type().</div><div dir="auto">-else</div><div dir="auto">         SomeVar :: yyy_type().</div><div dir="auto"><br></div><div dir="auto">We could specify the same type spec as:</div><div dir="auto">        SomeVar :: xxx_type() | yyy_type().</div><div dir="auto"><br></div><div dir="auto">Any reason we preferred the former over the latter?</div><div dir="auto"><br></div><div dir="auto"><br><div data-smartmail="gmail_signature" dir="auto">नमस्ते।<br>नलिन रंजन</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 26, 2021, 8:25 PM Micael Karlberg <<a href="mailto:micael.karlberg@ericsson.com">micael.karlberg@ericsson.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt">Hi,</span>
<div style="font-size:12pt"><br>
</div>
<div style="font-size:12pt">It is possible to configure (and build) otp *without* socket (esock) support.</div>
<div style="font-size:12pt">That is what the ifdef'ing is about. Eventually, when socket is properly</div>
<div style="font-size:12pt">official, this will be removed.</div>
<div style="font-size:12pt"><br>
</div>
<div style="font-size:12pt">Regards,</div>
<div style="font-size:12pt">  /BMK</div>
<span style="font-size:12pt"></span><br>
</div>
<div id="m_4200584065570924148appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="m_4200584065570924148divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> erlang-questions <<a href="mailto:erlang-questions-bounces@erlang.org" target="_blank" rel="noreferrer">erlang-questions-bounces@erlang.org</a>> on behalf of Nalin Ranjan <<a href="mailto:ranjanified@gmail.com" target="_blank" rel="noreferrer">ranjanified@gmail.com</a>><br>
<b>Sent:</b> Tuesday, January 26, 2021 1:12 PM<br>
<b>To:</b> Erlang-Questions Questions <<a href="mailto:erlang-questions@erlang.org" target="_blank" rel="noreferrer">erlang-questions@erlang.org</a>><br>
<b>Subject:</b> Type Specification of net:getnameinfo()</font>
<div> </div>
</div>
<div>
<div dir="ltr"><a href="https://erlang.org/doc/man/net.html#getnameinfo-2" target="_blank" rel="noreferrer">Type</a> of net:getnameinfo() is specified in the
<a href="https://protect2.fireeye.com/v1/url?k=b7971346-e80c2a40-b79753dd-86ee86bd5107-36a745eb8cb7a80a&q=1&e=300a3de5-54c4-41b9-bbee-604bb9991333&u=https%3A%2F%2Fgithub.com%2Ferlang%2Fotp%2Fblob%2Fmaster%2Flib%2Fkernel%2Fsrc%2Fnet.erl%23L203" target="_blank" rel="noreferrer">
source file</a>, and the one prevailing in the docs is as below:-
<div><br>
</div>
<div>
<table style="border-spacing:0px;border-collapse:collapse;color:rgb(216,212,207);font-size:14px;background-color:rgb(19,21,22)">
<tbody style="box-sizing:border-box">
<tr style="box-sizing:border-box;background-color:transparent">
<td id="m_4200584065570924148x_gmail-LC220" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(255,115,105)">-</span><span style="box-sizing:border-box;color:rgb(110,192,255)">spec</span>
<span style="box-sizing:border-box;color:rgb(197,143,255)">
getnameinfo</span>(<span style="box-sizing:border-box;color:rgb(188,182,173)">SockAddr</span>,
<span style="box-sizing:border-box;color:rgb(188,182,173)">
Flags</span>) <span style="box-sizing:border-box;color:rgb(255,115,105)">
-></span> {<span style="box-sizing:border-box;color:rgb(110,192,255)">ok</span>,
<span style="box-sizing:border-box;color:rgb(188,182,173)">
Info</span>} | {<span style="box-sizing:border-box;color:rgb(110,192,255)">error</span>,
<span style="box-sizing:border-box;color:rgb(188,182,173)">
Reason</span>} <span style="box-sizing:border-box;color:rgb(255,115,105)">
when</span></td>
</tr>
<tr style="box-sizing:border-box">
<td id="m_4200584065570924148x_gmail-L221" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC221" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">SockAddr</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
term</span>(),</td>
</tr>
<tr style="box-sizing:border-box;background-color:transparent">
<td id="m_4200584065570924148x_gmail-L222" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC222" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">Flags</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
name_info_flags</span>() | <span style="box-sizing:border-box;color:rgb(110,192,255)">
undefined</span>,</td>
</tr>
<tr style="box-sizing:border-box">
<td id="m_4200584065570924148x_gmail-L223" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC223" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">Info</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
name_info</span>(),</td>
</tr>
<tr style="box-sizing:border-box;background-color:transparent">
<td id="m_4200584065570924148x_gmail-L224" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC224" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">Reason</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
term</span>().</td>
</tr>
</tbody>
</table>
</div>
<div><br>
</div>
<div>Currently, the type is <span style="box-sizing:border-box;color:rgb(188,182,173);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">SockAddr</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">
</span><span style="box-sizing:border-box;color:rgb(255,115,105);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">::</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">
</span><span style="box-sizing:border-box;color:rgb(197,143,255);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">term</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">(),
 and could have been </span><span style="box-sizing:border-box;color:rgb(188,182,173);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">SockAddr</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">
</span><span style="box-sizing:border-box;color:rgb(255,115,105);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">::</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">
</span><span style="box-sizing:border-box;color:rgb(197,143,255);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">socket</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">:</span><span style="box-sizing:border-box;color:rgb(197,143,255);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">sockaddr</span><span style="color:rgb(216,212,207);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(19,21,22)">().</span><br>
</div>
<div><br>
</div>
<div>I think fixing it in the source at <a href="https://protect2.fireeye.com/v1/url?k=bf7916a9-e0e22faf-bf795632-86ee86bd5107-5570f6b0d920cfb7&q=1&e=300a3de5-54c4-41b9-bbee-604bb9991333&u=https%3A%2F%2Fgithub.com%2Ferlang%2Fotp%2Fblob%2Fmaster%2Flib%2Fkernel%2Fsrc%2Fnet.erl%23L221" target="_blank" rel="noreferrer">
L221</a> should fix it in the documentation as well. But please let me know if it doesn't.</div>
<div><br>
</div>
<div>However, I am myself confused about the way the type is specified, so thought I will discuss first before opening a PR. </div>
<div><br>
</div>
<div>It is not the net:getnameinfo/1 that I am confused, but about the net:getnameinfo/2. I don't understand the usage of
<b>ifndef</b> and <b>else </b>while specifying this type specification. If you could please point me to a place where I can understand these 2 better. I don't want to make wild guesses here while I am working through the foundations of Erlang.</div>
<div><br>
</div>
<div>It could have been simpler had this specification been written like below, even though whatever "ifdef" is doing out there is to be taken into consideration:-</div>
<div> </div>
<div>
<table style="border-spacing:0px;border-collapse:collapse;color:rgb(216,212,207);font-size:14px;background-color:rgb(19,21,22)">
<tbody style="box-sizing:border-box">
<tr style="box-sizing:border-box">
<td id="m_4200584065570924148x_gmail-LC215" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">SockAddr</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
socket</span>:<span style="box-sizing:border-box;color:rgb(197,143,255)">sockaddr</span>() | term(),</td>
</tr>
<tr style="box-sizing:border-box;background-color:transparent">
<td id="m_4200584065570924148x_gmail-L216" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC216" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">Flags</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
name_info_flags</span>() | <span style="box-sizing:border-box;color:rgb(110,192,255)">
undefined</span>,</td>
</tr>
<tr style="box-sizing:border-box">
<td id="m_4200584065570924148x_gmail-L217" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC217" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">Info</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
name_info</span>(),</td>
</tr>
<tr style="box-sizing:border-box;background-color:transparent">
<td id="m_4200584065570924148x_gmail-L218" style="box-sizing:border-box;padding:0px 10px;width:50px;min-width:50px;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;line-height:20px;color:rgba(211,207,201,0.3);text-align:right;white-space:nowrap;vertical-align:top;border-right:0px">
</td>
<td id="m_4200584065570924148x_gmail-LC218" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-size:12px;white-space:pre-wrap;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">
<span style="box-sizing:border-box;color:rgb(188,182,173)">Reason</span>
<span style="box-sizing:border-box;color:rgb(255,115,105)">
::</span> <span style="box-sizing:border-box;color:rgb(197,143,255)">
term</span>()</td>
</tr>
</tbody>
</table>
</div>
<div><br>
</div>
<div>Please let me know if there is any misconstrusion on my part. </div>
<div><br>
</div>
<div>Thanks and Regards</div>
<div>Nalin Ranjan</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div></div>
<div><font color="#cdc8c2" face="SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace"><span style="font-size:12px;white-space:pre-wrap;background-color:rgb(15,17,17)"></span></font></div>
</div>
</div>
</div>

</blockquote></div>