-
Notifications
You must be signed in to change notification settings - Fork 194
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
Debug print (toString
/ str
/ to_s
/ repr
/ inspect
/ etc) implementations
#299
Comments
Just for the record, @KOLANICH pioneered Python |
Just a random thought.... On my project (and, I've heard others mention it as well), our principal use of KS is to convert a binary data structure into a JSON representation. To accomplish this, we use KS to read the binary, and then we use a second layer of code (also generated from the KSY file) to call the KSC-generated code to complete the transposition. It would be quite handy if the mechanism proposed here could produce JSON (or a JSON-formatted string). That would obviate a huge chunk of infrastructure that I've had to create to close this gap in a general way. |
@webbnh Actually, that might be a good idea as well. Probably this one is relatively bulky and not required by many, but it's easy to generate similar |
From where I stand, there's not much difference between If you think the generation of the latter should be controlled by a compiler switch, I would think the generation of the former would want the same. (I mean, |
@webbnh Actually, you're right, it might be a good idea to make both I don't think that we have the user to choose between these two. |
Currently, the classes we generate are not very string conversion friendly. Many languages feature some kind of debugging print aid (like
toString()
orrepr
or stuff like that) that allows us to customize what would be printed out during to string conversion of an object.From bird's eye perspective, there are two major variations of that feature:
toString
-like method that would print outKaitaiStruct
that would achieve the same using reflectionDoing that should probably make debugging print much easier for all languages. Right now only Ruby and, to some extent, JavaScript, does sane debug printing.
The text was updated successfully, but these errors were encountered: