July 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


July 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:
<snip>

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.
July 16, 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.
July 17, 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/
August 10, 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.
<snip>

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.
1 2 3
Next ›   Last »