Re: Force inline

2017-02-20 Thread Daniel Kozak via Digitalmars-d-learn
Dne 21.2.2017 v 08:31 Johan Engelen via Digitalmars-d-learn napsal(a): On Monday, 20 February 2017 at 13:16:15 UTC, Jonathan M Davis wrote: dmd is great for fast compilation and therefore it's great for development. However, while it produces decent binaries, and it may very well do certain

Re: Force inline

2017-02-20 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 20 February 2017 at 13:16:15 UTC, Jonathan M Davis wrote: dmd is great for fast compilation and therefore it's great for development. However, while it produces decent binaries, and it may very well do certain optimizations better than the gcc or llvm backends do This I find hard

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
"H. S. Teoh via Digitalmars-d-learn" wrote: On Mon, Feb 20, 2017 at 05:39:30PM +, ketmar via Digitalmars-d-learn wrote: foreach (auto n; arr) oops. good job, auto! Haha... in this case you want to actually just drop `auto` completely. :-D But yeah, there are some funny inconsistencies

Re: Multiplatform development[DOUBT]

2017-02-20 Thread Adam D. Ruppe via Digitalmars-d-learn
Yes, D works on the major desktop platforms easily. There isn't an ANSI standard but there's just one D language.

Multiplatform development[DOUBT]

2017-02-20 Thread wiki via Digitalmars-d-learn
A friend of mine asked me a question today if D is multiplatform I particularly believe it is but I wanted to know the opinion of who has already developed the most time in it and even of the developers because I looked for some cisa on the net about such subject and did not find anything that

Re: align(n) outside struct useless?

2017-02-20 Thread kinke via Digitalmars-d-learn
On Monday, 20 February 2017 at 22:45:09 UTC, Adam D. Ruppe wrote: I don't believe it does anything (except perhaps pad bytes again) for a stack-defined struct. LDC does respect explicit type-alignments when allocating instances on the stack. The instances are obviously padded to their full

Re: align(n) outside struct useless?

2017-02-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 February 2017 at 20:45:27 UTC, Michael Coulombe wrote: I can't figure out how to set the alignment of a struct using align(n) on the outside of the struct. align(n) on the outside of a struct will pad the struct as a whole to meet that size requirement. So it changes the sizeof

Re: align(n) outside struct useless?

2017-02-20 Thread Ali Çehreli via Digitalmars-d-learn
On 02/20/2017 12:45 PM, Michael Coulombe wrote: I can't figure out how to set the alignment of a struct using align(n) on the outside of the struct. Only align on the fields (default or annotated) seems to work. I get the same results back to at least DMD 2.065... Is this a bug or am I using it

Re: Returning the address of a reference return value in @safe code - 2.072 regression?

2017-02-20 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 20 February 2017 at 20:54:31 UTC, Jack Stouffer wrote: On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen wrote: ... Yeah, this is another regression caused by DIP1000. Christ. For the record, the current list of regressions caused by DIP1000

Re: Returning the address of a reference return value in @safe code - 2.072 regression?

2017-02-20 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 20 February 2017 at 20:49:43 UTC, Johan Engelen wrote: ... Yeah, this is another regression caused by DIP1000. Christ.

Returning the address of a reference return value in @safe code - 2.072 regression?

