Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor %c into generic cached computation functionality #15

Closed
rpetrich opened this issue Nov 2, 2011 · 1 comment
Closed

Refactor %c into generic cached computation functionality #15

rpetrich opened this issue Nov 2, 2011 · 1 comment

Comments

@rpetrich
Copy link
Contributor

rpetrich commented Nov 2, 2011

It should be possible to pass arbitrary expressions into a logos macro and have it dedupe and cache them.
Existing %c(classname) expressions could be converted to use this functionality internally.
Additionally, components within theos itself could use this functionality to trim some of the work they perform (would use this for my internal generator)

Proposed syntax:
%cached(x) yields a C rvalue that references the result of the computation x as executed from inside %init; (or the automatically generated initializer if none exists)

Potential extensions:
Nested cached expressions could be supported to eliminate duplicate work inside of cached expressions themselves. Further, cached expressions that are used only as a subexpression of other cached expressions could be optimized not to escape the scope of %init
Lazy initialization via alternate syntax (with/without thread safety?). Would allow syntax like this to workaround glacial apis:
%cached([[[NSCharacterSet characterSetWithCharactersInString:@"_1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"] invertedSet] retain], lazy)

@DHowett
Copy link
Contributor

DHowett commented Sep 16, 2013

Wrapped into #60.

@DHowett DHowett closed this as completed Sep 16, 2013
@uroboro uroboro transferred this issue from theos/theos Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants