|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |