-
Notifications
You must be signed in to change notification settings - Fork 49
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
add overloaded print functions for debugging #167
Comments
Would also be cool if there was a type-safe format macro like the one in Rust for example. Or how printf works in OCaml. |
Yes, rusts |
If I remember correctly. Printf in ocaml is much like printf or like rusts print macros. Except that I think it's built in to the compiler to type check at compile time (and probably more optimized than C printf). In dale we should be able to implement this as a library instead of in the compiler. |
In rust this is implemented using the traits for normal printing and debug printing. In dale implementing a concept for printing would be similar, but since concepts cannot be implemented automatically (yet?), so something like my version is more usable, maybe with some compile time checking for existance. |
Format strings are nice sometimes. For example if the variable names are very long it is easier to see the format of the string to get a sense of what it will look like. And then you just gotta make sure the order is right etc. But yeah. I think both should be offered. |
something like |
Yeah I'm all for that kind of feature. But still it doesn't solve the issue that the variable names that you are interpolating might be really long. So you might wanna have the option of using safe format strings. |
I'm currently writing this, it already seems nice
Here some example usage
https://github.com/porky11/dale/blob/print/modules/print.dt#L88
it's similar to c++ stream operator<< but looks better, and also returns the printed value like lisp (this will be done as macro, so this won't become inefficient)
The text was updated successfully, but these errors were encountered: