non-Erlang Erlang grammars

Ulf Wiger <>
Tue Oct 24 11:22:33 CEST 2000

On Tue, 24 Oct 2000, Vlad Dumitrescu wrote:

>I was thinking about this problem, and I suppose the solution using funs
>would be to provide an ets:lookup/3, where the third argument is a fun that
>filters the results of ets:lookup/2 and also filters the elements that will
>be outputted to the result. Also, list comprehensions that accept an ets
>generator would also do fine, even more elegantly than simple funs.
>As I understand it, the big problem is how to make the funs evaluate in ets
>space, not local space. But otherwise I can't understand why these funs
>should abide by the following rules
>>- no message passing
>>- no external function calls
>>- no loops
>>- no operations that are not known to be O(1)
>Is it an efficiency aspect? Or an implementation issue? Or a more
>deep-going architecture one?
>Is it because the funs woill be evaluated in a different space?
>Could someone please explain this? Thanks.

It's partly an efficiency issue, I guess. If you want to apply a trace
filter, for example, you'll want some assurance that the filter fun is
as efficient as it can be. It would also be nice to know that the
function is guaranteed to terminate at all.

Basically, this borders on another topic that I've thought about
from time to time: fast-path processing. This is what would happen for
example in a content-based router (or perhaps a web switch, right?)
It would be nice if one could write some kind of "erlang lite" code
which is perhaps a subset of normal erlang, but has much of the same
feel. The main feature of erlang lite would be that it is optimized
for fast-path processing (say, able to handle many MBytes or even
GBytes per second on reasonable hardware.)

Message passing is not an efficiency aspect. It's more about being
able to _know_ that the code you're calling is side-effect free,
which is something that would often be useful. One example is the ACID
property of mnesia transactions, which can't be fully guaranteed if
the transaction funs contain side effects.

Ulf Wiger                                    tfn: +46  8 719 81 95
Strategic Product & System Management        mob: +46 70 519 81 95
Ericsson Telecom AB,              Datacom Networks and IP Services
Varuvägen 9, Älvsjö,                    S-126 25 Stockholm, Sweden

More information about the erlang-questions mailing list