rhaiscript / book

The Rhai Book.
https://rhai.rs/book
22 stars 22 forks source link

Document RawEngine packages #26

Closed rm-dr closed 5 months ago

rm-dr commented 5 months ago

I came across a problem today running the following with a raw engine:

let test = [1,2,3];
for s in test {
    print(s);
}

Which resulted in an error "For loop expects iterable type". This was caused by my raw engine being loaded without BasicArrayPackage.

This should probably be documented in the "Raw Engine" section, since the error here gives no hint as to what is wrong. A list of the features each Basic*Package enables would be nice.

schungx commented 5 months ago

Actually you can load the iterator yourself... It is just one call to set_iterable...

schungx commented 5 months ago

But maybe a better idea is to move the iterators out of the packages into builtin.

schungx commented 5 months ago

I have decided to solve this by duplicating the iterator registrations into both the iterators package as well as the regular packages.