![]() ![]() and they work by basically requesting the next computation result, which also avoids creating a new table with all results, when the user may be interested only in the first result, here is some pseudo code example: print(split('hello world, and salam in arabic!')) Slices are also very cheap and small tables to copy and pass around, unlike copying or creating a new big table just to return one of the portions of the existing table.Īn iterator or a generator is very useful as it allows a declarative functional approach into computation and transforming data but its also useful to save on resources, since iterators are usually lazy which means that you only pay for what you want although they come with some overhead for each iteration. ![]() ![]() And slices also give the property that if you modify the table directly or through one of its slices, the table and overlapping slices also see the changes, since it doesn’t have a copy of the table, merely a reference to it. it does exist in lua’s standard library but in its naked form table.fn(t, i, j). A slice is very useful when you want to pass or receive only a portion of a table, a view into a table (without ownership of the table) without having to copy the table or construct a new one. Rust and Zig have slices, C++ have views.Ī slice or a fat pointer in lua’s terms is basically a table with a start index and an end index.So luau is far behind by ages in terms of modern programming techniques. Luau’s standard libary is raw and minimal, unlike other programming languages like Rust and Zig’s standard library and C++'s STL. Publishing this library is very early but I’d like to get as much feedback and possibly contributions Codotaku Luau Library I would gladly accept contributions on github or here on the devforum. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |