POV-Ray : Newsgroups : povray.general : Dynamic arrays in SDL Server Time
29 Mar 2024 05:47:48 EDT (-0400)
  Dynamic arrays in SDL (Message 1 to 5 of 5)  
From: Bill Pragnell
Subject: Dynamic arrays in SDL
Date: 26 Jul 2016 16:30:00
Message: <web.5797c78d621f856f420301460@news.povray.org>
Hi all

I've been tinkering, and noticed that dynamic arrays are possible in SDL. I
wasn't previously aware of this, although naturally, others may have been.
Consider the following:

#macro ExpandArray(Array, N)
 #local Size = dimension_size(Array, 1);
 #local NewSize = Size + N;
 #local NewArray = array[NewSize];
 #for (I, 0, Size-1)
  #ifdef (Array[I])
   #local NewArray[I] = Array[I];
  #end
 #end
 #declare Array = NewArray;
#end

Now this is all fine and good, and terribly useful. But I was wondering: is this
a perfectly cromulent thing to do, or am I abusing the SDL in some way?

Bill


Post a reply to this message

From: Bald Eagle
Subject: Re: Dynamic arrays in SDL
Date: 26 Jul 2016 19:05:00
Message: <web.5797ec49ef86a3ce5e7df57c0@news.povray.org>
"Bill Pragnell" <bil### [at] hotmailcom> wrote:

> Now this is all fine and good, and terribly useful. But I was wondering: is this
> a perfectly cromulent thing to do, or am I abusing the SDL in some way?
>
> Bill

"Cromulent"   :)

It looks perfectly legit to me.   I'm not quite sure how else one would go about
it, though I'd like to find some way to sort of be able to add items into an
array "on the fly".  I suppose writing something like
#macro Add_ArrayItem (Item)
 [expand array by 1]
 [declare array [Old_N+1] = Item]
#end

wouldn't be too hard...


Post a reply to this message

From: clipka
Subject: Re: Dynamic arrays in SDL
Date: 27 Jul 2016 00:21:43
Message: <579836d7$1@news.povray.org>
Am 26.07.2016 um 22:28 schrieb Bill Pragnell:
> 
> I've been tinkering, and noticed that dynamic arrays are possible in SDL. I
> wasn't previously aware of this, although naturally, others may have been.

Well, I wouldn't exactly call your approach "dynamic arrays". It's an
(indeed perfectly "cromulent") kludge to /emulate/ dynamic arrays.


Post a reply to this message

From: Bill Pragnell
Subject: Re: Dynamic arrays in SDL
Date: 27 Jul 2016 05:20:00
Message: <web.57987ba4ef86a3ce5b7d07940@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Cromulent"   :)
Well, the array does get embiggened after all :)

> it, though I'd like to find some way to sort of be able to add items into an
> array "on the fly".  I suppose writing something like
> #macro Add_ArrayItem (Item)
>  [expand array by 1]
>  [declare array [Old_N+1] = Item]
> #end

Yup.
You could expand by more, less frequently, to save time, but then you'd also
need to keep track of the next free index.


Post a reply to this message

From: Bill Pragnell
Subject: Re: Dynamic arrays in SDL
Date: 27 Jul 2016 05:30:00
Message: <web.57987e10ef86a3ce5b7d07940@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 26.07.2016 um 22:28 schrieb Bill Pragnell:
> >
> > I've been tinkering, and noticed that dynamic arrays are possible in SDL. I
> > wasn't previously aware of this, although naturally, others may have been.
>
> Well, I wouldn't exactly call your approach "dynamic arrays". It's an
> (indeed perfectly "cromulent") kludge to /emulate/ dynamic arrays.

Yah. Dynamic at point of use, maybe?


Post a reply to this message

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