luup.variable_set - default service string parameter?

Through a schoolboy programming error (too embarrassing to explain fully!) that I’ve recently discovered:

luup.variable_set(service, variable, value, device)

…I found that [tt]service[/tt] was undefined, and therefore presumably [tt]nil[/tt], but the call worked perfectly well!

Is there some sort of default behaviour that would mean, for example, that if [tt]variable[/tt] was unique for [tt]device[/tt] across all the implemented services, then all would be well? It is clearly unambiguous in that case.

It’s not a behaviour that I would seek to exploit, just to understand. Thanks for any insight.

It’s unspecified behaviour to pass nil as the service Id. So, don’t do that.

Really, that’s all that should need to be said. You say that the call “worked”, but that presupposes that you know what the function was “supposed” to do in that case, and you’ve got nothing to defend that supposition. It didn’t fail or crash, but then, that’s allowed for “unspecified behaviour”, just as much as a crash or releasing blue smoke or whistling Dixie is allowed.

It’s an interesting behaviour that you’ve observed, and it might give some insight into how MCV has implemented luup.variable_set(), but you’re in the realm of black-box reverse-engineering.

Thanks futzle - knew I could rely on you for an incisive comment.

Absolutely with you on this. That’s all I wanted to know. But just to respond to your extended comments:

[ol][li]it might have been an intended behaviour[/li]
[li]it did work (reliably for months) in that the variable was set to the expected value (hence not a bug I was looking for)[/li][/ol]

Thanks again.