Re: prettyprinter
Uncrustify + UniversalIndentGUI. The latter comes packaged with uncrustify, but it might not ship with the latest version which had some D-related bugfixes.
Re: Alias/Ref Tuples ?
Am 17.12.2011 01:23, schrieb Simen Kjærås: On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch wrote: Hello, is there a way to say something like --- int a, b; AliasTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); --- without having to write an own AliasTuple template ? I want to use it for functions returning multiple values. A few small tests later: import std.typetuple; import std.typecons; import std.stdio; void main() { int a, b; TypeTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); } In other words, the language already has this. Note that TypeTuple!(a,b) = TypeTuple!(b,a) also works, but sets both a and b equal to b. Thank you ! This is exactly what I needed ! I didnt thought TypeTuple can do this.
Re: Array concat quiz
Don't forget that string is an alias for immutable(char)[]. The immutable isn't important here, but the fact that strings are arrays is. char[][][] is the real type here.
Array concat quiz
A small quiz. This Python2 code: m1 = [["A'", "B'"]] print m1 m2 = m1 + [[]] print m2 Prints: [["A'", "B'"]] [["A'", "B'"], []] What does this D2 program print? import std.stdio; void main() { string[][] m1 = [["A'", "B'"]]; writeln(m1); string[][] m2 = m1 ~ [[]]; writeln(m2); } Bye, bearophile
Re: Alias/Ref Tuples ?
On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch wrote: Hello, is there a way to say something like --- int a, b; AliasTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); --- without having to write an own AliasTuple template ? I want to use it for functions returning multiple values. A few small tests later: import std.typetuple; import std.typecons; import std.stdio; void main() { int a, b; TypeTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); } In other words, the language already has this. Note that TypeTuple!(a,b) = TypeTuple!(b,a) also works, but sets both a and b equal to b.
Re: prettyprinter
On Fri, 16 Dec 2011 23:59:58 +0100 "Paul D. Anderson" wrote: > Does anyone know of a prettyprint program for D code? > > I use a text editor rather than an IDE and it would be nice if I > could standardize the format of my code. It's not onerous to do > it by hand but it can be tedious. > > My text editor (Boxer) does pretty well on syntax highlighting > (other than not recognizing 1_000_000 as a numeric literal and > not understanding /+ +/ comment delimiters). But it doesn't > reformat code to a particular style. > > Thanks, > > Paul While this is likely a bad recommendation for Windows, indent is usable. I haven't figured out what configuration gets me what I want though. And depending on your attachment, my recommendation of Vim might not be help.
prettyprinter
Does anyone know of a prettyprint program for D code? I use a text editor rather than an IDE and it would be nice if I could standardize the format of my code. It's not onerous to do it by hand but it can be tedious. My text editor (Boxer) does pretty well on syntax highlighting (other than not recognizing 1_000_000 as a numeric literal and not understanding /+ +/ comment delimiters). But it doesn't reformat code to a particular style. Thanks, Paul
Invalid code gen with closures?
It's not a reduced test case, but the following program seg faults: import std.stdio, std.algorithm, std.range; void main() { int i = 1; auto arr = zip([0, 1, 2], ["A", "B", "C"]); // Works fine writeln( filter!((a){ return a[0] > 1; })(arr) ); // Seg faults writeln( filter!((a){ return a[0] > i; })(arr) ); } The only difference between the two delegate literals is that the second references a variable (i) in the enclosing scope, while the first only compares against a literal. This is leads me to suspect bad code for the closure which is being created. Curiously, I've only been able to reproduce this when using std.range.zip as the range to operate on.
Re: -D option = Embedded documentation
Am 16.12.2011, 19:45 Uhr, schrieb dune : I didn't realize that stuff like this will not work as expected: [code] /*** * Brief summary of what * myfunc does, forming the summary section. * * First paragraph of synopsis description. * * Second paragraph of * synopsis description. */ void myfunc() { } /*** * This is just some text that * should be added to the * documentation */ // below is the next chunk of code [/code] The second block of documentation will not show up. How is the doc generator supposed to know where that doc fragment is supposed to end up? If it's related to a declaration, put it there. If it's just a module-level comment, put it into the module doc comment.
Re: Alias/Ref Tuples ?
> There is one in dranges: > > http://dsource.org/projects/dranges > > It is not officially documented, and I don't know how good it actually is, > but here's what documentation exists: > > http://svn.dsource.org/projects/dranges/trunk/dranges/docs/reftuple.html Hmm, thanks Simen, but no. It was a simple hack I did in 10' one day to play with pointers without knowing what I was doing. I wouldn't use it if I were you, it's quite unsafe. I'm following with *great* interest all the nice changes in DMD that Kanji is adding. We may have a nice tuple syntax in 2012, who knows? Gosh, there should be a way to get extensions into DMD, like the Glasgow Haskell Compiler. Like: pragma(extension, tupleExpansionSyntax); // thanks, Kanji! Philippe
Re: Alias/Ref Tuples ?
On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch wrote: Hello, is there a way to say something like --- int a, b; AliasTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); --- without having to write an own AliasTuple template ? I want to use it for functions returning multiple values. There is one in dranges: http://dsource.org/projects/dranges It is not officially documented, and I don't know how good it actually is, but here's what documentation exists: http://svn.dsource.org/projects/dranges/trunk/dranges/docs/reftuple.html
Re: -D option = Embedded documentation
I didn't realize that stuff like this will not work as expected: [code] /*** * Brief summary of what * myfunc does, forming the summary section. * * First paragraph of synopsis description. * * Second paragraph of * synopsis description. */ void myfunc() { } /*** * This is just some text that * should be added to the * documentation */ // below is the next chunk of code [/code] The second block of documentation will not show up. Here the section of the D2 DDoc documentation I apparently missed: "Documentation comments not associated with a declaration are ignored." (from http://www.d-programming-language.org/ddoc.html) ...which in turn is not logical to me because the condition "/**" and "*/" are met. Anyway, thanks for the help; it guided me in the right direction. Thanks again
Re: -D option = Embedded documentation
Page generated by href="http://www.digitalmars.com/d/2.0/ddoc.html";>Ddoc. Ah looks like that must be updated to dlang.org too
Re: -D option = Embedded documentation
On 12/16/2011 06:12 PM, dune wrote: What? Sorry but I don't understand... What I posted was an example, in reality there is tons of code inside the d file. Thanks That is not what you said. Obviously you should always give an example that actually fails, especially when you claim it does. $ cat worksforme.d /** * documentation here */ module worksforme; /// program entry point void main(){} $ dmd -D worksforme $ cat worksforme.html worksforme worksforme documentation here void main(); program entry point Page generated by href="http://www.digitalmars.com/d/2.0/ddoc.html";>Ddoc.
Re: -D option = Embedded documentation
What I posted was an example, in reality there is tons of code inside the d file. Show the file, or part of it.
Re: -D option = Embedded documentation
What? Sorry but I don't understand... What I posted was an example, in reality there is tons of code inside the d file. Thanks
Re: -D option = Embedded documentation
Am 16.12.2011, 17:47 Uhr, schrieb dune : Never tried this before: Tried (with D2.057) to use the embedded documentation option with: /** * documentation here */ and the html files are generated but they only contain a html skeleton and no documentation. This comment doesn't refer to any code.
-D option = Embedded documentation
Never tried this before: Tried (with D2.057) to use the embedded documentation option with: /** * documentation here */ and the html files are generated but they only contain a html skeleton and no documentation. Any hints?
Re: Alias/Ref Tuples ?
I found a way doing this with a simple function: --- void explode(R, T...)(R range, ref T values) { static if(hasLength!R) assert(range.length == T.length); foreach(i, value; range) values[i] = value; } --- but a more self-documenting version would be nice.
Re: Alias/Ref Tuples ?
I think something like this is implemented in a dmd pull request.
Alias/Ref Tuples ?
Hello, is there a way to say something like --- int a, b; AliasTuple!(a, b) = tuple(4,5); assert(a == 4 && b == 5); --- without having to write an own AliasTuple template ? I want to use it for functions returning multiple values. Joshua Reusch