digitalmars.D - DMD 0.95 release
- "Walter" <newshound digitalmars.com> Jul 08 2004
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= <juanjuxNO SPAMyahoo.es> Jul 08 2004
- Ben Hinkle <bhinkle4 juno.com> Jul 08 2004
- "Ivan Senji" <ivan.senji public.srce.hr> Jul 08 2004
- "Walter" <newshound digitalmars.com> Jul 08 2004
- kinghajj <kinghajj_member pathlink.com> Jul 08 2004
- Stewart Gordon <smjg_1998 yahoo.com> Jul 09 2004
- "Walter" <newshound digitalmars.com> Jul 09 2004
- Matthias Becker <Matthias_member pathlink.com> Jul 10 2004
- "Walter" <newshound digitalmars.com> Jul 10 2004
- Stewart Gordon <smjg_1998 yahoo.com> Jul 12 2004
- Stewart Gordon <smjg_1998 yahoo.com> Jul 12 2004
- David L. Davis <SpottedTiger yahoo.com> Jul 09 2004
- "Walter" <newshound digitalmars.com> Jul 10 2004
- Juanjo =?ISO-8859-15?Q?=C1lvarez?= <juanjuxNO SPAMyahoo.es> Jul 10 2004
- David L. Davis <SpottedTiger yahoo.com> Jul 10 2004
- Burton Radons <burton-radons shaw.ca> Jul 12 2004
- "Vathix" <vathixSpamFix dprogramming.com> Jul 13 2004
- Stewart Gordon <smjg_1998 yahoo.com> Jul 13 2004
- Roberto Mariottini <Roberto_member pathlink.com> Jul 13 2004
- Roberto Mariottini <Roberto_member pathlink.com> Jul 13 2004
- Stewart Gordon <smjg_1998 yahoo.com> Jul 13 2004
- Burton Radons <burton-radons shaw.ca> Jul 16 2004
- J C Calvarese <jcc7 cox.net> Jul 16 2004
- Stewart Gordon <smjg_1998 yahoo.com> Aug 10 2004
Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
Jul 08 2004
Walter wrote:Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
And more important, writefln which will save a lot \n's to the world <g>
Jul 08 2004
Walter wrote:Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
cool. writef is nice and simple and as flexible as printf. Is someone going to add a std.stream wrapper for writef? (Sean? me?) A corresponding readf would be nice since then we could replace std.stream.scanf. It could also be worth deprecating std.stream.printf, too, though it just ends up calling C's printf so it isn't a big deal. -Ben
Jul 08 2004
"Walter" <newshound digitalmars.com> wrote in message news:cck67e$2irt$1 digitaldaemon.com...Finally, the new printf is here! (called writef). The rest are bug fixes.
Although i can't get writef to work (only writefln) it is a great improvement over printf. BUT: Why do fwritef and fwritefln take FILE* as an argument and not a Stream or something like that?http://www.digitalmars.com/d/changelog.html
Jul 08 2004
"Ivan Senji" <ivan.senji public.srce.hr> wrote in message news:cckkic$6gf$1 digitaldaemon.com..."Walter" <newshound digitalmars.com> wrote in message news:cck67e$2irt$1 digitaldaemon.com...Finally, the new printf is here! (called writef). The rest are bug
Although i can't get writef to work (only writefln) it is a great improvement over printf.
This works: ----------------------------------------- C:\mars>type test.d import std.stdio; void main() { std.stdio.writef("hello\n"); } C:\mars>dmd test \dm\bin\link test,,,user32+kernel32/noi; C:\mars>test hello C:\mars> ----------------------------------------------BUT: Why do fwritef and fwritefln take FILE* as an argument and not a Stream or something like that?
std.format.doFormat() is designed to work with anything you want.
Jul 08 2004
"Walter" <newshound digitalmars.com> wrote in message news:cck67e$2irt$1 digitaldaemon.com... Finally, the new printf is here! (called writef). The rest are bug
Wow, writef() is cool! This'll make displaying information alot easier than it was before with printf()! writef("NUMBER: ", 3); instead of: printf("NUMBER: %i", 3); Thanks, Walter (and whoever else contributed to the writef() function)!
Jul 08 2004
Walter wrote:Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
Presumably we're going to have versions of writef for strings and Stream objects? OK, so it would be straightforward to write them ourselves, but they'd be such common, simple operations there would otherwise be several independently-written copies around (a bit like the many copies of bubble sort that C programmers who haven't discovered how to qsort keep around...). The obvious way would be to add writef and writefln methods to Stream (we'd have Unicode or not to consider - maybe also writefW and writeflnW), and to create a function dchar[] swritef(...); (by analogy with sprintf - but still don't know if that's the best name) to return a formatted string. I'll probably code up these additions over the weekend if nobody else is going to.... BTW there are a few kinds of types you haven't told us the default formatting for: - characters (presumably the character itself) - structs and unions (presumably .toString(), if it has one....) - enums (do these count as integral types?) - arrays other than strings - pointers - function pointers/delegates - have I missed any? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 09 2004
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:cclsjm$20s5$1 digitaldaemon.com...BTW there are a few kinds of types you haven't told us the default formatting for: - characters (presumably the character itself)
The character itself.- structs and unions (presumably .toString(), if it has one....)
Yup. Though this won't work yet for structs until TypeInfo is improved.- enums (do these count as integral types?)
Enums I have special plans for. When TypeInfo gets better, I plan to have writef write out the enum identifier corresponding to the value. Right now, they come out as integers.- arrays other than strings
Waiting on improved TypeInfo. Probably will do a comma separated list.- pointers - function pointers/delegates
Like %p.
Jul 09 2004
- structs and unions (presumably .toString(), if it has one....)
Yup. Though this won't work yet for structs until TypeInfo is improved.- enums (do these count as integral types?)
Enums I have special plans for. When TypeInfo gets better, I plan to have writef write out the enum identifier corresponding to the value. Right now, they come out as integers.- arrays other than strings
Waiting on improved TypeInfo. Probably will do a comma separated list.
Could you perhaps tell something about the improved Typeinfo? What can be done with it? What will be changed?
Jul 10 2004
"Matthias Becker" <Matthias_member pathlink.com> wrote in message news:ccp56o$sjl$1 digitaldaemon.com...- structs and unions (presumably .toString(), if it has one....)
Yup. Though this won't work yet for structs until TypeInfo is improved.- enums (do these count as integral types?)
Enums I have special plans for. When TypeInfo gets better, I plan to have writef write out the enum identifier corresponding to the value. Right
they come out as integers.- arrays other than strings
Waiting on improved TypeInfo. Probably will do a comma separated list.
Could you perhaps tell something about the improved Typeinfo? What can be
with it? What will be changed?
Basically having specialized TypeInfo's for each type.
Jul 10 2004
Stewart Gordon wrote: <snip>The obvious way would be to add writef and writefln methods to Stream (we'd have Unicode or not to consider - maybe also writefW and writeflnW), and to create a function dchar[] swritef(...);
I've just discovered that there's a function char[] format(...); in std.string that does this. Yet another undocumented feature. And I'm not sure why it's only been written for char, not for wchar or dchar, considering that doFormat itself generates dchars.... Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 12 2004
Stewart Gordon wrote: <snip>The obvious way would be to add writef and writefln methods to Stream (we'd have Unicode or not to consider - maybe also writefW and writeflnW), and to create a function
Here they are.... ---------- void writef(...) { void putc(dchar c) { char[] buf; std.utf.encode(buf, c); writeString(buf); } std.format.doFormat(&putc, _arguments, _argptr); } void writefln(...) { void putc(dchar c) { char[] buf; std.utf.encode(buf, c); writeString(buf); } std.format.doFormat(&putc, _arguments, _argptr); version (Win32) { writeString("\r\n"); } else version (Mac) { writeString("\r"); } else { writeString("\n"); } } void writefW(...) { void putc(dchar c) { wchar[] buf; std.utf.encode(buf, c); writeStringW(buf); } std.format.doFormat(&putc, _arguments, _argptr); } void writeflnW(...) { void putc(dchar c) { wchar[] buf; std.utf.encode(buf, c); writeStringW(buf); } std.format.doFormat(&putc, _arguments, _argptr); version (Win32) { writeStringW("\r\n"); } else version (Mac) { writeStringW("\r"); } else { writeStringW("\n"); } } -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 12 2004
In article <cck67e$2irt$1 digitaldaemon.com>, Walter says...Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
Walter: Bravo! I really likee the new 'C' printf() replacements in 'D', especially the writef() and writefln() functions, which I've been converting all the printf()s to writefln()s in my current 'D' code! :)) They work Great!! Also v0.95 fixed the problems I had found in v0.93 and v0.94...Thxs! <*-Hint-*>I know that I promised not to bug you, but it has been a little while now, so here goes nothing...are you any closer to putting in the ifind(), and irfind() (and maybe hopefully the ireplace() and icount() functions) into std.string? Please. I need them for the code I'm writing, and it would be a lot better if they're already in the Phobos runtime library. Plus I'm very close to announcing the opening of an expanded 'D' programming section to my home page soon, so it would be nice have the functions in place. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Jul 09 2004
"David L. Davis" <SpottedTiger yahoo.com> wrote in message news:ccnnvn$1ko1$1 digitaldaemon.com...In article <cck67e$2irt$1 digitaldaemon.com>, Walter says...Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
Walter: Bravo! I really likee the new 'C' printf() replacements in 'D', especially the writef() and writefln() functions, which I've been
the printf()s to writefln()s in my current 'D' code! :)) They work Great!! Also v0.95 fixed the problems I had found in v0.93 and v0.94...Thxs! <*-Hint-*>I know that I promised not to bug you, but it has been a little
now, so here goes nothing...are you any closer to putting in the ifind(),
irfind() (and maybe hopefully the ireplace() and icount() functions) into std.string? Please. I need them for the code I'm writing, and it would be
better if they're already in the Phobos runtime library. Plus I'm very
announcing the opening of an expanded 'D' programming section to my home
soon, so it would be nice have the functions in place.
Don't worry, I'll get to them.
Jul 10 2004
<*-Hint-*>I know that I promised not to bug you, but it has been a little while now, so here goes nothing...are you any closer to putting in the ifind(), and irfind() (and maybe hopefully the ireplace() and icount() functions) into std.string? Please. I need them for the code I'm writing,
<*- Hint -*> I'm sure Walter accept patches <g>
Jul 10 2004
In article <ccp4j1$rio$1 digitaldaemon.com>, Juanjo =?ISO-8859-15?Q?=C1lvarez?= says...<*-Hint-*>I know that I promised not to bug you, but it has been a little while now, so here goes nothing...are you any closer to putting in the ifind(), and irfind() (and maybe hopefully the ireplace() and icount() functions) into std.string? Please. I need them for the code I'm writing,
<*- Hint -*> I'm sure Walter accept patches <g>
Juanjo: Thxs!! But I've already did that, done that in the following messages "Re:DMD 0.92 release 06/12/2004 11:44 AM" with ifind() and irfind() REF:<caf8dk$2l38$1 digitaldaemon.com> and "Re:DMD 0.92 release 06/15/2004 01:45 PM" with ireplace() and icount() REF:<canciu$2p8q$1 digitaldaemon.com>. And Walter had allowed me the chance to do them, so now it's just a matter of waiting. :P ... <g> P.S. I bug Walter ever now and then, because he seems to work better and faster under pressure. :)) The wonderful new writef() replacement for printf() being as a prime example. Keep Truckin' Walter!! ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
Jul 10 2004
This code doesn't compile properly. The first line in classTemplate
works, but the second reports the error "no property 'type' for type
'classBase'". It should create a field of the given alias type.
class classBase
{
alias int type;
const int constant = 1;
}
class classTemplate (parameter)
{
int value = parameter.constant;
parameter.type field;
}
alias classTemplate! (classBase) instantiation;
Jul 12 2004
"Walter" <newshound digitalmars.com> wrote in message news:cck67e$2irt$1 digitaldaemon.com...Finally, the new printf is here! (called writef). The rest are bug fixes. http://www.digitalmars.com/d/changelog.html
Hooray! I don't think the format %.*s works as expected. It's printing out the entire string rather than using the alternate length from the stack: writef("%.*s", 2, "hello"); Still prints out the entire "hello". I know we don't need this anymore, but I think it should at least be consistent. All the types cleanly print what you would expect, except strings are still treated as formats. I just don't think it's all that good. The same old problem with printf(): you get user input and go to print it, if the user types a % it is processed as a format and all hell breaks loose (the typesafety prevents some of the problems). Sure you could just writef("%s", userinput) but it's just not very clean with the rest of it. I guess I'm having a hard time explaining it. But I have an idea to make it better, by using a different string type as the format: writef(f"this is a format string", "this isn't"); writef("%s does nothing", f"%s does something"); the f"" tells the compiler to use fchar[], fwchar[] or fdchar[] (can be typedef'd in object.d) that instruct writef() to process it as a format string instead of a regular string. Then writef(userinput) is safe. I think it will fit in fine because we won't need as many format strings as printf() did, since writef() knows about the types.
Jul 13 2004
Vathix wrote: <snip>All the types cleanly print what you would expect, except strings are still treated as formats.
Yes, that's the whole point of writef.I just don't think it's all that good. The same old problem with printf(): you get user input and go to print it, if the user types a % it is processed as a format and all hell breaks loose (the typesafety prevents some of the problems). Sure you could just writef("%s", userinput) but it's just not very clean with the rest of it.
I tend to use puts to write a string by itself. The only problem is if you want to do it without a trailing newline. Maybe we should have another function or two in std.stdio for this....I guess I'm having a hard time explaining it. But I have an idea to make it better, by using a different string type as the format: writef(f"this is a format string", "this isn't"); writef("%s does nothing", f"%s does something"); the f"" tells the compiler to use fchar[], fwchar[] or fdchar[] (can be typedef'd in object.d)
For the syntax to be supported, the types would have to be built into the language. But it does seem a rather ad hoc feature.... Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 13 2004
In article <cd08je$2ar5$1 digitaldaemon.com>, Vathix says...
All the types cleanly print what you would expect, except strings are still treated as formats. I just don't think it's all that good. The same old problem with printf(): you get user input and go to print it, if the user types a % it is processed as a format and all hell breaks loose (the typesafety prevents some of the problems). Sure you could just writef("%s", userinput) but it's just not very clean with the rest of it. I guess I'm having a hard time explaining it. But I have an idea to make it better, by using a different string type as the format: writef(f"this is a format string", "this isn't"); writef("%s does nothing", f"%s does something"); the f"" tells the compiler to use fchar[], fwchar[] or fdchar[] (can be typedef'd in object.d) that instruct writef() to process it as a format string instead of a regular string. Then writef(userinput) is safe. I think it will fit in fine because we won't need as many format strings as printf() did, since writef() knows about the types.
Exactly my thought, with the difference that I think you can use a custom class to specify a format: # class Format # { # ... # } # # // the fspec utility function # Format fspec(char[] fs) # { # ... # } # # Format fspec(wchar[] fs) # { # ... # } # # Format fspec(dchar[] fs) # { # ... # } Then you can safely write: writef("This is 100% safe!"); writef("Items: ", num , ", free: ", fspec("%7.3f%%"), (max-num)/max*100); Ciao
Jul 13 2004
In article <cd0qv1$9me$1 digitaldaemon.com>, Roberto Mariottini says...
Then you can safely write: writef("This is 100% safe!"); writef("Items: ", num , ", free: ", fspec("%7.3f%%"), (max-num)/max*100);
Re-thinking about it, I prefer having a format function returning a string, and having a write function that doesn't apply formats: write("this is ", 100, "% safe"); write("Used: ", format("%7.3f%%", num/max*100), ", free: ", format("%7.3f%%", (max-num)/max*100)); write(format("Used: %7.3f%% free: %7.3f%%", num/max*100, (max-num)/max*100))); Ciao
Jul 13 2004
Roberto Mariottini wrote: <snip>Re-thinking about it, I prefer having a format function returning a string, and having a write function that doesn't apply formats:
We have that format function in std.string; it just isn't documented. But yes, an unformatted write function would be nice. See my previous post on this thread. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 13 2004
This code fails with "non-constant expression b" on the last line in DMD
0.95. It should compile normally.
struct foo { int x; }
const int a = 0;
const foo b = { a };
const foo c = b;
It's a sticky problem, but templating can't be done without it.
Jul 16 2004
Burton Radons wrote:This code fails with "non-constant expression b" on the last line in DMD 0.95. It should compile normally. struct foo { int x; } const int a = 0; const foo b = { a }; const foo c = b; It's a sticky problem, but templating can't be done without it.
We now have a newsgroup dedicated to bug reports. I'm cross-posting to it. *web interface* http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs *usenet interface* news://news.digitalmars.com/digitalmars.D.bugs FWIW, I've confirmed your bug. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jul 16 2004
J C Calvarese wrote:Burton Radons wrote:This code fails with "non-constant expression b" on the last line in DMD 0.95. It should compile normally. struct foo { int x; } const int a = 0; const foo b = { a }; const foo c = b; It's a sticky problem, but templating can't be done without it.
To elaborate, members of const structs also fail. (DMD 0.98) Stewart. ---------- struct Qwert { int yuiop; } struct Asdfg { int hjkl; } struct Zxcvb { Asdfg nm; } const int qaz = 15; const Qwert wsx = { qaz }; const Asdfg edc = { wsx.yuiop }; const Zxcvb rfv = { edc }; int tgb = rfv.nm.hjkl; ---------- D:\My Documents\Programming\D\Tests\bugs\init_struct.d(7): non-constant expression *(&wsx) D:\My Documents\Programming\D\Tests\bugs\init_struct.d(8): non-constant expression edc D:\My Documents\Programming\D\Tests\bugs\init_struct.d(9): non-constant expression *(&rfv) -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Aug 10 2004









Juanjo =?ISO-8859-15?Q?=C1lvarez?= <juanjuxNO SPAMyahoo.es> 