[erlang-questions] guard clause oddity, maybe bug (in my brain)?

Bengt Kleberg bengt.kleberg@REDACTED
Fri Nov 20 15:25:43 CET 2015


Greetings,

I can not duplicate your problem.

In case I have misunderstood, here is my code (-define is not my strong 
suite, so it has been removed).

t() -> walk( [asd, qwe], [{123, 456}] ).

walk ([I|Is], [Elt|_]=Ts) when (not is_tuple(Elt)) -> {[I|Is], Ts};
walk(_, _) -> the_other.

This is what happens:

4> c(t).
{ok,t}
5> t:t().
the_other


bengt

On 11/20/2015 03:03 PM, jim rosenblum wrote:
> I have a function:
>
> walk ([I|Is], [Elt|_]=Ts) when (not is_tuple(Elt)) andalso ?IS_INDEX(I) ->
>    Element = index_to_element(I,Ts),
>    case
>        ... snip ...
>    end.
>
> This function clause gets executed even though Elt is a tuple.
>
> I have a break point within this function clause. I am looking at the
> debugger at the break-point within the clause, and I can plainly see 
> that Elt
> IS a tuple: within the debugger I can evaluate is_tuple(Elt) and it 
> returns true,
> I can evaluate (not is_tuple(Elt)) and correctly get FALSE.
>
> So.... how can I be in this clause when the guard evaluates to false?
>
> Thoughts?
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151120/73de7ab3/attachment.htm>


More information about the erlang-questions mailing list