2017-02-20 Thread Johan Engelen via Digitalmars-d-learn
This code compiles with 2.071, but not with 2.072 nor 2.073: ``` struct S { int i; auto ref foo() @safe { return i; } auto bar() @safe { return (); // <-- Error } } void main() { auto s = S(); s.bar();

align(n) outside struct useless?

2017-02-20 Thread Michael Coulombe via Digitalmars-d-learn
I can't figure out how to set the alignment of a struct using align(n) on the outside of the struct. Only align on the fields (default or annotated) seems to work. I get the same results back to at least DMD 2.065... Is this a bug or am I using it wrong? align(32) struct A { ubyte padding; }

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Feb 20, 2017 at 05:39:30PM +, ketmar via Digitalmars-d-learn wrote: > Ali Çehreli wrote: > > > Correction: It's actually the 'auto attribute' in D with the > > venerable responsibility of "The auto attribute is used when there > > are no other attributes and type inference is

Re: Class Order Style

2017-02-20 Thread Jolly James via Digitalmars-d-learn
On Monday, 20 February 2017 at 13:50:26 UTC, ketmar wrote: just add ddoc documentation to 'em, and then it doesn't matter in which order they are declared: people will generate documentation to find out how to use your code. ;-) ah okay, thx But what about this? class A { private: int

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread Ali Çehreli via Digitalmars-d-learn
On 02/20/2017 07:00 AM, timmyjose wrote: > slice can be spawned off into a brand new array upon assigning data to > it (in the book "Learning D", which I find very nice so far). It's not assigning data to a slice, but adding elements to it: It *may* spawn off a new array. You can use .capacity

Re: Force inline

2017-02-20 Thread ketmar via Digitalmars-d-learn
H. S. Teoh wrote: Having said all that, though, have you used a profiler to determine whether or not your performance bottleneck is really at the function in question? I find that 90% of the time what I truly believe should be inlined actually doesn't make much difference; the bottleneck is

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Feb 20, 2017 at 03:00:05PM +, timmyjose via Digitalmars-d-learn wrote: [...] > Just one question about the compilers though - I read on the Wiki that > there are three main compiler distros - dmd, ldc, and gdc. I code > primarily on a mac, and I have installed both dmd and ldc. A lot

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
Ali Çehreli wrote: Correction: It's actually the 'auto attribute' in D with the venerable responsibility of "The auto attribute is used when there are no other attributes and type inference is desired." Good job, auto! :o) foreach (auto n; arr) oops. good job, auto!

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread Ali Çehreli via Digitalmars-d-learn
On 02/20/2017 06:44 AM, timmyjose wrote: > 3). Not so much a fan of "auto", but it does have its uses, of course. For completeness, D's 'auto' does not have the same meaning as C++'s auto. Wait... it actually has! :) But with the meaning of the 'auto' keyword from the olden C days: automatic

Re: Force inline

2017-02-20 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Feb 20, 2017 at 05:16:15AM -0800, Jonathan M Davis via Digitalmars-d-learn wrote: [...] > Regardless, if performance is your #1 concern, then I would suggest > that you compile with ldc and not dmd. [...] +1. If you are concerned about performance enough to worry whether the compiler

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Monday, 20 February 2017 at 15:27:16 UTC, ag0aep6g wrote: On 02/20/2017 03:44 PM, timmyjose wrote: Things I don't like so much: 1). The std.range: iota function(?) is pretty nice, but the naming seems a bit bizarre, but quite nice to use. Yeah, the name is weird. A little googling

Re: Getting nice print of struct for debugging

2017-02-20 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 20 February 2017 at 16:18:58 UTC, Paul Backus wrote: On Monday, 20 February 2017 at 16:04:17 UTC, Martin Tschierschke wrote: Hello, I have a little program where I am filling a struct with values from an regex match. Now I want to display the content of the struct for debugging

Re: Getting nice print of struct for debugging

2017-02-20 Thread Paul Backus via Digitalmars-d-learn
On Monday, 20 February 2017 at 16:04:17 UTC, Martin Tschierschke wrote: Hello, I have a little program where I am filling a struct with values from an regex match. Now I want to display the content of the struct for debugging purpose. I believe the easiest way to do this is to define a

Getting nice print of struct for debugging

2017-02-20 Thread Martin Tschierschke via Digitalmars-d-learn
Hello, I have a little program where I am filling a struct with values from an regex match. Now I want to display the content of the struct for debugging purpose. If struct is named MyStruct I can print a list of the field names with: foreach(fieldname;FieldNameTuple!MyStruct){writef("%s

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ag0aep6g via Digitalmars-d-learn
On 02/20/2017 03:44 PM, timmyjose wrote: Things I don't like so much: 1). The std.range: iota function(?) is pretty nice, but the naming seems a bit bizarre, but quite nice to use. Yeah, the name is weird. A little googling suggests it comes from C++ [1] which took it from APL. 2). The

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Monday, 20 February 2017 at 14:54:58 UTC, Adam D. Ruppe wrote: On Monday, 20 February 2017 at 14:44:41 UTC, timmyjose wrote: My confusion is this - the declaration of the array is arr [last-dimension]...[first-dimension], but the usage is arr[first-dimension]...[last-dimension]. Am I

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Monday, 20 February 2017 at 14:52:43 UTC, ketmar wrote: timmyjose wrote: Suppose I have a simple 2 x 3 array like so: import std.stdio; import std.range: iota; void main() { // a 2 x 3 array int [3][2] arr; foreach (i; iota(0, 2)) { foreach(j; iota(0, 3)) {

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: Very interesting reading about your experiences! tnx. ;-) one thing I've observed is that so far (very very early of course) D appears to be a lot more intuitive than C++ yeah. i almost finished writing my own nntp/email client (actually, i'm writing this post with it).

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Sunday, 19 February 2017 at 12:45:49 UTC, ketmar wrote: timmyjose wrote: a). So the GC is part of the runtime even if we specify @nogc yes. GC is basically just a set of functions and some supporting data structures, it is compiled in druntime. @nogc doesn't turn it off, if says that

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 February 2017 at 14:44:41 UTC, timmyjose wrote: My confusion is this - the declaration of the array is arr [last-dimension]...[first-dimension], but the usage is arr[first-dimension]...[last-dimension]. Am I missing something here? I've never understood how anyone could

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread ketmar via Digitalmars-d-learn
timmyjose wrote: Suppose I have a simple 2 x 3 array like so: import std.stdio; import std.range: iota; void main() { // a 2 x 3 array int [3][2] arr; foreach (i; iota(0, 2)) { foreach(j; iota(0, 3)) { arr[i][j] = i+j; }

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Sunday, 19 February 2017 at 12:31:51 UTC, ag0aep6g wrote: On 02/19/2017 12:51 PM, timmyjose wrote: a). So the GC is part of the runtime even if we specify @nogc Yup. @nogc is per function, not per program. Other functions are allowed to use the GC. b). Do we manually trigger the GC

Re: Create doc simultaneously with compilation

2017-02-20 Thread kinke via Digitalmars-d-learn
On Sunday, 19 February 2017 at 22:44:54 UTC, Satoshi wrote: Why is not possible to create documentation, compile code and generate header files simultaneously? When I pass -D and -Dd flags to ldc2 command it won't create doc until I don't pass -o- flag too. That is an LDC bug which has been

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Sunday, 19 February 2017 at 03:17:08 UTC, Seb wrote: On Saturday, 18 February 2017 at 21:09:20 UTC, ag0aep6g wrote: 5. Supposing I devote the time and energy and get up to speed on D, would the core language team be welcoming if I feel like I can contribute? Absolutely. Anyone is welcome

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Sunday, 19 February 2017 at 12:40:10 UTC, Guillaume Piolat wrote: On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: My rudimentary knowledge of the D ecosystem tells me that there is a GC in D, but that can be turned off. Is this correct? Also, some threads online mention that

Re: Hello, folks! Newbie to D, have some questions!

2017-02-20 Thread timmyjose via Digitalmars-d-learn
On Sunday, 19 February 2017 at 15:22:50 UTC, bachmeier wrote: On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote: 4. I have heard good reports of D's metaprogramming capabilities (ironically enough, primarily from a thread on the Rust user group), and coming from a Common Lisp (and

Re: Class Order Style

2017-02-20 Thread ketmar via Digitalmars-d-learn
Jolly James wrote: How to sort the members of a class? like: 1. properties then 2. private 3. methods 4. ctors ... and so on. are there any recommendations? And what is better? just add ddoc documentation to 'em, and then it doesn't matter in which order they are declared: people will

Re: Force inline

2017-02-20 Thread ketmar via Digitalmars-d-learn
Moritz Maxeiner wrote: I don't know, but I'd guess that the length of a function is not as important for the consideration of being inlined as its semantics. yep. basically, dmd doesn't like anything other than very simple if/else conditions. sometimes it likes if (cond0) return n0; else if

Class Order Style

2017-02-20 Thread Jolly James via Digitalmars-d-learn
How to sort the members of a class? like: 1. properties then 2. private 3. methods 4. ctors ... and so on. are there any recommendations? And what is better? class A { private: int a; int b; public: int c; int d; } or class A { private { int a; int b; }

Re: Force inline

2017-02-20 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 20 February 2017 at 12:47:43 UTC, berni wrote: pragma(inline, true) doesn't work out well: int bar; void main(string[] args) { if (foo()) {} } bool foo() { pragma(inline, true) if (bar==1) return false; if (bar==2) return false; return true; } with dmd -inline

Re: Force inline

2017-02-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 20, 2017 12:47:43 berni via Digitalmars-d-learn wrote: > with > > > dmd -inline test.d > > I get > > > test.d(8): Error: function test.foo cannot inline function > > When I remove -inline, it compiles, but seems not to inline. I > cannot tell from this small example, but with

Re: Force inline

2017-02-20 Thread berni via Digitalmars-d-learn
On Sunday, 19 February 2017 at 20:00:00 UTC, Daniel Kozak wrote: Dne 19.2.2017 v 20:19 berni via Digitalmars-d-learn napsal(a): Is it possible to force a function to be inlined? Comparing a C++ and a D program, the main difference in speed (about 20-30%) is, because I manage to force g++ to

Re: Create doc simultaneously with compilation

2017-02-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 19, 2017 22:44:54 Satoshi via Digitalmars-d-learn wrote: > Why is not possible to create documentation, compile code and > generate header files simultaneously? > > When I pass -D and -Dd flags to ldc2 command it won't create doc > until I don't pass -o- flag too. I don't know