[erlang-questions] Baffling lists

Ulf Wiger ulf@REDACTED
Mon Sep 22 15:02:13 CEST 2014


On 22 Sep 2014, at 14:21, Joe Armstrong <erlang@REDACTED> wrote:

> It's not really a good idea to have "improper" lists - so I'd check
> the code base to
> see this doesn't happen - there are rare "I'll save a word" cases where you
> might want a non proper list - but the pain of not being able to use standard
> libraries will outweigh the pleasure.

A bit O.T. ...

There is one particular place where improper lists are extremely useful:
in the match head of an ets:select(). This allows you to perform a prefix
search on list-structured keys, for example:

ets:select(Tab, [ { #stats{[requests, http | ’_’], _ = ‘_’}, [], [‘$_’] }])

The main problem with doing this is that Dialyzer will have opinions about both improper lists being used and ‘_’ violating the type signature for the record.

I understand the problem (match specifications are data - not patterns), but it’s still annoying.

BR,
Ulf W

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com






More information about the erlang-questions mailing list