« first day (1414 days earlier)      last day (1766 days later) » 
00:00 - 21:0021:00 - 00:00

9:00 PM
@M.Doerner #Words...
> Each dimension requires the summation of each higher dimensions product of cElements and lLbound.
 
I think you are looking at the array the wrong way around.
 
That's how I think of it as a feeble human.
 
The last dimension is the dimension of highest significance.
 
Yes
So, (0,1,0) has an offset of 4, the size of the first dimension.
 
9:04 PM
My brain lets me get the correct answer. Explaining it causes something to go wrong.
 
So, per index in the second dimension, you have to accomodate for one full fist dimension, i.e. for an entire array forgetting all higher dimensions.
What does that imply for (0,0,1)?
 
Down 1 is my kneejerk reaction.
That's how I think of it.
The computer has 3rd dimension first, then 2nd, then 1st.
That being said I need to account for the elements of dimension1 and dimension2 both first.
dimension1 has 4 elements, dimension2 has 3.
The product of both 4*3=12.
 
Correct
 
then I go down the corresponding 1 for the 3rd and final dimension.
 
Not exactly
Short question, are you thinking 1-based or 0-based?
 
9:12 PM
Right now I'm going with arr(3) being arr(0 to 3). So 0-based.
 
I mean in specifying the position in the data area.
 
I start at element 1. If I offset by 5 elements I'll end up at element 6.
 
Is you one down for the 1 in the third index or the general 1 from 1-based?
What would be the offset for (0,0,1)?
 
It's offset 12.
 
good
 
9:15 PM
That's because I can visually see the table.
 
And (0,0,2)?
Provided, we redim to accomodate that.
 
arr(0,0,2) would be an out of bounds. That'd be offset by 24.
 
good
 
Trying to generalize the wording dimension3position*(dim1elementCount*dim2elementCount).
 
Exactly
 
9:17 PM
I see what's being done.
I can describe it with numbers.
Getting that description into sentence format is where I fail.
 
= dim3Position*(sizeOfLowerDimArray)
 
I haven't extended the table but I'm going to try for arr(2,2,2).
 
Describing it for a position with more non-zero indices is a bit of a mouthful.
 
= dim3Position*(dim12Product) + dim2Position*(dim1Product) + dim1Position
 
Yep
 
9:22 PM
The dim12Product takes the ULONG cElements of SafeArrayBound for each of the lower elements and get their product. For each successive lower dimension it does the same.
 
My initial point was that you really need all the dimansion sizes in the safe bounds section, but the one for the highest dimension, to actually find the referenced array elements.
Yes
 
arr(2,2,2) would then be = 2*(3*2) + 2*(3) + 2 = 12 + 6 + 2 = 20 Somethings wrong.
 
Not exactly
 
I get stuck without seeing it visually. That's the part I'm still trying to connect.
 
How many elements has a 0-bases array with UBound 3?
 
9:25 PM
arr(3) is the same as arr(0 to 3) which has 4 elements.
:barf:
 
Now look again at you calculation.
 
arr(2,2,2) would then be = 2*(4*3) + 2*(4) + 2 = 24 + 8 + 2 = 34 which is a more comforting number, even without the table built.
 
That is looking right.
 
