alantech / alan

Autoscalable Programming Language
https://alan-lang.org
MIT License
305 stars 10 forks source link

Buffer methods #790

Closed dfellis closed 1 month ago

dfellis commented 1 month ago

Forgot these in the first set of issues I created for myself. The Buffer type also needs many similar methods as the Array type.

The functions desired for a first v0.2.0 are:

You'll note that filter and delete are missing from this list. That's because they would produce a new buffer of an unknowable length at compile time (technically delete could work, but I don't know if that should be encouraged, since it basically requires allocating a new buffer and copying the other values over, which is problematic for very large buffers).

dfellis commented 1 month ago

repeat can't really be done, because the return type is based on the value passed into function at runtime. I can have the multiple in the generic type list and do it that way without a second arg, but then type inference doesn't work anymore (no such thing as partial type inference, and I'm not sure if I want to have it, because then you also need to have some ability to guess which type the provided value belongs to).

So I'm thinking about what exactly to do here, and maybe, for now, repeat converts the buffer into an array.