Spin: what is the meaning of @scan{0}
laurent974
Posts: 77
in Propeller 1
as reading kuroneko scanline driver, there this code, and i don't know what is the meaning of the {0} ?
VAR long frame, scan[quads] PUB selftest : n driver.init(-1, @scan{0})
Comments
Probably a matter of taste. I prefer inline. That way the eyes don't need to jump between code and comment. The comment is exactly where it matters. "equiv to @scan[0]"?
Who? The whole line? Or which part?
"@scan is equiv to @scan[0]" would be exact but really would repeat too much.
In retrospect it's better to just write "x := buffer".
EDIT: I actually first used the {} notation in my malloc code, where each malloc'ed chunk contained a header with the chunk size and a pointer to the next chunk. The code looked something like this.
It sort of makes sense in this context.
In an optimizing compiler the two expressions would be the same -- PropGCC and fastspin, for example, would both generate the same code for these. It'd be nice if the "official" Spin2 compiler had some simple peephole optimizations to do really obvious optimizations like this.