POV-Ray : Newsgroups : povray.off-topic : Programming language discussion : Re: Programming language discussion Server Time
3 Sep 2024 23:30:19 EDT (-0400)
  Re: Programming language discussion  
From: Orchid XP v8
Date: 28 Oct 2010 15:21:06
Message: <4cc9cd22$1@news.povray.org>
>>>    What would the harm be if eg. list nodes were structs instead?
>
>> Since "null" is a union in Haskell to (i.e., it either has data in it or it
>> has no data in it), this wouldn't really save you anything.
>
>    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.

On the other hand, in a language where unions appear all over the place, 
the implementors go to great lengths to make it really efficient.

Besides, normally just about any code that does stuff to a linked list 
ends up doing something like

   while (list != null)
     do stuff;
     list = next node;

So there's a check in there anyway. All we're doing by using a union is 
making it a different check.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

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