orangeduck / BuildYourOwnLisp

Learn C and build your own programming language in under 1000 lines of code!
http://www.buildyourownlisp.com/
Other
2.9k stars 394 forks source link

fix control reaching end of non-void function #101

Closed keyboard-k closed 8 years ago

keyboard-k commented 8 years ago

Is there any specific reason for giving the example how you have given it before ?

orangeduck commented 8 years ago

No real reason why I wrote it like this except for clarity. The control flow is actually unambiguous in this case because we don't expect to receive negative numbers for the number of children - but of course the compiler doesn't know this.

I think your PR actually changes the behaviour of the algorithm to make it incorrect. You switch a >= to a >. I think the correct thing to do is to just add a return 0 at the end of the function.

keyboard-k commented 8 years ago

Okay, doing it and checking it :smile: Hold on.

keyboard-k commented 8 years ago

Alright done. :grin:

keyboard-k commented 8 years ago

hmm... it does makes sense now .

orangeduck commented 8 years ago

Great - Thanks!

keyboard-k commented 8 years ago

No, thank you for writing this amazing book ! :grinning: Everyone should read this and make their own lispy. It helps so much in understanding in other computer languages too.

orangeduck commented 8 years ago

Thanks! :+1: