[Verse-dev] Numerical IDs [R4]

Eskil Steenberg verse-dev@blender.org
Wed, 11 Aug 2004 19:22:49 +0300


Hi, still at Siggraph, I have the OpenGL and verse BOF today.

>Um, no? That's a tilde (~) character, not a minus...

Oh sorry.

>When doing these tests, I want to make sure that I only care about
>and look for changes that are not already known, to avoid doing re-
>dundant string comparisons against method names, 

Again this is what i said, it is mainly use full from optimization 
stand point. havinga invalid value _is_ ussefull, but i just think 
that zero is the wrong one.

>> So the invalid id is never used by verse, and are not very 
usefull 
>> in any client end either. 

>I disagree. I find it very useful to be able to set an ID variable
>(or structure field) to a known invalid value, to mark that I am
>still waiting for the server to assign it.

I agree it is usefull in your app, but not for the network protocol. 
Actiually not only wound the host never send you invalid values, it 
usualy even cant, since this triggers function aliases.

>Such defines would have to include the type of value, which is not
>very elegant, compared to just using zero.

Yes, it would need to have types. (just a question: dont you have 
issiues against all nunbers typed in to the code that arent 
defines?)

Ok Lets go beyond this and let me explain just how much this would 
break existing apps, and make them a hole more more complicated:

The first main reason is that in C the first element of an array is 
numberd wero.

Imagine that you allocate and array of vertexes, polygons, layers or 
buffers. Now either you dont use the first element and waist memory 
or you have to make lookups in to the array with ids minus one. This 
makes the code way more error prone.

Next consider this, If i have a look-up in to a array i must always 
check for this. For example lets read out a vertex from a a polygon 
reference. this is how its done now:

if(polygon[id * 4] < vertex_length && vertex[polygon[id * 4] * 3] != 
E_REAL_MAX) 

this the same code if the zero is reserved:

if(polygon[(id - 1) * 4] != 0 && polygon[(id - 1) * 4] < 
vertex_length && vertex[(polygon[(id - 1) * 4] - 1) * 3] != 
E_REAL_MAX) 

This extra test have to be done for every corner in the polygon and 
is just a hazzle. It compleatly breaks all my apps (in more then one 
place). and it is likely to introduse a lot of bugs even if fixed.

This doesnt just hurt polygon and vertex code, it require an extra 
test (and a subtract) for every, layer, fragment and buffer look up. 
Again breaking all apps and further complicate the apps.

Yes the hole NULL-zero thing makes having zero be an invalid look 
nice. But thees are ids not pointers! And when it comes to array 
lookups, the id zero is about as valid as you can get. Making zero 
invalid will make so much code so much uglyer. 

Cheers

E