FIRST-Tech-Challenge / SkyStone

FTC SDK
https://www.firstinspires.org/robotics/ftc/what-is-first-tech-challenge
275 stars 1.04k forks source link

Function parameters in blocks are visible as "global" variables #180

Open Windwoes opened 4 years ago

Windwoes commented 4 years ago

As I was helping our sister team that uses Blocks, I noticed that function parameters are listed as "global" variables, i.e. lumped into the same menu as "normal" variables.

This is extremely confusing and makes absolutely no sense at all. At a minimum, parameter variables should not "click" into place in functions other than their parents. However, having them be a different color and accessible through the little gear icon on the function (rather than through the variables pane) would also be a good idea.

Additionally, I feel like there's a possibility for undefined behavior here, because (as mentioned before) you can click a parameter block for funcationA into some code functionB. I would have no idea what the value of this variable would be when used outside its parent function. In C, returning a pointer to a local variable will cause undefined behavior because that method's stack will have been freed.