<div class="gmail_quote">On 3 July 2011 16:10, Roberto Ostinelli <span dir="ltr"><<a href="mailto:roberto@widetag.com">roberto@widetag.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
a very stupid spec declaration question. how can you declare the specs of a function which has a single list with multiple arguments?<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
For instance, consider this function:<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">myfun([One, Two]) -><br>
</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">these two following declarations do obviously not work:<br>-spec myfun([One::string(), Two::integer()]) -><br>
-spec myfun(list(One::string(), Two::integer())) -><br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">the proper way seems to be:<br>-spec myfun([string() | integer()]) -><br>
</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">however i feel this to be very misleading, as the specs do not show the order nor the fixed length of the parameter list.<br>
</blockquote><div><br></div><div>If you have a fixed length and format, it strikes me that a list isn't the data structure you want given that a list is by definition variable-length. Is there a reason you're not using a tuple instead of that list? Something like this?:</div>
<div><br></div><div>myfun({One, Two}) -> ...</div><div> </div></div>-- <br>"Perhaps people don't believe this, but throughout all of the discussions of entering China our focus has really been what's best for the Chinese people. It's not been about our revenue or profit or whatnot."<br>
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.<br>