Support Iterable in for-each

Matthieu Vachon matthieu.o.vachon@gmail.com
Fri Jan 10 18:45:00 GMT 2014


Hi Per,

I was wondering if you think it would be possible for the `for-each`
methods and friends to accept directly a Java `Iterable` object.

That would greatly ease Java usage since it would not be necessary in
a lot of cases to transform an `Iterable` to a native list. However, I
fear that it would not be that easy because maybe a lot of stuff
relies on car/cdr.

But we could make them compatible with `Iterable` though, where `car`
returns first element from `Iterable` object and `cdr` returns an
`Iterable` representing the rest elements and for a single element
list, returns maybe an empty `Iterable`. But this would implies some
more logic changes on `null?` and maybe other methods so it's possibly
far-fetched and potentially a BC break (I don't think so but it may be
the case).

Of course, I could have my specialized function of `for-each` and like
to do the job, but I think having "native" support if possible is
always better.

Had you had some thoughts on this subject before?

Regards,
Matt



More information about the Kawa mailing list