News for hackers. Stuff that matters.
Re:Will Hare replace C? Or Rust? Or Zig? Or anything else? by extropy on Tuesday May 03, 2022 @09:30AM (#31248060)
Does someone know how the str type works? From lang reference it's pointer/size/capacity struct but none of the examples does any freeing of strings.

What kind of magic is this?

Re:Will Hare replace C? Or Rust? Or Zig? Or anything else? by ddevault on Tuesday May 03, 2022 @09:36AM (#31248119)
Strings are essentially a usage-constrained slice alias. You can pass a string into "free" and it will free the underlying storage. Check out the spec for the full answer:

https://harelang.org/specification.pdf

They are a very lightweight language feature which is mostly supplemented by the standard library, e.g. the strings module.

Re:Will Hare replace C? Or Rust? Or Zig? Or anything else? by sanxiyn on Tuesday May 03, 2022 @09:40AM (#31248164)
Most strings in examples are statically allocated and don't need freeing.

There is an example with freeing of strings in the introduction. Search for strings::freeall.

Re:Will Hare replace C? Or Rust? Or Zig? Or anything else? by rasterdog on Tuesday May 03, 2022 @10:43AM (#31248948)
also there a lot of implementations of "pointer/size/capacity struct" for strings in plain C