D - native D puts()
- Jonathan Andrew (23/23) May 08 2003 Hello, for those interested, I whipped up a quick & dirty puts() functio...
- Sean L. Palmer (14/37) May 08 2003 I hate to see this sort of stuff proliferating. It would be prudent to
- Jonathan Andrew (6/14) May 09 2003 As far as I knew, WriteFile is just a windows system call buried in a li...
- Karl Bochert (12/22) May 09 2003 How about
- C. Sauls (10/16) May 09 2003 I like the idea with this, but rather than the switches as you have them...
- Ilya Minkov (3/15) May 09 2003 There is also another target where to output: there is some way to make
- Karl Bochert (8/30) May 09 2003
- Walter (4/7) May 11 2003 something
Hello, for those interested, I whipped up a quick & dirty puts() function for D strings. It was my understanding that the c.stdio puts() expects null termination. I figured it would be an easy way for people new to the language to play around without having to worry about all the %.*s stuff in printf. //-------------------cut here-------------------------- import windows; int putsd(char[] instring) { uint numwritten; HANDLE h; h = (HANDLE) -11; WriteFile(h, instring, instring.length, &numwritten, null); if(numwritten != instring.length) return 1; else return 0; } //--------------------cut here---------------------- Is there a lower-level way to do this? I figured calling the windows WriteFile was as low as practical, but if somebody knows an even better way to implement this, I would love to see it. Thanks, -Jon
May 08 2003
I hate to see this sort of stuff proliferating. It would be prudent to hammer out a good D streams spec now. Preferrably something that doesn't require layering atop C libraries. Hopefully add a "stddbg" sort of debug output stream as well (defaults to stderr or stdout if you're on a console-only platform). Assuming handle -11 is stdout doesn't seem to be such a good idea, either. I'm not saying it doesn't work; I haven't checked. Sean "Jonathan Andrew" <Jonathan_member pathlink.com> wrote in message news:b9epl6$1qri$1 digitaldaemon.com...Hello, for those interested, I whipped up a quick & dirty puts() functionfor Dstrings. It was my understanding that the c.stdio puts() expects null termination. I figured it would be an easy way for people new to thelanguage toplay around without having to worry about all the %.*s stuff in printf. //-------------------cut here-------------------------- import windows; int putsd(char[] instring) { uint numwritten; HANDLE h; h = (HANDLE) -11; WriteFile(h, instring, instring.length, &numwritten, null); if(numwritten != instring.length) return 1; else return 0; } //--------------------cut here---------------------- Is there a lower-level way to do this? I figured calling the windowsWriteFilewas as low as practical, but if somebody knows an even better way toimplementthis, I would love to see it. Thanks, -Jon
May 08 2003
I hate to see this sort of stuff proliferating. It would be prudent to hammer out a good D streams spec now. Preferrably something that doesn't require layering atop C libraries. Hopefully add a "stddbg" sort of debug output stream as well (defaults to stderr or stdout if you're on a console-only platform). Assuming handle -11 is stdout doesn't seem to be such a good idea, either. I'm not saying it doesn't work; I haven't checked. SeanAs far as I knew, WriteFile is just a windows system call buried in a library somwhere. If I am wrong about this, please let me know, I'm new to this whole thing. I got the -11 from Pavel's windows.d. There are other functions that will look up this number, but I figured Pavel knew what he was doing when he wrote his API, certainly more than I do =). -Jon
May 09 2003
On Thu, 8 May 2003 22:01:21 -0700, "Sean L. Palmer" <palmer.sean verizon.net> wrote:I hate to see this sort of stuff proliferating. It would be prudent to hammer out a good D streams spec now. Preferrably something that doesn't require layering atop C libraries. Hopefully add a "stddbg" sort of debug output stream as well (defaults to stderr or stdout if you're on a console-only platform). Assuming handle -11 is stdout doesn't seem to be such a good idea, either. I'm not saying it doesn't work; I haven't checked. SeanHow about stdin stdout stderr stdkbd -- read keyboard even if input redirected stddbg -- Behavior determined by command-line switch (or similar) -debug Output to console -log Output to file -regress Compare to existing regression file -release No output Karl Bochert
May 09 2003
stdkbd -- read keyboard even if input redirected stddbg -- Behavior determined by command-line switch (or similar) -debug Output to console -log Output to file -regress Compare to existing regression file -release No outputI like the idea with this, but rather than the switches as you have them, it might be safer to use something like: -stddbg=console -stddbg=log -stddbg=regress -stddbg=none & -stddbg=release And I'm thinking the compiler could seek&destroy calls to stddbg when 'none' or 'release' is specified. But I'm not a compiler expert by the slightest means. -- C. Sauls
May 09 2003
There is also another target where to output: there is some way to make a debugger, in the case it is running, display and log a message. C. Sauls wrote:I like the idea with this, but rather than the switches as you have them, it might be safer to use something like: -stddbg=console -stddbg=log -stddbg=regress -stddbg=none & -stddbg=release And I'm thinking the compiler could seek&destroy calls to stddbg when 'none' or 'release' is specified. But I'm not a compiler expert by the slightest means. -- C. Sauls
May 09 2003
On Fri, 9 May 2003 09:06:22 -0500, "C. Sauls" <ibisbasenji yahoo.com> wrote:As long as it can handle output to more than one location i.e. '-stddgb=console,log' Best is if the compiler can toggle these flags from the source -- something like (in another world) '#pragma stddbg=log' Can D do this?stdkbd -- read keyboard even if input redirected stddbg -- Behavior determined by command-line switch (or similar) -debug Output to console -log Output to file -regress Compare to existing regression file -release No outputI like the idea with this, but rather than the switches as you have them, it might be safer to use something like: -stddbg=console -stddbg=log -stddbg=regress -stddbg=none & -stddbg=releaseAnd I'm thinking the compiler could seek&destroy calls to stddbg when 'none' or 'release' is specified. But I'm not a compiler expert by the slightest means.The compiler certainly would comment out dbg calls for 'release'-- C. Sauls
May 09 2003
"Karl Bochert" <kbochert copper.net> wrote in message news:1103_1052526238 bose...Best is if the compiler can toggle these flags from the source --somethinglike (in another world) '#pragma stddbg=log' Can D do this?Yes - check out the version and debug statements.
May 11 2003