[erlang-questions] Pattern-matching function?

Jachym Holecek <>
Wed Oct 29 20:40:10 CET 2008


# anders conbere 2008-10-29:
> On Wed, Oct 29, 2008 at 7:24 AM, Richard Carlsson <> wrote:
> > You cannot pass a pattern with uninstantiated variables to a function.
> > Erlang is a strict functional language, it is not Prolog. Patterns are
> > not run-time values.
> 
> That being said, the lack of first class access to Patterns makes
> programmatic access to a few of the most common tools in erlang
> exceptionally difficult. Constructing case statements at runtime is
> impossible with out accessing the preproccessor, building functions at
> runtime that have many different possible patterns, also impossible.

It's not impossible, it's just not as easy as you seem to be
expecting: compile:forms/[1, 2]. Also, it works with module
granularity, not individual functions/expressions.

> Maybe that's crazy, but I
> sympathize with Francois, I've been trying to fumble my way through
> erlang metaprogramming and just running into huge walls like this.

When running into huge walls, consider changing direction. ;-)
What actual problems are you trying to solve?

	-- Jachym



More information about the erlang-questions mailing list