3 ms·
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 w
by throwawaymaths 4y ago
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.
- WorldMaker 4y agoTechnically 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.)
- Dylan16807 4y agoThe mathematical definition of function also rejects all side-effects, so probably not the best thing to use around programming. Call it a routine instead?
- int_19h 4y agoWe had a descriptive yet very generic term for function-like stuff: "subprogram".
- throwawaymaths 4y agoOh man that brings memories: gosub in basic (though I think it was subroutine). Also Pascal had procedures vs functions.