www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D3 printing api should get some attention

reply monkyyy <crazymonkyyy gmail.com> writes:
printf sux and walters worried about optimizing it rather then 
api clarity

I use print statements for debugging and debugging sux, every 
little bit of syntax sugar should be used because its temp code 
99% of the time

So there should be several templated to hell and back print 
functions, without the slightest care about speed

----

`println` => assumes the first argument is a string and replaces 
% with the rest of the arguments `println("hello %, today is 
%.","bob",days.monday);` "hello bob, today is monday"

`debugln` => prints with line number and file `"foo".debug`=> 
"(fizzbuzz/bar.d:1)foo"

`formatln` => prints as if it was a excel doc, elements that are 
to long get shortened, pads the length of small numbers etc. 
`formatln(vec2(1000,1),"hello world")=> "x:  1000|y:     1|"hello 
w...| "

etc.

~~give me yummy yummy sugar~~
Jul 14
next sibling parent monkyyy <crazymonkyyy gmail.com> writes:
On Sunday, 14 July 2024 at 17:54:05 UTC, monkyyy wrote:
 `formatln` => prints as if it was a excel doc, elements that 
 are to long get shortened, pads the length of small numbers 
 etc. `formatln(vec2(1000,1),"hello world")=>
 ```
 "x:  1000|y:     1|"hello w...| "
 ```
I counted those charaters out, but the forums software deleted my white space
Jul 14
prev sibling parent Dennis <dkorpel gmail.com> writes:
On Sunday, 14 July 2024 at 17:54:05 UTC, monkyyy wrote:
 So there should be several templated to hell and back print 
 functions, without the slightest care about speed
We could add something like Rust's `dbg` to object.d (which is the module that's always implicitly imported) https://doc.rust-lang.org/std/macro.dbg.html
Jul 14