Menu

#10 Inconsistent semantics of Insert procedures

v1.0_(example)
wont-fix
None
5
2018-05-02
2007-01-15
No

In bc-containers-lists-double.adb, the procedures
Insert(L : in out List; Elem : Item)
and
Insert(L : on out List; From_List : in out List)
raise the exception BC.Not_Root if L points to an item that is the successor of some other item. This condition is not tested in the procedures
Insert(L : in out List; Elem : Item; Before: Positive)
and
Insert(L : in out List; From_List : in out List; Before: Positive) .

I surmise, but cannot be sure, that the intention is to avoid surprising side-effects in other lists which share content with L. But I note that there is no attempt to attempt to avoid such side effects in singly linked lists, where they could be detected by testing L.Head.Rep.Count. I also note that the latter two procedures will raise the exception if Before = 1, but not if Before > 1. Surely this semantics is not intended.

For the sake of consistency, I think tests should be added to the latter two procedures, or taken out of the former two. My vote would be to take them out, and advise the user that surprising side effects are a "feature."

Discussion

  • Simon Wright

    Simon Wright - 2007-01-21
    • assigned_to: nobody --> simonjwright
     
  • Simon Wright

    Simon Wright - 2018-05-02
    • status: open --> wont-fix
    • Group: --> v1.0_(example)
     

Log in to post a comment.

MongoDB Logo MongoDB