Hacker News new | past | comments | ask | show | jobs | submit login

Well maybe it's my small brain but I remember in math class it was very important that "a function has only one return value", which probably is part of why I was confused.



Technically generators still only have one return value: an Iterable. That Iterable represents an object with a "next()" callback and you can entirely write by hand Iterables as simple dumb objects if you like. (The generator function syntax makes it a lot easier to build complex state machines, but most languages aren't going to stop you if you prefer to write your state machine by hand.)


The mathematical definition of function also rejects all side-effects, so probably not the best thing to use around programming.

Call it a routine instead?


We had a descriptive yet very generic term for function-like stuff: "subprogram".


Oh man that brings memories: gosub in basic (though I think it was subroutine). Also Pascal had procedures vs functions.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: