[racket-dev] scheme_is_list?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Sep 7 20:22:32 EDT 2011

At Wed, 7 Sep 2011 20:18:44 -0400, Danny Yoo wrote:
> I'm looking at scheme_is_list in src/list.c, and it looks like there's
> code that's unreachable, unless I'm reading it wrong?!  The body is:
> 
> 
> int scheme_is_list(Scheme_Object *obj1)
> {
>   Scheme_Object *obj2;
>   int flags;
> 
>   if (SCHEME_PAIRP(obj1)) {
>     flags = SCHEME_PAIR_FLAGS(obj1);
>     if (flags & PAIR_FLAG_MASK) {
>       if (flags & PAIR_IS_LIST)
>         return 1;
>       else
>         return 0;
>     }
>   } else if (SCHEME_NULLP(obj1))
>     return 1;
>   else
>     return 0;
> 
>   obj2 = obj1;
> 
>   /** more code here */
> }
> 
> 
> Isn't all the code starting from 'obj2 = obj1' unreachable?

No --- the first `if' branch doesn't always return, since its returns
are protected by another `if'.




Posted on the dev mailing list.