POV-Ray

The Persistence of Vision Raytracer (POV-Ray).

This is the legacy Bug Tracking System for the POV-Ray project. Bugs listed here are being migrated to our github issue tracker. Please refer to that for new reports or updates to existing ones on this system.

Tasklist

FS#129 - Hash arrays

Attached to Project: POV-Ray
Opened by Mike H (SharkD) - Wednesday, 09 June 2010, 23:46 GMT
Last edited by William F Pokorny (wfpokorny) - Saturday, 21 January 2017, 14:55 GMT
Task Type Feature Request
Category Backend → Parser/SDL
Status Tracked on GitHub
Assigned To No-one
Operating System All
Severity Very Low
Priority Low
Reported Version 3.70 beta 37a
Due in Version Future release
Due Date Undecided
Percent Complete 0%
Votes 1
Private No

Details

Currently, array items may only be referenced by their index number (an integer). It would be nice to also be able to assign string values as array indexes, as in other scripting languages.

This task depends upon

Comment by Grimbert Jérôme (Le_Forgeron) - Thursday, 10 June 2010, 12:35 GMT

How do you loop over such arrays ?
POV-SDL is not php, I do not feel the need of a foreach()... nor a ksort().

Nice seems a bit frivolous here.

Comment by Mike H (SharkD) - Sunday, 20 June 2010, 00:34 GMT

It's easier to remember names than index numbers. If you have a group of related items (stored objects, variables, macros, etc.) then you can use the same naming scheme throughout. And, if you have more than one array you don't have to worry about the arrays being equal in length, or if they have had items added or removed to/from them: the index will always remain the same.

Comment by Thorsten Fröhlich (thorsten) - Sunday, 20 June 2010, 08:05 GMT

POV-Ray is not a scripting language in the sense of the ones that offer the feature you are talking about. You can declare special indices in advance, then they are easier to remember.

Comment by Mike H (SharkD) - Sunday, 20 June 2010, 08:43 GMT

Er, what? That sounds bogus to me. "POV-Ray is not a thing that has that feature, therefore it is not a thing that has that feature." That is the point of "Feature Requests" isn't it, or am I retarded? Don't the POV-Ray docs themselves brag about how you're able to write a complete ray-tracer within POV-Ray using only SDL? And plenty of non-"scripting" languages support hash (associative) arrays. Or do C++ and C# not count?

Comment by Grimbert Jérôme (Le_Forgeron) - Friday, 29 October 2010, 11:52 GMT

what about simply declaring your "string" index with classical #declare.

Instead of

arr["Mike"] = foo;

You can already have

#declare Mike = 3;
...

arr[Mike] = foo;

Associative array in C++ are called maps, not arrays.
(unless you want only an #enum for povray ?
#enum { Mike, Thorsten, Jerome } ???
)

Comment by Mike H (SharkD) - Sunday, 19 December 2010, 17:55 GMT

What if:

#declare Mike = 3;
#declare Thorsten = 7;
#declare Jerome = 32;

#declare MyArray = array[3]
#declare MyArray[Mike] = pigment{White}
#declare MyArray[Thorsten] = pigment{Blue}
#declare MyArray[Jerome] = pigment{Black}

Isn't going to work.

Comment by Grimbert Jérôme (Le_Forgeron) - Tuesday, 21 December 2010, 11:56 GMT

I can lead the horse to water, but I cannot make it drink.

Good practices would be for the last code to have instead:

#declare Mike = 3;
#declare Thorsten = 7;
#declare Jerome = 32;
#declare Last_Entry = 33;// or even " = 1+max(Jerome,Thorsten,Mike); "


#declare MyArray = array[Last_Entry]
#declare MyArray[Mike] = pigment{White}
#declare MyArray[Thorsten] = pigment{Blue}
#declare MyArray[Jerome] = pigment{Black}

(and we might be missing a few semi-colons)

Comment by William F Pokorny (wfpokorny) - Saturday, 21 January 2017, 14:55 GMT
  • Field changed: Status (New → Tracked on GitHub)

Now tracked on github as issue #198. Perhaps the new ‘dictonary’ feature completely satisfies the request? If so, please close out on github.

Loading...