''illegal pattern'' when using records in case statement

Bengt Kleberg <>
Thu Feb 6 12:49:07 CET 2003


> X-Authentication-Warning: cbe1066.al.sw.ericsson.se: etxuwig owned process 
doing -bs
> Date: Thu, 6 Feb 2003 12:27:09 +0100 (MET)
> From: Ulf Wiger <>


> On Thu, 6 Feb 2003, Richard Carlsson wrote:
> 
...deleted

> >To be more formalistic about why that can't be made into a
> >pattern: patterns describe the static skeleton of the data
> >(counting pre-bound variables as static), and a pattern
> >like this one would not be static.
> 
> Why wouldn't it be, if it's an intuitive way to express the
> pattern? All suggested alternatives are less intuitive,
> IMHO.
> 
> Isn't this really an artifact of the syntactic expansion of
> record expressions?
> 
> One could imagine that the compiler (knowing the size of the
> prswDomain record) generate code like this:
> 
> dpid_to_if(Dp, Domain) ->
>    __working_dp = Domain#prswDomain.working_dp,
>    __protection_if = Domain#prswDomain.protection_if,
>    case Dp of
>      __working_dp ->
>          Domain#prswDomain.working_if;
>      __protection_if ->
>          Domain#prswDomain.protection_if
>    end.
> 
> Why whould that not be valid?

this is the workaround i refered to in my question. i am using it.
please accept my apologise to all who have made suggestions, but all
other suggestions are less intuitive, IMHO.


bengt




More information about the erlang-questions mailing list