https://bugs.documentfoundation.org/show_bug.cgi?id=59327

LeMoyne Castle <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
           See Also|                            |https://bz.apache.org/ooo/s
                   |                            |how_bug.cgi?id=116948
           Assignee|[email protected] |[email protected]
                   |desktop.org                 |

--- Comment #7 from LeMoyne Castle <[email protected]> ---
Definitely a bug.  Looking at the source and the tests here and at
https://bz.apache.org/ooo/show_bug.cgi?id=116948 it is crystal clear that only
the last optional argument is declared at runtime.  Is a bug because default
values are not available and, even worse, the parameters in the function
prototype are not available as variables at runtime so using >1 optional
parameter causes runtime errors.  

Making more than one optional parameter a source of run-time errors == worse
than useless. Only real workaround is to not use the broken feature and require
all but the last parameter.  

The idea that the Basic programmer MUST use the IsMissing feature to work
around the optional brokenness is weak at best. The fact that IsMissing is and
will always be false because of the way it is implemented makes it appalling. 
Shouting how Basic == 'workarounds required' as in the AOOo forum?  Ludicrous. 
VBA has supported optional parameters with defaulting and IsMissing() for well
over a decade.  

The appropriate recommendation is: always set default values &/or use
IsMissing(arg) to ensure that after ALL args are declared by the Basic runtime
they are ALL initialized, except where zero is fine.    

ALL Parameters in ALL sub/function declarations should be available for use as
variables within that sub or function. ALL Parameters Always declared in
function scope whether or not values have been passed through them or set by
default.  

I agree that this is fairly low priority, but here is a potential use:  The
IsMissing test allows the function to distinguish between 2,3,4... argument
calls.  An upgraded function library can then tell if it is being called from
old code before the upgrade that obviously didn't know about the optional
params.  The opt args can control the new doings &/or transmit more output from
the new routines.  This also allows real time determination of the need for
more or less of safety dance, defaulting, workaround, file format change, etc.
as is appropriate.  
e.g.> If Not IsMissing(optArg1) Then '''REM assign to optArg1 only when it was
given 
e.g.> If IsMissing(arg1) Then arg1 = new fancy.new.object  '''REM not given one
so create one 

Optional parameters can allow live testing of new stuff in a shared or
delivered function library without requiring the more complex primary routines 
also be updated everywhere before they have been fully tested live.  

Was working another (unfortunately related) issue, found the defaulting
brokenness and remembered this bug.  Will patch <strike>both</strike> all three
issues soon.  Taking assignment.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to