July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nicolai Waniek | Nicolai Waniek wrote:
>
> My problem with both libraries is that I just use a subset of their features,
> but I get the whole package compiled into my projects - and though we have 250GB
> HDDs, i want my applications be (damn) small.
At this point, there are two factors that bloat D executables: TypeInfo, and file-level linking. We're likely stuck with the former, but if the latter could be addressed then things would improve tremendously. Unfortunately, this suggests that we'll need a new linker for Win32.
Sean
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> For what it's worth, Stdout supports a number of different output methods. The "whisper syntax" you show above is just the most commonly known. For formatted output similar to writefln you'd do:
>
> Stdout.format( "X is: {}", x ).newline;
Using Stdout.formatln() instead of Stdout.format().newline is more likely to be accepted by phobos users.
Out of curiosity, why is {} used instead of %s?
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly Wrote:
> Steve Teale wrote:
> > Sean Kelly Wrote:
> >
> >> Steve Teale wrote:
> >>> It seemes to me that given Walter's definition of the language - a system programming language - that Phobos is closer to the mark. If users want a more object oriented standard library, that's all well and good, but it should be a shoe-in, then if you want to use the OO stuff you can, but code that's been written to work with Phobos should work unmodified with other libraries. (Note the recent discussion on C++ security).
> >> While one might argue that it is easier to wrap a strictly procedural library with an OO layer than vice-versa, I think the ease with which any library may be encapsulated in a wrapper is more dependent on its design (the assumptions it makes, how features are exposed, etc) than on whether the interface uses functions or objects. That said, I don't personally consider Tango to be an object-oriented library because it does not require the user to define his own objects in order to use it.
> >>
> >>
> >> Sean
> >
> > Sean, I take your point, and maybe should not have used the term "OO", but my idea of progress is:
> >
> > printf("X is: %s\n", toStringz(x))
> > cout << "X is: " << x << endl;
> > Stdout("X is: ")(x).newline;
> > writefln("X is: %s", x);
> >
> > rather than:
> >
> > printf("X is: %s\n", toStringz(&x))
> > cout << "X is: " << x << endl;
> > writefln("X is: %s", x);
> > Stdout("X is: ")(x).newline;
> >
>
> For what it's worth, Stdout supports a number of different output methods. The "whisper syntax" you show above is just the most commonly known. For formatted output similar to writefln you'd do:
>
> Stdout.format( "X is: {}", x ).newline;
>
> Another option is:
>
> Stdout( "X is: ", x ).newline;
>
> This last prints comma-delimeted output, since that's how it appears in the Stdout call. For what it's worth, Kris recently explained all this on D.learn.
>
>
> Sean
Sean,
I give in. I know that your motivations are genuine. I just don't want two see classes of D citizens. In Europe we fought for centuries over this sort of thing. Somehow we should get to astate of affairs where if you are writing a library you should not have to make a religious choice as to which standard library you subscribe to. Please talk to Walter at the conference, and try and get this sorted. I would love to attend, but I live on the other side of the world, and still need to go to work.
Steve
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to TomD | TomD Wrote:
> Jason House Wrote:
>
> > Actually, I'm just about to switch from phobos to tango. I initially went with phobos because it's what comes with D and was simpler for both me and anyone who uses my program...
> >
> > I didn't have any issues for 2 months, then I started hitting issues with little or no way to get help. I eventually traced one of my issues to a low numbered issue in the issue database that had never gotten fixed. I saw Walter nearly overloaded with D 2.0, but got rapid responses and encouraging responses from the Tango team. Many of my problems (bit or small) with Phobos have been fixed already in Tango... Or at least look like someone took a stab at it. When you add in that the Tango team will be responsive to problems discovered and work to resolve issues, I'm sold!
> I totally second that complaint. It is a pitty that even if you send in tested, working
> patches, they do not get incorporated. Still, I prefer Phobos because it looks much leaner, and has a better decumentation.
>
> Ciao
> Tom
Tom,
Then let's persist with this bitching until we get it sorted. Someone else in the thread has already noted that Walter has too much on his back already. Somehow we need to get these things unified, so it's safe to write a library. My version of Phobos is patched, as I suspect are many, but as you say there's no way of checking these changes in.
Walter, you are eventually going to have to delegate this somewhere!
Steve
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jason House | "Jason House" <jason.james.house@gmail.com> wrote in message news:f7atnl$2lm6$1@digitalmars.com... > > Out of curiosity, why is {} used instead of %s? It makes it easier to make more flexible formatting, and also so you can put indices into the braces. Indexing the arguments is important because word order in different languages can be different. For example, say you had the message in English: "Employee {} is not in personnel database {}", personName, databaseName Now look at a language like Japanese, where you'd probably put the database name first; it'd be arranged something like "in personnel database {}, employee {} does not exist". Now you have to change the order of the arguments after the format string. But with indexing, you can say {0} always is the employee name, and {1} always is the database name, so that you can format them in the correct order for other languages, without having to change the actual format code. Just change the format string. Another reason is custom formatting. You know how you can do %x with printf-style to get a hex number. You can add in some digits to change the number of digits to display etc. like %08x. But what if you had a class which could be formatted beyond the simple "use toString (or toUtf8 in Tango :P)"? Like, what if that class represented a set of coordinates, like latitude/longitude? There might be more than one way to display it; including or ommitting some of the pieces of the coordinates, rouding pieces off to certain precisions etc. What you can do with the {} formatting specifiers is pass an entirely custom format string after the colon which is used to format certain types. You'd have to write a custom formatter class to do this, but the basic formatting framework is already in place; all you have to do is write a formatting method which parses out that string and formats the components correctly. No way would you be able to do that with the % formatters without some ugly additions. And lastly I think the {} looks prettier ;) | |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Nicolai Waniek wrote:
>>
>> My problem with both libraries is that I just use a subset of their features,
>> but I get the whole package compiled into my projects - and though we have 250GB
>> HDDs, i want my applications be (damn) small.
>
> At this point, there are two factors that bloat D executables: TypeInfo, and file-level linking. We're likely stuck with the former, but if the latter could be addressed then things would improve tremendously. Unfortunately, this suggests that we'll need a new linker for Win32.
For the former, perhaps it would be possible to have an extension to the module statement to indicate "this module should not generate any TypeInfo".
I'm particularly thinking of things like the Windows headers, which should entirely disappear if not used.
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote:
> What you can do with the {} formatting
> specifiers is pass an entirely custom format string after the colon which is used to format certain types.
The colon? I've never seen examples of Tango I/O with a colon. Do you mean something like the following?
Stdout.format("Foo with custom formatting = {:custom}",foo);
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Walter Bright wrote:
>> I'm up for such a discussion.
>
> Same here. Heck, the point of the conference in my opinion is to meet people. The talks largely exist to fuel conversation.
Absolutely right. I'm really looking forward to it.
| |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jason House | Jason House schrieb: > The colon? I've never seen examples of Tango I/O with a colon. Do you mean something like the following? > > Stdout.format("Foo with custom formatting = {:custom}",foo); {index:format,alignment} You can google for the C# format strings or have a look at the tango.text.convert.Layout unittests: http://dsource.org/projects/tango/browser/trunk/tango/text/convert/Layout.d#L571 | |||
July 14, 2007 Re: Two standard libraries? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote:
> "Jason House" <jason.james.house@gmail.com> wrote in message news:f7atnl$2lm6$1@digitalmars.com...
>> Out of curiosity, why is {} used instead of %s?
>
> It makes it easier to make more flexible formatting, and also so you can put indices into the braces. Indexing the arguments is important because word order in different languages can be different. For example, say you had the message in English:
>
> "Employee {} is not in personnel database {}", personName, databaseName
>
> Now look at a language like Japanese, where you'd probably put the database name first; it'd be arranged something like "in personnel database {}, employee {} does not exist". Now you have to change the order of the arguments after the format string. But with indexing, you can say {0} always is the employee name, and {1} always is the database name, so that you can format them in the correct order for other languages, without having to change the actual format code. Just change the format string.
That's a great argument -- I think it deserves to be in the Tango docs. It's surely a frequently asked question from programmers with a C/C++/Phobos background.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply