Follow

Rust protip: if you have cyclic data, have you considered not having cyclic data?

oh wait you need it? uhh... uhhhhhh

· · Web · 5 · 2 · 10

@hazel galaxy braining my memory model so hard that implementing a ring buffer becomes illegal in my language

@dankwraith @hazel nah it's not a ring buffer it's a uhhhh tape with wraparound read-write semantics ✨

@dankwraith @hazel couldn't you just impl a ringbuffer as a vec + two usizes for the start and end

@dankwraith @hazel pedantic correction, a Vec<Option<T>> (or if we're allergic to malloc and know size at comp, a [Option<T>; N])

@hazel looks like you've been thinking about this type of problem for a while, so I'll ask: have you looked at GhostCell? It falls into the "make an allocator but pretend you aren't" space, which I see you've identified at a pervasive pattern with Rust. But it does make "thicket of stuff pointing into stuff" a lot easier to work with. (Although it's not completely without friction, e.g., hard to move things out of a graph when your graph handles are all &mut references.)

Sign in to participate in the conversation
types.pl

A Mastodon instance for programming language theorists and mathematicians. Or just anyone who wants to hang out.