View mode: basic / threaded / horizontal-split · Log in · Help
May 01, 2002
Re: dmd 30
On Tue, 30 Apr 2002 09:13:50 -0700, "Walter" <walter@digitalmars.com>
wrote:

>"Burton Radons" <loth@users.sourceforge.net> wrote in message
>news:5jascu4ff6rrdbhd5iptdo81mgvvoao4cj@4ax.com...
>> I'll have to get DJGPP's source for FP, tricky stuff.
>
>Be careful about the copyright/license status of DJGPP's source.

I didn't use it anyway.
May 02, 2002
Re: dmd 30
On Tue, 30 Apr 2002 15:47:01 +0400, "Pavel Minayev" <evilone@omen.ru>
wrote:

>"Burton Radons" <loth@users.sourceforge.net> wrote in message
>news:5jascu4ff6rrdbhd5iptdo81mgvvoao4cj@4ax.com...
[snip]
>> For printing objects we use "%o".  This calls the new toFormat (?)
>> method of the object, sending it the FormatFlags so that it can do
>> tricky things to it.  Normally this would just call toString.
>
>Format flags on object - how'd this look?..
>
>    Apple apple;
>    fmt("%o", apple);
>
>Where do I put those flags here?

Apple could have the class:

class Apple
{
   wchar [] toFormat (FormatFlags flags)
   {
       if (find (flags.string, "+"))
           return "a red and juicy apple";
       return "apple";
   }
}

I aborted this facility for now as FormatFlags would have to be moved
to object.d.  Walter can make that change to the code I sent him if he
wants (you did get that code, right Walter?)  At the moment it just
uses toString.

Oh, and it's "%r" instead.  "%o" is an octal.

>> Oh, and a string without any other limits on it defaults to (wchar*);
>> I was kind of expecting (wchar[]).  So this is incorrect in the
>> current release:
>>
>>     fmt ("%d blue borg%S", count, count == 1 ? "" : "s");
>>
>> Instead it would have to be:
>>
>>     fmt ("%d blue borg%+S", count, count == 1 ? "\0" : "s\0");
>
>Hm... I thought string literals are of type char[] (or wchar[])...

Depends upon the context.  Without a context it defaults to wchar* for
now.

>> "%ld" is our long (64-bit) in my implementation, rather than C's weird
>> mechanism.  I don't handle short or bit, ideas?  What about byte and
>> ubyte?  What about complex and extended?
>
>byte and short are converted to int when passing to vararg-functions, so
>no need to worry about it. You could add a bit type (%b?), so
>it'd print "true" and "false", but I guess it is passed as
>int as well.

"%b" is free.  Let's not support it for now and see whether it's a
requested feature; don't want to waste a formatting code if it's not
used.

>extended should be %lf, %lg, or %le, I think. imaginary could be %If,
>%Ig and %Ce, and complex - %Cf, %Cg and %Ce.

"%C" is a wide char, so no go there.  I don't think %I would be very
smart as many fonts render %l and %I identically.  I'm letting it
stew.
May 02, 2002
Re: dmd 30
"Burton Radons" <loth@users.sourceforge.net> wrote in message
news:fdg1dusukig9s1qvgsscsa1rt8oit9s1gs@4ax.com...

> Apple could have the class:
>
> class Apple
> {
>     wchar [] toFormat (FormatFlags flags)
>     {
>         if (find (flags.string, "+"))
>             return "a red and juicy apple";
>         return "apple";
>     }
> }

Okay, I get the idea.

> "%b" is free.  Let's not support it for now and see whether it's a
> requested feature; don't want to waste a formatting code if it's not
> used.

I think that printing booleans is not a rare operation.
May 03, 2002
Re: dmd 30
"Burton Radons" <loth@users.sourceforge.net> wrote in message
news:5jascu4ff6rrdbhd5iptdo81mgvvoao4cj@4ax.com...
> On Mon, 29 Apr 2002 20:57:44 -0700, Burton Radons
> <loth@users.sourceforge.net> wrote:
>
> >On Mon, 29 Apr 2002 20:01:49 -0700, "Walter" <walter@digitalmars.com>
> >wrote:
> >>"Burton Radons" <loth@users.sourceforge.net> wrote in message
> >>news:mcercusasglvehmssbnrhq475h7ashsh51@4ax.com...
> >>> Some kind of printf that returns the result would be very nice.
> >>> fmt(), say.  Such as: [snip code]
> >>
> >>Yes, a D-ized version of printf is needed.
> >
> >Speak of the devil.  Working on it this very moment.  It's going to be
> >wchar through and through if you don't mind.
>
> This demands a little more explanation since a feature this affecting
> deserves a debate.  I'd like to hear what people want from this thing.

Some time ago, I requested that printf fix my favorite usability gripe with
printing numbers.  It should allow replacing the period in the formatting
string with a comma to indicate that commas should be put in every three
places to the left of the decimal point.

Thus, instead of say      6874934935.45
You would get           6,874,934,935.45

