Currently if you want to create a list it is necessary to use instructions. It would be nice if lists could be built with expressions (which would not modify the original list, but make a partial or linked copy). With the basic instructions prepend (append an item to the beginning), and rest (take all but the first item) it would be theoretically possible to derived all the others, however it would be nice to have the following:

  • prepend - add an item to the beginning
  • append - add an item to the end
  • concat - join to lists
  • take n - takes the first n items
  • skip n - returns a list with all but the first n items
  • span start end - Like substring but for lists, returns items from start through end

.Net has native support for these concepts, and relatively efficient implementations with Enumerable, Span, and the System.Collections.Immutable package. To make this optimized all expressions should return immutable list types, and they should only be converted to mutable types when assigned to a list variable (so that the list instructions can still do their thing). However it might also be worth completely switching to immutable lists and simply updating the _list field of the ExpressionResult instance for the variable since the current implementation is a source of bugs.

Suggestion Submitted

2 Comments

  • Log in to leave a comment
  • Profile image
    Mod sflanker

    @SFSspacex good luck with that. You know the moderators are all volunteers right?

    4.2 years ago
  • Profile image
    Mod sflanker

    @SFSspacex whether or not you like me is not relevant. As a moderator my job is to enforce the rules. If you violate the rules with your posts or comments I will remove them. If you persist I after being warned I will ban you. I don't do this because I enjoy it, I don't, I do it because the rules are there to help make the community safe, constructive, and welcoming. If you don't want to hear from me again that's fine, all you need to do is follow the rules.

    4.2 years ago

1 Upvote

Log in in to upvote this post.