Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Local variables needed in functions (help variables, temp variables, etc) #352

Open
fastpipe opened this issue Jan 28, 2020 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@fastpipe
Copy link

fastpipe commented Jan 28, 2020

The situation:

You create a function with parameters and a result.
Inside the function block you have to calculate several values by help variables (temporary variables, not needed outside). It is a logic catastrophe to use global (app) variables for this.
And in bigger projects you loose overview. Global variables only created for temporary use in function can cause severe problems, when you use the same name outside the function.

Of course you could implement additional parameters to use them as local variables. But that is not a proper solution.
Or you can construct a count loop that you do not use and use the names of the loop variables. But this is no real solution, because count-variables in loops also react global.
What do you think?

So we urgently need local variables!

As a teacher for computer science and book author I have problems to teach about functions and using global variables.

@MrMazzone
Copy link

@fastpipe Absolutely agree! -- Also a teacher FYI. I just completed a unit on function/procedural abstraction. I didn't like having to use global/app variables to just temporarily store values for the function to just return.

Initializing local variables would be a welcomed addition. Could be done similar to App Inventor where the block showcases the variable scope and lifetime.
image

@mark-friedman
Copy link

Thanks @fastpipe and @MrMazzone! We have local variables on our feature list and understand how useful they can be.

@jane-d-alt jane-d-alt added the enhancement New feature or request label May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants