Open GWRon opened 1 year ago
I am not sure if BCC should error out if someone "defines" a global somewhere where others cannot reach it. Or maybe "warn" ?
Midimaster ammended that a global in a "block" exists for the whole lifetime of the block (eg loop)
For Local i:Int=0 To 9
Global wert:Int=10
wert=wert+1
Print wert
Next
Maybe the documentation for "global" should reflect it ? Something that tells that globals "stay forever" but are limited in their scope (you can only read them in that scope)
Maybe a better way to put it would be...
"A global within a scoped block, and its assigned/updated value, will exist for the lifetime of the application, but it is only available to be used within the defined scope and any inner scopes from where the global is defined."
Something like that 😬
On Thu, 13 Jul 2023, 19:29 Ronny Otto, @.***> wrote:
Midimaster ammended that a global in a "block" exists for the whole lifetime of the block (eg loop)
For Local i:Int=0 To 9 Global wert:Int=10 wert=wert+1 Print wert Next
Maybe the documentation for "global" should reflect it ?
— Reply to this email directly, view it on GitHub https://github.com/bmx-ng/bcc/issues/629#issuecomment-1634079469, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYSTENOD2WNOOLG24BBX63XP7L2BANCNFSM6AAAAAA2IYOPFQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
a user had an issue reported in discord. I extracted the original problem:
I thought a global can be declared everywhere - but it seems it can't: Output:
Same also for While-loops and surely other "blocks". And also inside "if endif".