HEnquist / camillagui

GNU General Public License v3.0
9 stars 1 forks source link

undefined instead of null? #83

Closed JWahle closed 1 year ago

JWahle commented 1 year ago

I just noticed, that in the next20 default values in configs are expressed through null values. Have you considered using undefined instead? Variables with value undefined will be omitted when serializing to JSON, so default values could be omitted from the config, when saved. Also, it is a general recommendation to use only undefined in JavaScript/TypeScript and not use null - so just use one concept of nothingness and stick to it.

HEnquist commented 1 year ago

Yes I considered this. Things get complicated by the fact that json and yaml only have null. A missing value is deserialized to undefined in JS, but other deserializers may return something else. Camilladsp deserializes both missing values and null to the Rust value None. And when serializing all Nones become nulls. Changing this is possible, but it means that the standard Option type in Rust can't be used, and requires writing a custom (de)serializer. Not very tempting!

JWahle commented 1 year ago

Ok, makes sense.