POV-Ray : Newsgroups : povray.off-topic : Programming language discussion : Re: Programming language discussion Server Time
3 Sep 2024 23:30:26 EDT (-0400)
  Re: Programming language discussion  
From: Darren New
Date: 28 Oct 2010 14:00:22
Message: <4cc9ba36$1@news.povray.org>
Warp wrote:
>   It saves checking the node type for each single operation you do to any
> node in the list. It the node is a struct, its contents are fixed and thus
> you don't have to check anything.

If the node is a struct, you still have to check if it's the end of the list 
or a leaf of the tree.  You still have to do the equivalent of the text in

if (node->next != NULL) ...

In any case, this checking process is built into the syntax of the language. 
That (and more) is what is meant by "pattern matching" constructs. So 
checking the tag on the union (so to speak) is done in a type-safe way with 
pretty much the same amount of work as checking for a NULL pointer.

-- 
Darren New, San Diego CA, USA (PST)
   Serving Suggestion:
     "Don't serve this any more. It's awful."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.