[erlang-questions] List to proplist?
Andras Georgy Bekes
Fri Oct 31 12:29:23 CET 2008
> Between [E(X) || X (<-) F]
> and [E(X) || X <- unfold(S, F')]
> there is very little difference,
> *provided* the compiler knows about unfold and treats it specially.
What do you mean by "treats it specially"?
Do you mean that the result list of unfold(S,F') is not generated by
calling unfold as a function call, but is generated element-by-element
as the list-comprehension progresses?
In that case, the difference is only syntactic I think, and I'm
perfectly satisfied by both solutions.
> I've been thinking that we wouldn't really need
> syntax for iterating over the elements of a tuple
> if the compiler knew how to handle
> [E(X) || X <- tuple_to_list(T)].
The compiler handles this just right. What do you mean?
Do you want the compiler to generate code that does not build the result
list of tuple_to_list(T), but traverses the tuple element-by-element as
the list-comprehension progresses?
I don't think it makes a big difference, as tuples are usually small. On
the other hand, the list generated by an unfold can be really big (even
infinite, and a list comprehension should handle it without problems,
if the resulting list is not used and therefore, not generated).
> Using QLC it is already possible to implement generators and use them
> with the LC syntax.
But QLC is too bloated. You must write way more boilerplate code for QLC
than for the above specially-treated unfold.
More information about the erlang-questions