3 ms·
> In PHP now when you define a function, and then call that function; it may or may not execute the code inside that function, depending on whether later on in
by wvenable 14y ago
> In PHP now when you define a function, and then call that function; it may or may not execute the code inside that function, depending on whether later on in the function there's a `yield` keyword. That's insane!
It's exactly how it works in C# and Python. When you call a function, you don't care how it does what it does -- only that it returns a result. The syntax and design works this way in all sorts of languages because it's easier to reason about. I've only used generators in C# but it's amazingly simple to use. The point of an abstraction is that it hides the details. You're overly concerned with the details that are neatly and logically hidden away.