4 ms·
One of the fun possibilities is that funcs could be safely turned into a serialized version for sending over the wire etc. Will bagel have a json equivalent?
by kybernetikos 5y ago
One of the fun possibilities is that funcs could be safely turned into a serialized version for sending over the wire etc.
Will bagel have a json equivalent?
- brundolf 5y agoBagel values will fundamentally be JavaScript values, so the same subset of them will naturally translate to JSON 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.
- brundolf 5y agoEdit: Just noticed you said funcs and not func results This isn't really true, since they'll still capture their closures and will definitely be able to reference other constructs like classes, etc
- kybernetikos 5y agoChanging mutable state you've closed over is a side effect, so from your description I assumed that wouldn't be allowed in a function. 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.
- brundolf 5y agoThat's what I mean. Functions can't mutate anything, period- the assignment operator won't even parse, and calls to procedures are forbidden. But they can still close over state that is mutable one other contexts 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