core icon indicating copy to clipboard operation
core copied to clipboard

Allow return without expression

Open skasti opened this issue 1 year ago • 5 comments

Small change to allow writing return #5070 instead of return [#5070] and similar. Still allows the old way of returning only using expressions, but I find this syntax less error-prone.

Also explicitly setting _value to 0 if no value is returned, as I have had some confusion where I get a unexpected _value but _value_returned is 0 😅

skasti avatar Oct 09 '24 11:10 skasti

This is a breaking change? Returning an explicit value with e.g. return [123.456] will no longer work? I am currently without access to a controller so cannot check.

FYI I am going to add expresssion support to ENDSUB and clearing of _value and _value_returned on CALL since these were not in compliance with the LinuxCNC spec.

terjeio avatar Oct 10 '24 10:10 terjeio

This is a breaking change? Returning an explicit value with e.g. return [123.456] will no longer work? I am currently without access to a controller so cannot check.

No, it just means you can use any of:

return 1
return [1]
return #5070
return [#<something>+10]
etc

FYI I am going to add expresssion support to ENDSUB and clearing of _value and _value_returned on CALL since these were not in compliance with the LinuxCNC spec.

I don't think I understand. Will read again tomorrow and see if brain is braining :P

skasti avatar Oct 11 '24 18:10 skasti

@terjeio Do you think this can get merged? I can't see that it is breaking anything from using it for a while 🤔

skasti avatar Nov 10 '24 09:11 skasti

I am a bit hesitant to add this as it breaks compatibility with LinuxCNC and is not a neccessary change. I'll come back to it a bit later.

terjeio avatar Nov 10 '24 19:11 terjeio

I don't see how this breaks compatibility with anything? it just extends the current mode of operation so that you do not need to encapsulate your return value with []

skasti avatar Nov 10 '24 20:11 skasti