V4MD Noob: VOID instead of Vset with zero records?
Marc Schmitt
Marc_Schmitt at gmx.de
Tue Apr 22 04:10:45 CDT 2008
Hi to you and thank you for your concentration ;)
I'll try to explain myself, without getting things mixed up.
My first approach, (that I want an empty Vset as optional returned output) would be mostly for comfort.
Actually, I do what your pseudo-code implies:
Perform a search in a field -> check if the result is void -> if its void then I substitute it with an empty handmade Vset.
That works, but is not nice to read and hard to debug.
My desired comfortably pseudocode would read like:
result_1 = fieldA.findContains(aString,aSelection)
result_2 = fieldB.findContains(anotherString,result_1)
-> drawback 1: when there are no records, the returned void is interpreted in the second search as 'all records' instead of 'no-records'
-> drawback 2: 'result_2' looses its object-type with all its consequences
-> drawback 3: I don't know if the VOID is the result of an error, or the result of a zero-records-set
This is what I do for now (pseudo-code):
result_1 = fieldA.findContains(aString,aSelection)
if voidP(result_1) THEN result_1 = generateEmptyVBitset()
result_2 = fieldB.findContains(anotherString,result_1)
-> drawback 3 still exists
I agree that in most cases there must be performance over comfort. So I understand you have to use less RAM and cannot generally satisfy my laziness ;)
And for consistence between the platforms you took the void whats the nearest thing to a c++ null-pointer as far as I understand.
But, the problem here is that void in lingo is very unsharp. I just can't know if it is an undefined variable or a formerly c++ null-pointer resulting from a zero matches search. Thats really hard to debug.
You're right, there's no NIL in director, I think my suggestion was not very well written.
I strongly suggest (optionally) not to use void for zero-records-results. A returning integer 0 or boolean FALSE or a symbol #null (or whatever...) would be far more easy to debug.
(In lingo a symbol is something like a by the user reserved constant that uses verly little space.)
A symbol(#null) instead VOID would help a lot for debugging.
I think I understood the main problem here is, that Lingo uses a quite uncommon mix of datatypes and values and is only loosely typed. So it's not so easy to adapt these things without braking the logic. Hey, maybe I am just learning, why most Director-people use the SQL-way? ;)
But please comment anyway on my suggestion.
Cheerio
Marc
More information about the Valentina
mailing list