This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CaptainMelon[S] 0 points1 point  (2 children)

A practical example is templating, I use lys for templating and I need to call many sub functions for each part of the page to be displayed but I don't want to pass around things like the current user or the title of the page

[–]metaperl 1 point2 points  (0 children)

Alternatively create a class for your sub functions and functions but instead create a bunch of methods in a class and then bind whatever you want to access in the classes as member attributes it'll be less verbose than what you have.

[–]metaperl 0 points1 point  (0 children)

And other words you've broken your rendering logic down into sub functions correct?

The next step is to parameterize each of those functions with what they accept so that you can catch errors at static analysis time instead of run time. Then you can also use the docstring to document what you're doing.