I'm not too good with Renoise lua and such, so excuse me if I've missed something (obvious?). But could I just ask:
If I have two tracks in the Renoise song (Track 1 and Track 2 each sitting at renoise.song().tracks and renoise.song().tracks) and I want to apply operations on say Track 2 I can do this by accessing renoise.song().tracks. I save renoise.song().tracks userdata 'object' to a variable. Now if the user swaps/moves Track 1 and Track 2 via say the mouse, maybe it isn't too much of a problem because we have rawequal. I can compare via rawequal rs.tracks and rs.tracks with saved variable and find that now rs.tracks returns true, so I now know that my Track 2 sits (from the API POV) at rs.tracks.
I want to keep a reference to Track 2 though at all times. Even when the user has saved/loaded the song, and (even when my tool isn't running) the user can move (behind my back) Track 2 around. Where is maybe a unique reference id to these dynamically allocated objects? I can't really use the name field string (and write a searcher that finds my Track 2) as an identifier because then the user could have two or more tracks that have the same name (or no name at all on tracks), that would only really work if the user has unique track names.