You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: