But tuples lack things like lists:map() and lists:foreach(). If there were such functions for tuples, I would agree with you and just use tuples.<div><br></div><div>Dan.<br><br><div class="gmail_quote">On Sat, Jul 7, 2012 at 5:15 AM, Joe Armstrong <span dir="ltr"><<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't understand.<br>
<br>
Lists are intended as containers for a variable number of terms. Tuples are<br>
intended as a container for a fixed number of terms. Not using lists and tuples<br>
as they are intended will just lead to confusion.<br>
<br>
/Joe<br>
<div><div class="h5"><br>
On Fri, Jul 6, 2012 at 6:28 PM, Daniel Goertzen<br>
<<a href="mailto:daniel.goertzen@gmail.com">daniel.goertzen@gmail.com</a>> wrote:<br>
> While working with lists of fixed length, I noted that type specification<br>
> for such lists are conspicuously missing. For example, the following does<br>
> not work...<br>
><br>
> -spec get_buttons() -> {ok, [boolean(), boolean(), boolean(), boolean()]}.<br>
><br>
> Is there some sneaky way to make this go? Now I know you would normally use<br>
> a tuple in this situation, but I will be using the lists module to process<br>
> this data so I want to stick with lists.<br>
><br>
> I would love to see something like this for list specification...<br>
><br>
><br>
> List :: list(Type) %% Proper list ([]-terminated)<br>
> + | list(Type, Length) %% Proper list of fixed size<br>
> + | tlist(TList) %% Proper list specified like a<br>
> tuple<br>
> | improper_list(Type1, Type2) %% Type1=contents,<br>
> Type2=termination<br>
> | maybe_improper_list(Type1, Type2) %% Type1 and Type2 as above<br>
><br>
> Tuple :: tuple() %% stands for a tuple of any<br>
> size<br>
> | {}<br>
> | {TList}<br>
><br>
> TList :: Type<br>
> | Type, TList<br>
><br>
><br>
> Thanks,<br>
> Dan.<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
</blockquote></div><br></div>