I’m confused when working with NoteColumn userdata objects in the Renoise Lua API. I have two NoteColumn instances (note1 and note2) from different lines in the same track, and I expect them to be distinct instances with different memory addresses.
However, when I check their equality using the == operator, it returns true, which means that lua considers them equal, even though they should be different instances.
Here’s a code example and output:
local song = renoise.song()
local pattern = song.patterns[1]
local track = pattern.tracks[1]
local note1 = track:line(1).note_columns[1]
local note2 = track:line(2).note_columns[1]
print(note1)
print(note2)
print(note1 == note2)
print(rawequal(note1, note2))
The __eq(a, b) metatable methods for NoteColumn, EffectColumn, PatternLine, Pattern and Phrase are overloaded to check for content equality instead of checking for object identity. So it’s expected that this differs from rawequal which bypasses those metamethods.
There’s a bug NoteColumn and EffectColumn’s eq impl though. Must be in there since ages. They do check for != (for whatever reason). I’ll fix that for the next update.