3 ms·
> And here’s the kicker. All of these functions did the same thing as the method. My only question is if you have function x, y and z, how do you restrict func
by DeathArrow 2y ago
> And here’s the kicker. All of these functions did the same thing as the method.
My only question is if you have function x, y and z, how do you restrict function z so it can only be called from function x, but not from function y? If you have classes you can use access modifiers.
- freilanzer 2y agoWhy do you want that if there is no state involved?
- ninetyninenine 2y agoExactly. These functions are stateless and thus calling the functions ultimately doesn’t really do anything.
- DeathArrow 2y agoI wasn't referring to a pure functional context. I was thinking of a context where you have functions and procedures but no objects.
- freilanzer 2y agoYou can still have modules, for example. They're a way of grouping functions and types.
- ninetyninenine 2y agoYou don’t need to restrict functions. You can still organize functions into groups via libraries or modules. But ultimately that’s just aesthetics. ModulaA.funcA ModuleB.funcB FuncA cannot be called from ModuleB. This restriction is possible in terms of organizing code but you can see it’s just naming and ultimately has no effect outside of aesthetic appeal.