class Foo {
get prop1() {
this.state = Math.random();
return this.state;
}
}
console.log(myFoo.prop1)
console.log(myFoo.prop1) // different!
So I think the func/proc distinction will line up really nicely with classes as containers of state. And, as in other cases, pure functions will be able to access properties and call pure functions on class instances, just not call their proceduresOther things I'm going to try out with classes are getting rid of inheritance, and adding a publicly-readable-but-privately-writable access modifier for properties
Will bagel have a json equivalent?
With that said I hope to give stronger typing to what's allowed to be converted to JSON, since JavaScript's serialization will happily eat up class instances (losing class information), dates (silently converting them to strings), undefined, etc.
This isn't really true, since they'll still capture their closures and will definitely be able to reference other constructs like classes, etc
Or are you talking about reading mutable state you've closed over where you're still a pure function (just with hidden arguments) but the environment might change and you can't send that over the wire.
The full implications of allowing this in closures have yet to be explored and I still need to make sure they won't break the guarantees I'm wanting to offer
Or is the "possibly nominal types" bullet an indication that you don't plan to have things that can have members at all?