octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #53579] Change in global handling for variable


From: Michael Godfrey
Subject: [Octave-bug-tracker] [bug #53579] Change in global handling for variable in global and passed as argument
Date: Fri, 6 Apr 2018 23:21:28 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?53579>

                 Summary: Change in global handling for variable in global and
passed as argument
                 Project: GNU Octave
            Submitted by: godfrey
            Submitted on: Sat 07 Apr 2018 03:21:27 AM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Regression
                  Status: None
             Assigned to: None
         Originator Name: godfrey
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

It would seem that the handling of the case below in the
current dev is appropriate, but it conflicts with 4.2.2 and
previous versions. The error occurs if a variable in declared
global and used in a function argument list. Below shows
Matlab, 4.2.2, ad dev results. I do not fully understand
the Matlab error message...

I think that the handling in dev is a good choice, but the
error message should be made clearer and the incompatibility
with previous Octaves should be noted. The diagnostic could
be: passing a variable which is declared global as an argument
is not allowed...


The script top.m is:
global aa bb
  xx =1 ;
  aa = 1;
  sub1(aa, xx);
  aa
==================
sub1.m is:
function sub1 (aa, bb)
  global aa bb
  aa = 1;
return

Results for Matlab, 4.2.2, and dev 4.5.0+ are:

                                      < M A T L A B (R) >
                            Copyright 1984-2017 The MathWorks, Inc.
                             R2017b (9.3.0.713579) 64-bit (glnxa64)
                                       September 14, 2017

 
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
 
>> ls
sub1.m  top.m

>> top
Warning: The value of local variables may have been changed to match the
globals.  Future versions
of MATLAB will require that you declare a variable to be global before you use
that variable. 
> In sub1 (line 2)
  In top (line 4) 
Warning: The value of local variables may have been changed to match the
globals.  Future versions
of MATLAB will require that you declare a variable to be global before you use
that variable. 
> In sub1 (line 2)
  In top (line 4) 

aa =

     1

Results for
GNU Octave, version 4.2.2
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-redhat-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> top
aa =  1
octave:2> quit

Results for dev:
address@hidden global_change]$ oct
octave:1> version
ans = 4.5.0+
octave:2> top
error: 'aa' undefined near line 5 column 3
error: called from
    top at line 5 column 3
octave:2> 






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53579>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]