[erlang-questions] Bug ?!

Mats Cronqvist <>
Tue Oct 3 13:03:23 CEST 2006

Richard Carlsson wrote:
> Richard A. O'Keefe wrote:
>> Of course, it could be given a different expansion, so the question
>> of whether field access SHOULD be allowed in a pattern remains open.
> Allowing a pattern such as X#r.a, however, introduces a more general 
> computation: it does not describe a record #r{a=..., ...} in the 
> position of the pattern, but a constraint `{foo, Y} when Y =:= X#r.a 
> ->...' (which in this case performs a decomposition). If this is
> allowed, there is no real reason why not arbitrary expressions (that may 
> occur in guards) should be allowed, using the same expansion 

   and that would be a bad thing? apparently, since...

> but that 
> would probably make guards rather unreadable and go against the "spirit 
> of patterns" - it breaks compositionality (in the intuitive sense - I'm 
> not trying to be formal here).

   that is way too philosophical for my (admittedly weak) mind. it seems good to 
me. perhaps richard has an example of such an "unreadable guard"?

> `X#r.a' has a superficial look and feel that is close to the other 
> (allowed) record patterns, which is probably why one may easily think 
> that it should also be allowed, but it is really rather different.

   seems like a pretty obvious way to describe a constraint to me.


More information about the erlang-questions mailing list