[erlang-questions] style question - best way to test multiple non-guard conditions sequentially

Anthony Ramine <>
Mon Dec 16 12:00:35 CET 2013


That should have been « it’s not finished yet ».

-- 
Anthony Ramine

Le 16 déc. 2013 à 11:56, Anthony Ramine <> a écrit :

> It’s done finished yet, but I’m on it:
> 
> 	https://github.com/nox/otp/tree/cond
> 
> -- 
> Anthony Ramine
> 
> Le 16 déc. 2013 à 11:32, Richard Carlsson <> a écrit :
> 
>> On 2013-12-15 19:07 , Anthony Ramine wrote:
>>> Hello,
>>> 
>>> I’ve thought about this again and realised that there is a technical reason not to expand cond expressions to nested cases directly. That reason is scoping rules.
>>> 
>>> Let’s assume we compile this expression naively to nested cases:
>>> 
>>> 	cond X = false -> X;
>>> 	     X = true -> X
>>> 	end
>>> 
>>> =>
>>> 
>>> 	case X = false of
>>> 	    true -> X;
>>> 	    false ->
>>> 	        case X = true of
>>> 	            true -> X;
>>> 	        end
>>> 	end.
>>> 
>>> I would be *extremely* surprised that such an expression would crash with badmatch instead of returning true as it should.
>>> 
>>> Regards,
>>> 
>> 
>> Yes, these complications are the reasons why cond never got implemented beyond experimenting with the expansion you showed above. It needs clearly specified scoping rules, and support in all tools above the Core Erlang level. And nobody seemed to have the time to do that.
>> 
>>  /Richard
> 




More information about the erlang-questions mailing list