April 06, 2009 The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Hi everybody, I just committed all of Phobos into svn on dsource.org. That is not an official release and has known and unknown bugs, limitations, and rhinodemons. I expect some ripples before we stabilize, but when we will we'll stabilize at a higher potential. For convenience, I've also uploaded pre-built libraries for Windows and Linux here: http://www.erdani.dreamhosters.com/d/ The updated documentation is here: http://www.erdani.dreamhosters.com/d/web/phobos/phobos.html Finally, the whole shebang with source and all as dumped from my disk is to be found here: http://www.erdani.dreamhosters.com/d/src/ If you want to build Phobos yourself, check out the Makefile (not linux.mak; that won't work). That GNU Makefile, hosted on Linux, can build the Linux lib and also the Windows lib by using wine. (I'm very happy about this; now I can test on Windows and Linux without switching more than a command line tweak.) Below are highlights of the additions and changes: *** std.path * getDrive now works with all string types * isabs accepts in char[] * join accepts variadic in char[] * fnmatch works with in char[] *** std.regexp * Scheduled for deprecation. Use std.regex instead. *** std.regex (new file) * Regular expression library with wide char support, simplified interface, better speed etc. *** std.format * Added vector parsing and printing with the specifier "%()". For example, writefln("[%(s; )]", [1, 2, 3][]) writes "[1; 2; 3]". This support is experimental and may be changed in the future. * Added a formattedRead function (i.e., scanf that doesn't suck). The implementation is incomplete but common cases are supported. *** std.random * Added RandomCover that covers a given range in a random manner * Eliminated the old-fashioned random functions * Defined a default random object that simplifies calls to the random functions * Changed generators to obey the range interface. So now you can write: Random r; foreach (n; take(100, uniform(0, 100)) { ... } *** std.file * read, write, append, rename, remove, getSize, getTimes, getAttributes, isfile, isdir, chdir, mkdir, mkdirRecurse, rmdir, listdir, copy, take filename(s) by "in char[]" * Added function readText that reads and validates a text file * Added function slurp that reads a file into an array of tuples. Example: auto a = slurp!(int, double)("filename", "%s, %s"); Each line in the file looks like e.g. "1, 2.3". slurp returns an array of Tuple!(int, double) with the parsed content. *** std.mmfile * Minor cosmetic changes *** std.conv * Rewrote conversions with constrained templates. * Added text() function that transforms everything into text. *** std.typecons * Added constructors, assignment operator, length, toString, and slice to Tuple. ** std.bitmanip * Bitfields of length 0 are defined to be always 0. * The read functions for bitfields are const. *** std.numeric * Added type CustomFloat that allows defining specialized floating-point numbers (e.g. 16-bit floats, positive floats etc.) * Added FPTemporary as the best type to store temporary values. * Templatized oppositeSigns * Added Euclidean distance * Added dotProduct * Added cosineSimilarity * Added normalize * Added string kernel functions gapWeightedSimilarity, gapWeightedSimilarityNormalized, gapWeightedSimilarityIncremental. *** std.outbuffer * Added a few missing overloads of write() *** std.contracts * enforce accepts const(char)[] instead of string * Added enforce overload that invokes a delegate on failure * Added assumeSorted template * Added structuralCast that implements, well, structural casting (incomplete). *** std.c.stdio * Added fopen64 and friends *** std.utf * toUTF16z accepts in char[] *** std.algorithm * Everything converted to ranges. Big disruption. Algorithms added. *** std.getopt * Added support for parameterless delegates *** std.functional * Improved error messages * Added configurable parameter names for functions as strings * Added Adjoin template *** std.variant * Added support for Variants that contain vectors and hashes of themselves *** std.string * strip, stripl, stripr, startsWith, endsWith now work with any string type *** std.array * Range primitives for arrays * Appender template * insert, replace functions *** std.date * Added a benchmark function that allows for simple timing measurements. *** std.stdio * Major breaking changes: introduced the File struct. Now stdin, stdout, stderr are instances of the File struct. * Due to bugs in the compiler, the copy constructor and destructor of File are commented out. Walter will look into fixing the issues soon. File should work fine, but you need to close it manually. * A byRecord iteration mode makes it pretty easy to iterate structured text files. *** std.range (new file) * Range manipulation stuff. Andrei P.S. If you have any troubles with the website, I'd appreciate if you let me know. This is my first experiment with a new provider. |
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Reply to Andrei,
> auto a = slurp!(int, double)("filename", "%s, %s");
>
> Each line in the file looks like e.g. "1, 2.3". slurp returns an array
> of Tuple!(int, double) with the parsed content.
>
It would be nice to have a version that would slurp into pre defined structs.
struct S{ int i; double d }
S[] a = slurp!(S)("filename", "%s, %s");
|
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote:
> Reply to Andrei,
>
>> auto a = slurp!(int, double)("filename", "%s, %s");
>>
>> Each line in the file looks like e.g. "1, 2.3". slurp returns an array
>> of Tuple!(int, double) with the parsed content.
>>
>
> It would be nice to have a version that would slurp into pre defined structs.
>
> struct S{ int i; double d }
>
> S[] a = slurp!(S)("filename", "%s, %s");
>
>
And maybe a burp that spits a tuple back into a file?
|
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote:
> Reply to Andrei,
>
>> auto a = slurp!(int, double)("filename", "%s, %s");
>>
>> Each line in the file looks like e.g. "1, 2.3". slurp returns an array
>> of Tuple!(int, double) with the parsed content.
>>
>
> It would be nice to have a version that would slurp into pre defined structs.
>
> struct S{ int i; double d }
>
> S[] a = slurp!(S)("filename", "%s, %s");
>
>
That's a great idea. Would be great if you could bugzillize it so it doesn't get forgotten.
Andrei
|
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tue, 07 Apr 2009 01:23:20 +0400, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: > Hi everybody, > > [snip] > Random r; > foreach (n; take(100, uniform(0, 100)) { ... } > Warning: unreferenced variable 'r'. :) > > [snip] > |
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Koroskin | Denis Koroskin wrote:
> On Tue, 07 Apr 2009 01:23:20 +0400, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
>
>> Hi everybody,
>>
>> [snip]
>> Random r;
>> foreach (n; take(100, uniform(0, 100)) { ... }
>>
>
> Warning: unreferenced variable 'r'. :)
Rats :o). Now uniform doesn't need an explicit Random object, but I still created one out of reflex.
Andrei
|
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | == Quote from Andrei Alexandrescu (SeeWebsiteForEmail@erdani.org)'s article > Hi everybody, > I just committed all of Phobos into svn on dsource.org. That is not an > official release and has known and unknown bugs, limitations, and > rhinodemons. I expect some ripples before we stabilize, but when we will > we'll stabilize at a higher potential. Is this pretty much everything, or is there even more to come? I want to start porting some code to the new Phobos, or at least thinking about how to change the code to best make use of the new Phobos, but I don't want to do it until at least the more radical, earthquake-like changes have been unveiled. P.S. It looks fantastic! |
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha | dsimcha wrote:
> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail@erdani.org)'s article
>> Hi everybody,
>> I just committed all of Phobos into svn on dsource.org. That is not an
>> official release and has known and unknown bugs, limitations, and
>> rhinodemons. I expect some ripples before we stabilize, but when we will
>> we'll stabilize at a higher potential.
>
> Is this pretty much everything, or is there even more to come? I want to start
> porting some code to the new Phobos, or at least thinking about how to change the
> code to best make use of the new Phobos, but I don't want to do it until at least
> the more radical, earthquake-like changes have been unveiled.
>
> P.S. It looks fantastic!
Thanks! This is all I have, and I think from here on there will be more additions instead of big changes. There is one major change not effected yet, which affects both the compiler and phobos: the renaming of head, toe, next, and retreat to (respectively) front, back, popFront, and popBack. Also in foreach we will make the following change:
foreach (e; range) body
from:
for (auto copy = range; !copy.empty; copy.popFront)
{
auto e = copy.front;
body
}
with:
for (auto copy = range[]; !copy.empty; copy.popFront)
{
auto e = copy.front;
body
}
Notice the extra [] when getting the copy of the range. The reason is that people want to do:
foreach (e; container) {}
when the container is actually not a range. Operator [] for a range will simply return the range itself. For a container, it will return that container's preferred range.
Andrei
|
April 06, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Really Sweet,
Any chance of fixing one of my pet peeves of std.stream
writeLine() - using platform dependant line endings
Almost all the socket work I've done with this has made it a rather annoying pointless method (as it's totally non-portable). perhaps implementing
writeCR() writeLF() writeCRLF(), then letting writeLine call them, dependant on which platform would be better?
I guess in-line comments in the manual are a bit outside your scope at present.
Anyway great work.
Regards
Alan
Andrei Alexandrescu wrote:
> Hi everybody,
>
>
> I just committed all of Phobos into svn on dsource.org. That is not an
> official release and has known and unknown bugs, limitations, and
> rhinodemons. I expect some ripples before we stabilize, but when we will
> we'll stabilize at a higher potential.
>
> For convenience, I've also uploaded pre-built libraries for Windows and
> Linux here:
>
> http://www.erdani.dreamhosters.com/d/
>
> The updated documentation is here:
>
> http://www.erdani.dreamhosters.com/d/web/phobos/phobos.html
>
> Finally, the whole shebang with source and all as dumped from my disk is
> to be found here:
>
> http://www.erdani.dreamhosters.com/d/src/
... chopped (see orignal)
|
April 07, 2009 Re: The new, new phobos sneak preview | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alan Knowles | On Tue, 07 Apr 2009 03:34:37 +0400, Alan Knowles <alan@akbkhome.com> wrote: > Really Sweet, > > Any chance of fixing one of my pet peeves of std.stream > writeLine() - using platform dependant line endings > > Almost all the socket work I've done with this has made it a rather annoying pointless method (as it's totally non-portable). perhaps implementing > writeCR() writeLF() writeCRLF(), then letting writeLine call them, dependant on which platform would be better? > write(text, '\r'); write(text, '\n'); > I guess in-line comments in the manual are a bit outside your scope at present. > > Anyway great work. > Regards > Alan > > |
Copyright © 1999-2021 by the D Language Foundation