Laythe-lang / Laythe

A gradually typed language originally based on the crafting interpreters series
MIT License
65 stars 4 forks source link

Laythe native list #151

Closed jonnyboyC closed 1 month ago

jonnyboyC commented 1 month ago

Problem

Our existing list implementation using Vec under the hood. This causes several issues with the long term health of the system.

Additionally we'll want to eventually do similar with Map and to do that we'll need a collection which is GC managed.

Solution

Create a new container GcList which is a resizable array. Like GcArray it contains it's header and length information inline with it's data. Additionally GcList contains a capacity field.

When an operation like push is applied to GcList that would requires a a resize the following occurs

RIght now in the case of multiple resizes we would need to go through multiple pointers to get to do data which defeats the directness advantage. I'll follow up this PR with another we we introduce a mechanism for a native function to signal for an argument to be changed.