Menu ▾ ▴

#3002 save() doesn't handle structs correctly

None
closed
nobody
5
1 day ago
2015-08-15
No

If a struct is defined and saved into a file:

defstruct(struct(a,b,c));
s:
[
    new(struct([1,2,3],2,3)),
    new(struct([4,5,5],5,6))
];
save("Test.lisp",s);
s[1]@a;

it can be loaded again within the same maxima session:

kill(s);
load("Test.lisp");
s[1]@a;

If maxima is restarted this doesn't work anymore, though:

load("Test.lisp");
s[1]@a;

in this case returns:

struct([1,2,3],2,3)@a

It seems like the struct isn't defined as a struct via defstruct() and new() but rather treated as a function with the struct elements as argument.

Discussion

  • Gunter Königsmann

    Found out why this did happen for me and documented it with commit #d0b2a1eacb1c2a47ed9bdef86c58bf9bdfc99851.

     
  • Gunter Königsmann

    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2017-10-09
    • labels: --> save, defstruct
    • status: closed --> open
     
  • Robert Dodier

    Robert Dodier - 2017-10-09

    I'm reopening this bug report -- I just bumped into this problem. This is a bug in save -- it should save the structure definition, as it also saves arrays, functions, properties, etc.

    When this bug is fixed, we can remove the text introduced in commit d0b2a1ea.

     
  • Gunter Königsmann

    Thanks a lot! Don't know if there is a way to make maxima forget a struct's definition: That would feel like risking to delete the definition of an already-existing struct. If there is one I would be willing to write a few test cases.

     
  • Robert Dodier

    Robert Dodier - 1 day ago
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 1 day ago

    Fixed by commit a5d1d3e. Closing this ticket.

     

Log in to post a comment.