Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1937 string iterator suffix #1938

Merged
merged 2 commits into from
Jan 27, 2017

Commits on Jan 22, 2017

  1. Fixes KSP-KOS#1937 - by adding :ITERATOR suffix to string.

    Note, when I tested this I noticed that although
    the FOR loop now works, the :RESET suffix of the
    iterator you get from String:ITERATOR doesn't work.
    
    :RESET throws a System.NotSupportedException.
    
    When I looked in to why, I tried comparing it to some of the
    other iterators for Queue, List, and so on.  **Many of them
    give the same error**, but our docs mention being able to
    do a RESET of an Iterator.  I didn't check which types don't
    implement it but several of ours don't.  Our documentation
    is wrong.  I made a quick edit so at least the docs aren't
    lying, but it should be addressed better in a future issue.
    The iterators we are using have no RESET on them.  The suffix
    exists, but it points to a method under the hood that's not
    there.
    
    (Basically, our iterators implement C#'s IEnumerator,
    but apparently IEnumerator has a method called Reset()
    that you are guaranteed the compiler will allow you try
    calling even though IEnumerator isn't required to
    actually be implemented in classes that claim to implement
    IEnumerator.  This seems to hint at the existence of
    something I've never heard of before in C# - an interface
    method you aren't required to implement because there's
    some kind of default base behavior when you don't.  (Isn't
    that by defintion an Abstract Class instead of an Interface
    then if it has some implemented and some not implemented
    methods?))
    Dunbaratu committed Jan 22, 2017
    Configuration menu
    Copy the full SHA
    e230351 View commit details
    Browse the repository at this point in the history
  2. ITERATOR:RESET not supported anymore.

    I found out that we had to remove the :RESET suffix entirely
    because the way the new collections structures we have
    no longer actually support rewinding the enumerators:
    
    When we went with the newer collections style, there
    was a revamp to go through all of them and change how
    they returned ITERATORS.  Instead of returning a hand-made
    IEnumerator, the technique was changed to the one where you
    let C# magically create an IEnumerator<fooType> out of
    a single method where all it does a yield return <fooType>.
    
    Apparently this technique causes it to build an IEnumerator
    in which the .Reset() method has been defined as just
    
    public void Reset()
    {
       throw new System.NotSupportedException().
    }
    
    So this part of our docs have been lying ever since we made that
    change.  The RESET was never implemented an never worked ever
    since then.
    Dunbaratu committed Jan 22, 2017
    Configuration menu
    Copy the full SHA
    bc48c0b View commit details
    Browse the repository at this point in the history