SpryFox / DarkConfig

DarkConfig is a configuration library for games which supports fast and expressive iteration
Other
151 stars 19 forks source link

PostDoc should work similarly to FromDoc #9

Closed grahamboree closed 7 years ago

grahamboree commented 7 years ago

Currently PostDoc needs to be a public Func that's set on an instance of an object like so:

class Ship {
    public System.Func<Ship, Ship> PostDoc = (d) => {
        // ...
        return d;
    };
}

whereas FromDoc is a public static method that operates similarly:

class Ship {
    public static Ship FromDoc(Ship existing, DocNode doc) {
        // ...
        return existing;
    }
}

There's a few issues with the PostDoc style:

With these considerations, I think it seems to make sense to author PostDoc like FromDoc:

class Ship {
    public Ship PostDoc(Ship existing) {
        // ...
        return existing;
    };
}
rdw commented 7 years ago

+1

I think it's really only used in the demo, as currently written.