MerlinofMines / EasyCommands

Github Repository for Ingame Scripts built by MerlinofMines. Uses MDK to Deploy to SpaceEngineerse
GNU General Public License v3.0
8 stars 3 forks source link

[Bug] Unable to remove string values from list #238

Open MerlinofMines opened 2 years ago

MerlinofMines commented 2 years ago

Describe the bug Currently it's not possible to remove string values from a list, as the string values are interpreted as keys vs values.

To Reproduce set myList to ["one","two"] myList -= ["one"] print myList

Expected behavior "one" value is removed from the list. Today it does nothing, as it looks for a "one" key, doesn't find it, and then returns the original llist.

Additional context I think a major issue here is an inability to declare whether you are trying to operate on keys or on values. Additionally, it may be time to consider separating lists and dictionaries more strongly.

MerlinofMines commented 2 years ago

I think i like the idea of {} for dictionaries and [] for lists. This would be similar to python, though I think I like "->" as the key separator vs ":", which is already overloaded.

jgersti commented 2 years ago

Sounds good and would remove atleast one of my problems when replacing the ListProcessor with a conventional rule. One stumbling block might be the MultiListProcessor when someone wants to immediatly access a dict.

Print {"a" -> 0, "b" -> 1, "c" -> 2 }["b", "c"]
# should print "[0,1]"
jgersti commented 2 years ago

I did start to implement a seperation of KeyedList into a dictionary and a list. While doing that i noticed that the actual expected/implemented behaviour is removal by index/key.

Print reverse (0...3) - 1
# [3,1,0]

To make the example given in the issue report work would necessitate a change of the current behaviour.