At a very modest cost, and no backward compatibility problems, you get a
great improvement in readability.  In that post - which I can't find the
number of using find :-(, I had some other suggestions relating for easier
to read numeric formatting, which I will be happy to share again if you are
interested.

--
- Stephen Fuld
  e-mail address disguised to prevent spam
May 04, 2002
Re: dmd 30
On Fri, 3 May 2002 08:49:58 -0700, "Stephen Fuld"
<s.fuld.pleaseremove@att.net> wrote:

>
>"Burton Radons" <loth@users.sourceforge.net> wrote in message
>news:5jascu4ff6rrdbhd5iptdo81mgvvoao4cj@4ax.com...
>> On Mon, 29 Apr 2002 20:57:44 -0700, Burton Radons
>> <loth@users.sourceforge.net> wrote:
>>
>> >On Mon, 29 Apr 2002 20:01:49 -0700, "Walter" <walter@digitalmars.com>
>> >wrote:
>> >>"Burton Radons" <loth@users.sourceforge.net> wrote in message
>> >>news:mcercusasglvehmssbnrhq475h7ashsh51@4ax.com...
>> >>> Some kind of printf that returns the result would be very nice.
>> >>> fmt(), say.  Such as: [snip code]
>> >>
>> >>Yes, a D-ized version of printf is needed.
>> >
>> >Speak of the devil.  Working on it this very moment.  It's going to be
>> >wchar through and through if you don't mind.
>>
>> This demands a little more explanation since a feature this affecting
>> deserves a debate.  I'd like to hear what people want from this thing.
>
>Some time ago, I requested that printf fix my favorite usability gripe with
>printing numbers.  It should allow replacing the period in the formatting
>string with a comma to indicate that commas should be put in every three
>places to the left of the decimal point.
>
>Thus, instead of say      6874934935.45
>You would get           6,874,934,935.45
>
>At a very modest cost, and no backward compatibility problems, you get a
>great improvement in readability.  In that post - which I can't find the
>number of using find :-(, I had some other suggestions relating for easier
>to read numeric formatting, which I will be happy to share again if you are
>interested.

This could tie into the regional settings facility of modern OSes to
produce correct numbers everywhere... see the "Regional Settings" tab
on Windows' Control Panel.  These could take up an "n" flag for number
or a "$" flag for currency (for example).  So I could have:

 fmt ("%nd %$g", 4545, 8783.232);

Which would reply on my system with:

 4,545 $8,783.23

Perhaps even "%$US.g" or "%$Euro.g".

Java has solutions for this spread out all over the library.
Currency, like proper date, is not a simple problem by any means.  But
supporting separated numbers and simple currency is pretty trivial.

There's an MSDN page for the locale symbols at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_crt_locale.asp
May 06, 2002
Re: dmd 30
"Burton Radons" <loth@users.sourceforge.net> wrote in message
news:87o6duk1e2ik2o69rceihr3msq0lnq4l0e@4ax.com...
> On Fri, 3 May 2002 08:49:58 -0700, "Stephen Fuld"
> <s.fuld.pleaseremove@att.net> wrote:
>
> >
> >"Burton Radons" <loth@users.sourceforge.net> wrote in message
> >news:5jascu4ff6rrdbhd5iptdo81mgvvoao4cj@4ax.com...
> >> On Mon, 29 Apr 2002 20:57:44 -0700, Burton Radons
> >> <loth@users.sourceforge.net> wrote:
> >>
> >> >On Mon, 29 Apr 2002 20:01:49 -0700, "Walter" <walter@digitalmars.com>
> >> >wrote:
> >> >>"Burton Radons" <loth@users.sourceforge.net> wrote in message
> >> >>news:mcercusasglvehmssbnrhq475h7ashsh51@4ax.com...
> >> >>> Some kind of printf that returns the result would be very nice.
> >> >>> fmt(), say.  Such as: [snip code]
> >> >>
> >> >>Yes, a D-ized version of printf is needed.
> >> >
> >> >Speak of the devil.  Working on it this very moment.  It's going to be
> >> >wchar through and through if you don't mind.
> >>
> >> This demands a little more explanation since a feature this affecting
> >> deserves a debate.  I'd like to hear what people want from this thing.
> >
> >Some time ago, I requested that printf fix my favorite usability gripe
with
> >printing numbers.  It should allow replacing the period in the formatting
> >string with a comma to indicate that commas should be put in every three
> >places to the left of the decimal point.
> >
> >Thus, instead of say      6874934935.45
> >You would get           6,874,934,935.45
> >
> >At a very modest cost, and no backward compatibility problems, you get a
> >great improvement in readability.  In that post - which I can't find the
> >number of using find :-(, I had some other suggestions relating for
easier
> >to read numeric formatting, which I will be happy to share again if you
are
> >interested.
>
> This could tie into the regional settings facility of modern OSes to
> produce correct numbers everywhere... see the "Regional Settings" tab
> on Windows' Control Panel.

I looked on my system and found the tab, but is seems not to make any
difference as very few applications, and even Windows itself, seems to
ignore it, at least as far as providing comma separation in numerif values.


>These could take up an "n" flag for number
> or a "$" flag for currency (for example).  So I could have:
>
>   fmt ("%nd %$g", 4545, 8783.232);
>
> Which would reply on my system with:
>
>   4,545 $8,783.23
>
> Perhaps even "%$US.g" or "%$Euro.g".
>
> Java has solutions for this spread out all over the library.
> Currency, like proper date, is not a simple problem by any means.  But
> supporting separated numbers and simple currency is pretty trivial.

Yes, I was suggesting the simple things that cover most of the cases.  If
someone later wants to do the full thing, more power to them.  But if
waiting for the full solution is the excuse for not solving the problem
before in C, then we have waited far too long and the excuse is beyond
credible.  At least fix the simple case first and we can worry about the
full solution later.

--
- Stephen Fuld
  e-mail address disguised to prevent spam
May 06, 2002
Re: dmd 30
"Stephen Fuld" <s.fuld.pleaseremove@att.net> wrote in message
news:ab4vmr$q49$1@digitaldaemon.com...

> Yes, I was suggesting the simple things that cover most of the cases.  If
> someone later wants to do the full thing, more power to them.  But if
> waiting for the full solution is the excuse for not solving the problem
> before in C, then we have waited far too long and the excuse is beyond
> credible.  At least fix the simple case first and we can worry about the
> full solution later.

So, back to the locales library...
I wonder if C++-like solution would suit here. What do you think?
May 06, 2002
Re: dmd 30
On Sun, 5 May 2002 21:06:04 -0700, "Stephen Fuld"
<s.fuld.pleaseremove@att.net> wrote:

>"Burton Radons" <loth@users.sourceforge.net> wrote in message
>news:87o6duk1e2ik2o69rceihr3msq0lnq4l0e@4ax.com...
[snip]
>> Java has solutions for this spread out all over the library.
>> Currency, like proper date, is not a simple problem by any means.  But
>> supporting separated numbers and simple currency is pretty trivial.
>
>Yes, I was suggesting the simple things that cover most of the cases.  If
>someone later wants to do the full thing, more power to them.  But if
>waiting for the full solution is the excuse for not solving the problem
>before in C, then we have waited far too long and the excuse is beyond
>credible.  At least fix the simple case first and we can worry about the
>full solution later.

You're exaggerating the difficulty of supporting number separations
properly.  Once Walter's finished his current work and put fmt in
Phobos, I'll patch it up for numeric printing and send it off.
There's no problem, I just can't do it this very instant for you.
May 06, 2002
Re: dmd 30
"Burton Radons" <loth@users.sourceforge.net> wrote in message
news:n7dcducl1caqs6i9l2odqaspbf63u67air@4ax.com...
> On Sun, 5 May 2002 21:06:04 -0700, "Stephen Fuld"
> <s.fuld.pleaseremove@att.net> wrote:
>
> >"Burton Radons" <loth@users.sourceforge.net> wrote in message
> >news:87o6duk1e2ik2o69rceihr3msq0lnq4l0e@4ax.com...
> [snip]
> >> Java has solutions for this spread out all over the library.
> >> Currency, like proper date, is not a simple problem by any means.  But
> >> supporting separated numbers and simple currency is pretty trivial.
> >
> >Yes, I was suggesting the simple things that cover most of the cases.  If
> >someone later wants to do the full thing, more power to them.  But if
> >waiting for the full solution is the excuse for not solving the problem
> >before in C, then we have waited far too long and the excuse is beyond
> >credible.  At least fix the simple case first and we can worry about the
> >full solution later.
>
> You're exaggerating the difficulty of supporting number separations
> properly.  Once Walter's finished his current work and put fmt in
> Phobos, I'll patch it up for numeric printing and send it off.
> There's no problem, I just can't do it this very instant for you.

I wasn't trying to exaggerate the difficulty - in fact just the opposite.
Your solution sounds great.  Thanks.

--
- Stephen Fuld
  e-mail address disguised to prevent spam
May 06, 2002
Re: dmd 30
"Pavel Minayev" <evilone@omen.ru> wrote in message
news:ab546o$tng$1@digitaldaemon.com...
> "Stephen Fuld" <s.fuld.pleaseremove@att.net> wrote in message
> news:ab4vmr$q49$1@digitaldaemon.com...
>
> > Yes, I was suggesting the simple things that cover most of the cases.
If
> > someone later wants to do the full thing, more power to them.  But if
> > waiting for the full solution is the excuse for not solving the problem
> > before in C, then we have waited far too long and the excuse is beyond
> > credible.  At least fix the simple case first and we can worry about the
> > full solution later.
>
> So, back to the locales library...
> I wonder if C++-like solution would suit here. What do you think?

I am not a C++ person, so I can't comment intelligently.

--
- Stephen Fuld
  e-mail address disguised to prevent spam
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home