You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commit 0e34cc3 adds support for parsing JSON documents without the need to allocate intermediate Json values. Unfortunately this API exposes a new problem: Inko's lack of uninitialized/partially initialized memory means you have to allocate some sort of dummy value, then update that in-place or overwrite it with the parsed data. In other words, you end up with something like this:
let val = Something(
location: Location.default,
...
)
try parser
.object
.key('location', fn { Location.parse(parser).map(fn (v) { val.location = v }) })
.require_all
Here the initial Location is redundant, given require_all requires a value to be parsed from the input stream.
Since closures capture by value (such that they can outlive their stack frames), you can't use a bunch of local variables of type Option[Whatever] either, as the assignment isn't visible outside the closure. Even if it was, you're still creating a bunch of Option values followed by a redundant "is it in fact a Some and not a None?" check after the require_all.
We'll need something better that doesn't suffer from these issues.
The text was updated successfully, but these errors were encountered:
Commit 0e34cc3 adds support for parsing JSON documents without the need to allocate intermediate
Json
values. Unfortunately this API exposes a new problem: Inko's lack of uninitialized/partially initialized memory means you have to allocate some sort of dummy value, then update that in-place or overwrite it with the parsed data. In other words, you end up with something like this:Here the initial
Location
is redundant, givenrequire_all
requires a value to be parsed from the input stream.Since closures capture by value (such that they can outlive their stack frames), you can't use a bunch of local variables of type
Option[Whatever]
either, as the assignment isn't visible outside the closure. Even if it was, you're still creating a bunch ofOption
values followed by a redundant "is it in fact aSome
and not aNone
?" check after therequire_all
.We'll need something better that doesn't suffer from these issues.
The text was updated successfully, but these errors were encountered: