POV-Ray : Newsgroups : povray.general : Feature requests iden() : Re: Feature requests iden() Server Time
8 Aug 2024 22:15:07 EDT (-0400)
  Re: Feature requests iden()  
From: Chris Huff
Date: 27 Nov 2000 21:26:52
Message: <chrishuff-AC0F7E.21272527112000@news.povray.org>
In article <slr### [at] fwicom>, ron### [at] povrayorg 
wrote:

> The Perl syntax...

I meant your idea of what it would look like in POV. Hopefully a little 
better than "$foo{"bar"}"...


> An associative array is a variable-sized data structure (a hash table, 
> in Perl) which associates a key with an arbitrary scalar value.  Perl
> uses them to do its equivalent of data structures, among other things.

I see...but a POV one would have to allow more than just scalars, but 
also vectors, objects...what should the keys be? Should(could?) both 
scalars and strings be allowed as keys? Or maybe keys should be used 
like identifiers...

#declare AssocArray =
assoc_array {
    Ident, Val;
    Ident2, Val2;
    Ident3, Val3;
    ...
};

Or maybe this, more consistent with other POV syntax...

#declare AssocArray =
assoc_array {
    {Ident, Val},
    {Ident2, Val2},
    {Ident3, Val3},
    ...
};

// Adds an item or modifies an existing item...
#declare AssocArray[NewIdent] = AssocArray[Ident2] + AssocArray[Ident1];

Or this, farther from array syntax(which may be a good thing, since it 
isn't the same thing) but makes more sense(to me):

#declare AssocArray.NewIdent = AssocArray.Ident2 + AssocArray.Ident1;

The identifier names would be local to the array, you would be able to 
use them in other places. It should be possible to have an associative 
array with a member with the same name as the array:
#declare Moof =
assoc_array {
    {Moof, 2.5}
};

#declare Moof.Moof = 6;

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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