Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37167
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2019-09-01 03:20 -0700 |
| References | <8910e5f0-4fc9-417e-a5c8-1bec8693194a@googlegroups.com> <4c1ea5a9-c407-4752-920e-ec33b756af59@googlegroups.com> |
| Message-ID | <ec9caa3f-68c8-4ac6-b805-e168f86cb0f0@googlegroups.com> (permalink) |
| Subject | Re: Object iterators |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
Den söndag 1 september 2019 kl. 11:53:34 UTC+2 skrev Jonas Thörnvall:
> Den söndag 1 september 2019 kl. 02:12:59 UTC+2 skrev Jonas Thörnvall:
> > Well they probably have their use, but i've been googling on web midi api for some months looking for howto ***set*** inputs iterator to a single port.
> >
> > inputs = mid.inputs.values();
> >
> > for (var input = inputs.next();
> > input && !input.done;
> > input = inputs.next()) {
> > // each time there is a midi message call the onMIDIMessage function
> > input.value.onmidimessage = onMIDIMessage;
> > }
> >
> > I can't find a single example where one set a single input port without looping thru.
> >
> > I do not want to read all inputs port using the iterator, i just want to set one input say port 3.
> >
> >
> > I would prefered the inputs in an indexed array, because i just do not get howto pick a single port from the input object iterator.
>
> Found this....
> ========================
> For the record, the Iterator API does not allow you to do this. There is no notion of a "current" object. The Iterator.next() method gives you the next object ... and moves on.
>
> (The ListIterator.previous() and ListIterator.next() methods are analogous. Note that in the ListIterator case, method behaviour is documented in terms of a cursor that denotes a position before / between / after elements in the sequence being iterated.)
>
> The solution is to assign the result of calling it.next() to a temporary variable, as described by the accepted answer
> ========================
>
> So who implemented this as an object iterator, did i????
> It is not clear to me what does
> //This is the midi object i guess holding input and output ports
> mid = midi;
> //Here it becomes unclear to me WTF is going on?????
> inputs = mid.inputs.values();
> //It seem like we read out inputs values "that apparently is part of the midi //object, it is monkey syntax basicly inputs.values()
>
> But why the fuck they end up in an iterator "inputs?" had it not been more natural to have them end up in an array so you can pick one????
>
> So is it, I that have implemented this as an iterator, or have some deranged little fuck decided that input ports of midi objects are iterators?????
>
> Because that is where my logic breaks down, i guess the inputs are implemented as iterators but why?????
>
> I mean i have no fucking problem to iterate thru an input ports array in a for loop and no problem to set a single one of those to a listener. Using input.
>
> input.value.onmidimessage = onMIDIMessage;
>
> So who the fuck decided that the input ports should be iterators where i can not pick a port because they are not indexed?
>
> If it was me then tell me where the fuck in the code i did it.
> Better yet tell how the fuck to get the ports in an array so i can access them one by one two by two or whatever.
By the way what kind of syntax, is this?
input.value.onmidimessage = onMIDIMessage;
omMIDIMessage is a function, to me it looks like an assigment i assign a function to input.value.onmidimessage?
So is input.value.onmidimessage a listener or is it just onmidimessage that is the listener and input.value the object port?
I mean the syntax is really not clear is it?
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-31 17:12 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-31 17:17 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-08-31 17:24 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 02:53 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 02:59 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 03:07 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 03:20 -0700
Re: Object iterators John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-01 11:59 +0100
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 05:54 -0700
Re: Object iterators John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-02 11:08 +0100
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-01 12:54 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 02:36 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 10:16 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 10:19 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-02 10:30 -0700
Re: Object iterators Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-03 23:26 -0700
Re: Object iterators 1975.nenad@googlemail.com - 2020-05-24 04:21 -0700
csiph-web