Python Guarded Pattern matching (when x -> do action)

ygutfreund at gmail.com ygutfreund at gmail.com
Tue Nov 15 11:36:26 EST 2016


I am looking to see if there is prior work, or design ideas for implementing pattern-matched guard statements in a very natural format for python programmers.

For those not familiar with pattern matching in [SCALA][1], [Erlang][2], or [F#][3]

They all have constructs similiar to:

When (pattern == condition) then invoke( behavior)

This is also very similiar to trigger-stored-procedure techniques in Databases.

What we want to do is create an agent-based system, where there is a large shared memory, with lots of binary structs (python has good modules for this). Which has many attached guard-statement rules, that will fire when the values match the pattern (we will have monitors that watch when structs are modified).

Has anyone seen prior work of this nature? The goal is to get something that is quite natural to a python programmer, not force SCALA, GO, Erlang, F#, etc on python folks.

We have our own ideas, but I would love to see what the community might have already done along these lines.


  [1]: http://docs.scala-lang.org/tutorials/tour/pattern-matching.html
  [2]: http://stackoverflow.com/questions/21083874/erlang-case-statement
  [3]: https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/match-expressions



More information about the Python-list mailing list