Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39449
| Path | csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Understanding recursive code |
| Date | Wed, 10 Feb 2021 11:19:52 +0000 |
| Organization | A noiseless patient Spider |
| Lines | 30 |
| Message-ID | <87tuqkgofb.fsf@bsb.me.uk> (permalink) |
| References | <fb7855df-e736-40db-b184-8621c13f4d1bn@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | reader02.eternal-september.org; posting-host="1cf95790cca243eb5e1e6b17078f9ce0"; logging-data="29100"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OP8MuWChx4hrkayw3M3b7iNIDItFkh/o=" |
| Cancel-Lock | sha1:MG186mnWhyixpLXhVSNSHKXUgyA= sha1:9YNle6e+WSs6fhjWwwvEm2nN6M8= |
| X-BSB-Auth | 1.b955c04490cc26b89233.20210210111952GMT.87tuqkgofb.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:39449 |
Show key headers only | View raw
Jonas Thörnvall <jonas.thornvall@gmail.com> writes: > I had a look at my own recursive code, and realised i am not sure i > get what actually break my recursion. Could someone explain. What you have posted is not a complete example. First, I have to guess what the call is that you are debugging. I've assumed it's evalPrimary(calcSTR); Second, the code references undefined variables. For example, 'evaluation' is used in conditional tests but is never set. That's not the only case of using undefined variables, but it's the most obvious. Third, the almost exclusive use of global rather than local variables makes it almost impossible for me to reason about what the code is doing. Every function call could, until I can prove otherwise, change almost every variable referenced in the calling function. I last debugged such a program when I stopped being a research assistant helping non-programmers using FORTRAN IV. That was in 1979. I don't want to start again. It's a grim job. I know you will want to just plough on, hammering the code into shape, but if you were a student of mine I would insist that you start again with a well thought out high-level plan which can be written in code without a single global variable. <snip code> -- Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Understanding recursive code Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-10 01:36 -0800
Re: Understanding recursive code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-02-10 11:19 +0000
Re: Understanding recursive code Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-10 05:19 -0800
Re: Understanding recursive code John G Harris <niam@jghnorth.org.uk.invalid> - 2021-02-10 18:01 +0000
csiph-web