> # [Codecov](https://codecov.io/gh/rubberduck-vba/Rubberduck/pull/3935?src=pr&el=h1) Report
> Merging [#3935](https://codecov.io/gh/rubberduck-vba/Rubberduck/pull/3935?src=pr&el=desc) into [next](https://codecov.io/gh/rubberduck-vba/Rubberduck/commit/a7475d76599d20e5acfeb332c39aa8135d0ba45f?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `0%`.


```diff
@@ Coverage Diff @@
## next #3935 +/- ##
===========================
 
9:29 PM
 
What the runtime probably does is that it iterates over the indices and the bounds array and builds the product variable along the way.
Note that the only reasons making this memory layout for arrays more useful than the other way around is that it makes more sense to humans to be able to redim preserve the last dimension instead of the first and basically the same for reducing the dimension of an array.
 
@M.Doerner Laymans meaning: [USHORT cDims](msdn.microsoft.com/en-us/library/windows/desktop/… ) is iterated and for each SAFEARRAYBOUND rgsabound[1] it grabs [ULONG cElements]((msdn.microsoft.com/en-us/library/windows/desktop/…) and does the product of ever dimension.
 
Yes
 
After working through this I'd have to agree.
 
Unless you start to do some nasty things with pointers, knowing the memory structure really only tells you why redim preserve has the restrictions it has.
 
9:40 PM
I've wanted to know why only the last, highest, dimension of an array was the only one that could be resized.
So this exercise was very helpful to me.
 
[rubberduck-vba/Rubberduck] build for commit 4fd24a68 on unknown branch: AppVeyor build succeeded
 
In C, you would actually do the calculation yourself for a generic array.
 
> # [Codecov](https://codecov.io/gh/rubberduck-vba/Rubberduck/pull/3935?src=pr&el=h1) Report
> Merging [#3935](https://codecov.io/gh/rubberduck-vba/Rubberduck/pull/3935?src=pr&el=desc) into [next](https://codecov.io/gh/rubberduck-vba/Rubberduck/commit/a7475d76599d20e5acfeb332c39aa8135d0ba45f?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `0%`.


```diff
@@ Coverage Diff @@
## next #3935 +/- ##
===========================
[rubberduck-vba/Rubberduck] build for commit 4fd24a68 on unknown branch: 57.67% (target 0%)
 
That's because of how low level of a language it is?
 
Generics are void*.
a bare pointer without any information
You better know how large your elements are.
If you do not do generics, you get more syntactic sugar.
But under the hood, every C/C++ array is just a [type]*.
I am kind of glad that VBA and C# hide all the pointer problems.
 
9:45 PM
@IvenBach yep. C will happily let you shoot bazooka yourself in the foot.
 
Again the * indicates it's a pointer.
 
Yes
 
Well thanks pond for bearing with me... I'm trying to learn and get on the level the rest of you are at.
 
Say, you have an array of integers arr. Then you can access the third element by dereferencing arr* + 8.
Just hope that your array actually has at least 3 elements.
 
@M.Doerner Why + 8?
 
9:47 PM
2*4
length of two integers
 
I spotted the issue with `LenB(temp(0, 0))
` in https://chat.stackexchange.com/transcript/message/44132698#44132698. It's coming up as 2 because of the `0`.
@M.Doerner And because it's 0 based?
 
A pointer is just an integer.
You tell it "Take the thing 8 bytes after the address in the pointer.".
The array pointer points at the first element.
 
2 = offset. Got it.
 
I prefer a world with a bit of safety belts.
 
I don't trust myself with that kind of stuff. I struggle hard enough with assistance.
 
9:53 PM
I think things like pointers and the memory layout are sometimes useful to know to understand why some things are the way they are, but it is good to have a layer of abstraction over them.
Well, and it can be useful when something goes wrong for some stupid low-level reason, i.e. when the abstraction is leaking.
Now, back to making the unreachable case inspection culture invariant.
 
^ That's why I want to have that underlying knowledge.
Sorry for breaking you away.
 
No problem.
 
One more question though.
 
I was looking up some things in parallel anyway.
 
elementBytes = totalElements * LenB(temp(0, 0)) evaluates to 2 for every digit. Why?
If it 0-9 its 2. For 10-99 it's 3, 100-999 is 4.
That's very confusing.
 
9:56 PM
It is
 
ByVal temp As Variant is how its fed in as.
If i use a Long directly it comes up as 4, as expected.
 
Oh, you are not do pass in type(0,0) by specification.
The behaviour you get is unspecified.
You have to either use a string expression or a variable name.
If you pass in a Variant variable, it is specified to behave like Len applied to a string.
 
msdn.microsoft.com/en-us/library/ee199725.aspx If the variable name is a Variant, Len/LenB treats it the same as a String and always returns the number of characters it contains.
Ok... Now I see it.
 
That is really stupid behaviour.
 
10:11 PM
Public Function MemorySizeOfArrayInBytes(ByRef temp() As Long) As Long causes it to return the correct information.
If I want to use variant I'm going to have to build my own lookup function for variable sizes.
 
10:29 PM
What is preferred in RD, initializing readonly collections in the (single) constructor or doing it in place?
Hm, is there any usecase for a private property?
 
10:53 PM
@M.Doerner in-place, no? unless there's a reason to initialize it in the ctor (from a parameter?)
 
Ah, now I see the usecase for a private property.
I always forget that the accessability is on the type, not the object.
Just wanted to check because it is the other wy around in the unreachable case inspection classes.
Moreover, if I can make a property an auto-property I should, right?
 
11:24 PM
@MathieuGuindon no work back from @Comintern?
 
Hm, I kind of don't like this: a method taking an interface just to immediately (hard) cast it to a concrete implementation.
 
@IvenBach /s/work/word? nope.
 
word... Man my brain is fried.
 
11:42 PM
@this Thank you so much for those links. Took a lot of effort to grok them but I feel a lot better having done so.
 
11:53 PM
I'm stupidly giddy over having learned how to make calls to user32 library.
 
00:00 - 21:0021:00 - 00:00

« first day (1414 days earlier)      last day (1766 days later) »