bugGNU Octave - Bugs: bug #62697, What wizardry is this

 
 

bug #62697: What wizardry is this

Submitter:  None
Submitted:  Sat 02 Jul 2022 07:57:54 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 7.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 03 Jul 2022 08:58:26 AM UTC, comment #3: 

Like Nik already explained, this is expected behavior.

Closing as invalid.

If you have some (general or specific) question about Octave, the discourse forum might be a better place to ask than this big tracker:
https://octave.discourse.group/

Markus Mützel <mmuetzel>
Group administrator
Sun 03 Jul 2022 04:47:32 AM UTC, comment #2: 

i and j have values equal to the unit imaginary number when they aren't defined as variables. When you use a or k, the for loop applies the value to a or k, you call that value and it displays as 1, you clear that variable, then call it again, but because you cleared it you get an error because it no longer exists

When you do the same with I or j, clearing it return the variable to the original hit imaginary value, and that's what it displays. Without any error occurring, the next loop iteration begins, octave assigns 2 to i or j, and the cycle continues.

All of this seems to be as I would expect.

Nicholas Jankowski <nrjank>
Group Member
Sat 02 Jul 2022 08:33:52 PM UTC, comment #1: 

Possible same issue/duplicate as bug #62552


for j =1:5
j
clear
j
end
j = 1
ans =  0 + 1i
j = 2
ans =  0 + 1i
j = 3
ans =  0 + 1i
j = 4
ans =  0 + 1i
j = 5
ans =  0 + 1i


for k

for k=1:5
k
clear
k
end
k = 1
error: 'k' undefined near line 4, column 4


Anonymous
Sat 02 Jul 2022 07:57:54 PM UTC, original submission:  


for i = 1:5
  i
  clear
  i
end


i = 1
ans =  0 + 1i
i = 2
ans =  0 + 1i
i = 3
ans =  0 + 1i
i = 4
ans =  0 + 1i
i = 5
ans =  0 + 1i


The loop executes 5 times with no error.

What wizardry is this? How did i get its loop value back after being cleared?

Refactor the variable name and it causes an error.


for a = 1:5
  a
  clear
  a
end

gives

a = 1
error: 'a' undefined near line 1, column 24


Now the loop executes only once and ends with an error.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-07-03 mmuetzel StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code