Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39923

Re: I don't get it

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: I don't get it
Date 2021-04-13 20:06 +0100
Organization A noiseless patient Spider
Message-ID <87blaim2c4.fsf@bsb.me.uk> (permalink)
References (16 earlier) <845c8b8e-d415-4b41-8327-6b31bc50825an@googlegroups.com> <1ae0aa1d-162d-4666-acf9-50376e1acd9fn@googlegroups.com> <8090782c-7564-4881-a97e-70dd1e865674n@googlegroups.com> <87y2dmmgln.fsf@bsb.me.uk> <4121e04d-bef4-4cf9-a047-542daa2bf2b8n@googlegroups.com>

Show all headers | View raw


Jonas Thörnvall <jonas.thornvall@gmail.com> writes:

> tisdag 13 april 2021 kl. 15:58:19 UTC+2 skrev Ben Bacarisse:
>> Jonas Thörnvall <jonas.t...@gmail.com> writes: 
>> 
>> > måndag 12 april 2021 kl. 23:32:18 UTC+2 skrev sc...@sauyet.com: 
>> >> Jonas Thörnvall wrote: 
>> >> > Ben Bacarisse wrote: 
>> >> 
>> >> >> Your code is unmanagable. Almost any part of it can alter the behaviour 
>> >> >> of any other part. You might be sure what parts do what (though your 
>> >> >> repeated requests for help suggest you probably no longer know what the 
>> >> >> code is doing) but other people will find it almost impossible. 
>> >> >> 
>> >> >> Your best bet is to re-write it step by step making sure that functions 
>> >> >> are genuinely self-contained actions. Not only will the result be 
>> >> >> easier to modify, you will probably find the problem on your own. 
>> >> > You are dreaming Ben it is a single function with ten lines of code 
>> >> > and just two global arrays. 
>> >> The first three lines of this single "function" are 
>> >> | function STARTPLAY(){ 
>> >> | if (keepGoing) { 
>> >> | stopRec=setTimeout(STARTPLAY,copyEv[playPos]); 
>> >> We have four free variables used here: `keepGoing`, `stopRec`, `copyEv`, 
>> >> and `playPos`. There are at least ten more in the remainder of the 
>> >> snippet you passed. 
>> >> 
>> >> This is horrible. 
>> >> 
>> >> Ben was, if anything, too kind. 
>> >>
>> > Well those can't possibly effect anything going on in recursion of 
>> > function, not even the understaning of it.
>> Even you can't understand it. 
>> 
>> You are arguing with people who have, I suspect, many decades more 
>> experience than you do in debugging horrid code. The advice to write it 
>> properly is not given flippantly. It is by far the best course of 
>> action.
>> > function STARTPLAY(){ 
>> > if (keepGoing) { 
>> > setTimeout(STARTPLAY,copyEv[playPos]); 
>> > REALTIME=performance.now()-browserLoadTIME; 
>> > LATENCY=REALTIME-oldPassedTime; 
>> > oldPassedTime=schedTime; 
>> > schedTime=copyEv[playPos]+schedTime; 
>> > copyEv[playPos]=Math.max(0,copyEv[playPos]-LATENCY); 
>> > outportarr[outportindex].send(noteMessage[playPos]); 
>> > playPos++; 
>> > } 
>> > } 
>> > https://jonasth.github.io/ 
>> 
>> > What is so hard to understand about function nothing, the hard thing 
>> > is to understand why it does not work.
>> If it's easy to understand, why don't you know what it's doing? 
>> 
>> You need to ditch this distinction between understanding it and 
>> understanding why it does not work because they are the same thing. 
>> This is about the first step every programming student has to take. You 
>> must stop thinking you know what you wrote. The function is doing 
>> exactly what you wrote. If that's not what you want or need, then you 
>> need to understand it better. Other people may be able to help, but I, 
>> for one, am not going to try unless you put some effort into writing it 
>> properly. 
>> 
>> You are, I think, doing this for fun, yes? If it remains fun to be 
>> puzzling out what's going on, then you really don't need any help. Just 
>> keep going as you are. But if the fun comes from getting things to 
>> work, then learning how to program will be a huge benefit. There is, 
>> usually, much more fun to be had from productive coding than poking 
>> about in a mess you don't quite follow. 
>> 
> I understand the code, not how the recursion effect it...

Recursion and non-local variables don't mix well.  You know what my
advice would be.

> You see one cannot look into a blackbox, you can learn how it behave
> and that is why i ask you people, what is going on?  Because i am
> clueless about what the recursion do to it. I probably could and
> should do an iterative solution, but i want to know what is going on.

I wish you well.

-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 03:32 -0700
  Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 03:37 -0700
    Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 04:26 -0700
      Re: I don't get it JJ <jj4public@gmail.com> - 2021-04-08 19:39 +0700
        Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 05:53 -0700
          Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 13:55 -0700
            Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 00:46 -0700
              Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-09 10:03 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 04:09 -0700
                Re: I don't get it "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-04-09 11:07 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-10 03:23 +0100
                Re: I don't get it "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-04-10 22:02 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-11 01:05 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-11 01:07 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-11 11:42 +0100
                Re: I don't get it John G Harris <niam@jghnorth.org.uk.invalid> - 2021-04-09 20:01 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 13:31 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-10 03:37 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 23:53 -0700
                Re: I don't get it John G Harris <niam@jghnorth.org.uk.invalid> - 2021-04-10 12:05 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-10 15:59 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-10 15:47 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-10 18:25 +0100
                Re: I don't get it Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-04-10 17:29 +0000
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-10 19:08 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-11 11:41 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-11 14:33 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-12 02:39 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-12 11:21 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-12 10:19 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-12 21:20 +0100
                Re: I don't get it "sc...@sauyet.com" <scott@sauyet.com> - 2021-04-12 14:32 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 04:11 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-13 14:58 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 09:20 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 09:29 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-13 20:06 +0100
                Re: I don't get it "sc...@sauyet.com" <scott@sauyet.com> - 2021-04-13 15:09 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-14 01:15 -0700
                Re: I don't get it "sc...@sauyet.com" <scott@sauyet.com> - 2021-04-14 05:22 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-15 11:52 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-15 11:57 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-15 12:04 -0700
                Re: I don't get it Scott Sauyet <scott.sauyet@gmail.com> - 2021-04-15 19:29 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-20 14:12 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-20 14:47 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-20 23:35 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-21 01:08 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-21 01:24 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-21 01:29 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 09:32 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-13 21:59 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 01:32 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-14 09:08 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 10:06 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-14 10:59 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 14:05 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-14 16:32 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 23:53 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-15 13:56 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-12 11:20 +0100
        Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-08 15:21 +0100
          Re: I don't get it Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-04-09 16:50 +0200
  Re: I don't get it Man From a city with name Viljandi <he12457@hotmail.com> - 2021-04-08 10:44 -0700
  Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-10 00:01 -0700

csiph-web