Bug 144185

Summary: Clarification needed about scope/lifetime of different types of variables
Product: LibreOffice Reporter: Mike Kaganski <mikekaganski>
Component: DocumentationAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: himajin100000, ilmari.lauhakangas, olivier.hallot
Priority: medium    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:

Description Mike Kaganski 2021-08-30 13:43:42 UTC
Documentation for Global keyword [1] is wrong, stating that the keyword is for scope ("the variable and the array are valid in all libraries and modules for the current session"). The "for the current session" might attempt to express the idea of keeping its value between different macro invocations - but in fact, this is completely unclear from the text, unless you know that yourself.

OTOH, documentation on "Using Procedures, Functions and Properties" [2] tells that there are differences between scope of Global/Public/Private/Dim variables - and it obviously has problems. It doesn't discuss scope of the Global variable (only it keeping its value - but is it visible across modules? across libraries? between macros in shared libraries and document-defined ones (and in the opposite direction)?) It tells that Private and Dim variables are only visible in the module it's defined in - but in fact, it's visible also outside.

This needs clarification (and *maybe* fixing, if some types actually have wrong scope).

[1] https://help.libreoffice.org/7.3/en-US/text/sbasic/shared/03103450.html?DbPAR=BASIC
[2] https://help.libreoffice.org/latest/en-US/text/sbasic/shared/01020300.html?DbPAR=BASIC