[haXe] Re: Xml.attributes() and Iterable

Asger Ottar Alstrup asger at area9.dk
Mon Jan 29 12:04:09 CET 2007


Sorry, I accidentally clicked Send before the mail was complete.

On 1/29/07, Asger Ottar Alstrup <asger at area9.dk> wrote:
>
> Hi,
>
> I'm trying to compile with haxe 1.11, but I get this error:
>
> Running process: C:\Program Files\Motion-Twin\haxe\haxe.exe conceive.hxml
> ..\..\..\bohr\source\shared/TopicDataSerializer.hx:275: characters 14-168
> : Iterator<String> should be Iterable<Unknown<0>>
> ..\..\..\bohr\source\shared/TopicDataSerializer.hx:275: characters 14-168
> : { next : Void -> String, hasNext : Void -> Bool } should be
> Iterable<Unknown<0>>
> ..\..\..\bohr\source\shared/TopicDataSerializer.hx:275: characters 14-168
> : { next : Void -> String, hasNext : Void -> Bool } should be { iterator :
> Void -> Iterator<Unknown<0>> }
> ..\..\..\bohr\source\shared/TopicDataSerializer.hx:275: characters 14-168
> : { next : Void -> String, hasNext : Void -> Bool } has no field iterator
> ..\..\..\bohr\source\shared/TopicDataSerializer.hx:275: characters 14-168
> : For function argument 'it'
>
> and the code looks like this:
>
>
>         var attrs = Lambda.fold(node.attributes(), function (a: String,
> arr: Array<TopicContent>) { if ("id" != a) arr.push({name: a, value:
> node.get(a)}); return arr; }, []);
>         var features = Lambda.fold(node.elements(), more stuff);
>
> Now, I can change this to
>
>         var iterable = function(it) {
>             return { iterator : function() { return it; } }
>         };
>         var attrs = Lambda.fold(iterable(node.attributes()), function (a:
> String, arr: Array<TopicContent>) { if ("id" != a) arr.push({name: a,
> value: node.get(a)}); return arr; }, []);
>         var features = Lambda.fold(node, more stuff);


but this is tiresome, since I need to do this many, many places in my code.

The question is:

Shouldn't iterable at least be part of the standard library since so many
methods return an iterator, or alternatively, change the APIs to be Iterable
instead of Iterators?

Regards,
Asger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070129/46a66203/attachment.htm


More information about the Haxe mailing list