POV-Ray : Newsgroups : povray.general : Status of Moray? : Re: New SDL for POVRay Server Time
28 Apr 2024 21:55:24 EDT (-0400)
  Re: New SDL for POVRay  
From: Patrick Elliott
Date: 1 Nov 2007 16:17:07
Message: <MPG.2193f03b6910848e98a063@news.povray.org>
In article <472a38dd@news.povray.org>, tho### [at] trfde says...
> Patrick Elliott wrote:
> > Mind you, if the only kind of table you have used in 
> > a programming language is a numerically indexed array,
> 
> Actually, I have only ever used computers that support numerically indexe
d
> arrays regardless of programming language. Everything else is superfluous
> anyway.
> 
> 	Thorsten
> 
Well, on a basic level this is the case, true, but high level tables 
like Lua has allow you to index via both numerical and strings. They 
also don't require that the indexes all have "equal" numbers of elements 
for each level. Its more like a mixture of pointers and standard arrays, 
so you can do stuff that, if you did it in some other language would 
look more like:

type idx {
  data as variant
  link as pointer
}
dim myarray() as variant
dim index as idx
dim contents as idx
index.data = "Fred"
contents.data = 1
index.link = contents
myarray.add(index)

Or.. well something like that. Its not a strict array in the sense that 
most languages handle it. Its actually a complex structure, which can 
have different numbers at different layers, or even between different 
indexes. Since the data types are all variant, you can have that contain 
everything from a pointer to a new "array" for one index, or text for a 
different on, or a numerical value for a third, even though the "index" 
you are looking at is on the same "level" of the structure. Sort of if 
you made "myarray()" above into:

dim myarray(3) as variant
myarray(1) = "Fred"
myarray(2) = 42
myarray(3) = newarray()

At least in theory. Its possible there are some constraints that require 
the index to contain a similar data type or something, but just because 
I haven't seen anyone use multiple index types doesn't mean it can't, 
and there is no problem at all with having the "data" associated with an 
index contain strings, numbers, objects, or even another table, as the 
"data" in that element. Its sounds confusing as hell, but its very 
flexible and you can do thing with it that are complicated and 
irritating to manage in most other languages, where your arrays tend to 
be one data type, and only one type, for the entire contents. Even ones 
like VB, which use variants for most stuff, can have problems trying to 
do this, since while you could define an array of variants, the commands 
to handle the result are... not necessarily geared towards handling such 
a structure.

-- 
void main () {

    call functional_code()
  else
    call crash_windows();
}

<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
 
3D Content, and 3D Software at DAZ3D!</A>


Post a reply to this message

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