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

A Show Class #1

Closed
orangeduck opened this issue Jul 18, 2012 · 3 comments
Closed

A Show Class #1

orangeduck opened this issue Jul 18, 2012 · 3 comments

Comments

@orangeduck
Copy link
Owner

I've thought about this in various ways and implementing a "Show" class, essentially a class for converting objects to strings, is really a pain.

First of all issues is memory allocation. We could have objects allocate their own memory for the strings they return. Or have them put their data in some previously allocated block (in which case how big is the block?). Both have downsides but self allocation of memory is perhaps best as although it introduces a "policy" overhead, the fact it adds a performance overhead isn't so important.

Secondly is the fact that I would wish for an Show class to be printf friendly. More specifically I would want it to act like python string formatting. If the string contains a %f then the system automatically attempts to call the "as_double" function upon whichever object it is being passed.

Perhaps the way to solve this is to extract the formatting functionality into a separate body.

Either way, unfortunately I can't see an easy way of doing any of this without basically reimplementing the whole of the printf stack. Ouch.

@rrichardson
Copy link

With Pattern Matching, re-implementing show/printf can become a lot more tractable. Yea, memory management is a bit of an issue, but a memory pool that is tied to a function can make it simpler. Sort of a poor man's region based memory management.

@orangeduck
Copy link
Owner Author

I think I generally understand what you mean, but could you elaborate and be more specific?

@orangeduck
Copy link
Owner Author

This has been added in most recent updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants