This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Support Iterable in for-each
- From: Matthieu Vachon <matthieu dot o dot vachon at gmail dot com>
- To: "kawa at sourceware dot org" <kawa at sourceware dot org>
- Date: Fri, 10 Jan 2014 13:45:02 -0500
- Subject: Support Iterable in for-each
- Authentication-results: sourceware.org; auth=none
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