Re: Where to go after "Programming in D"

2016-03-02 Thread realdonaldtrump via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. My current focus is on network programming, database systems, data manipulation and software architectures for database related apps(mostly Linux

Re: Assoc Array for Concurrency

2016-03-02 Thread Chris via Digitalmars-d-learn
On Monday, 29 February 2016 at 17:38:11 UTC, ZombineDev wrote: On Monday, 29 February 2016 at 12:43:39 UTC, Chris wrote: [...] I'm almost sure that built-in AAs don't provide automatic synchronization (in my tests I hit a deadlock), but you can easily wrap the AA into a struct that does the

Re: Lazy param with nothrow

2016-03-02 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 13:41:38 UTC, Nemo wrote: On Tuesday, 1 March 2016 at 13:35:08 UTC, Andrea Fontana wrote: This very very simple function [1] won't compile. It says that param t is not nothrow. Why? What's wrong with this? http://dpaste.dzfl.pl/bfc382e62711 writeln isn't nothrow

Where to go after "Programming in D"

2016-03-02 Thread karabuta via Digitalmars-d-learn
I am almost done with the "programming in D" book. Where will you suggest a go from there. My current focus is on network programming, database systems, data manipulation and software architectures for database related apps(mostly Linux platforms with D). I am aiming to become a hardcore and

Re: Where to go after "Programming in D"

2016-03-02 Thread David DeWitt via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote: On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. My current focus is on network programming, database systems, data manipulation and

Re: Where to go after "Programming in D"

2016-03-02 Thread cym13 via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. My current focus is on network programming, database systems, data manipulation and software architectures for database related apps(mostly Linux

Re: ErrnoException

2016-03-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/1/16 12:44 AM, Mike Parker wrote: On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote: Ok, that would throw some OOM exception instead so I wouldn't need to bother with it, is there something else in the GC that would override it during class instance allocation? I am finding it weird

Re: Member Access Based On A Runtime String

2016-03-02 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 08:53:20 UTC, Adrian Matoga wrote: struct Foo { string foo = "dog"; int bar = 42; int baz = 31337; } void set(P, T)(ref P p, string name, auto ref T value) { foreach (mem; __traits(allMembers, P)) { static if

Re: Where to go after "Programming in D"

2016-03-02 Thread Ali Çehreli via Digitalmars-d-learn
On 03/01/2016 08:50 AM, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. Like others said, I would spend time on Phobos to become familiar with it; there are many gems in there. I am still reading both Mike Parker's "Learning D" and

Re: Where to go after "Programming in D"

2016-03-02 Thread David DeWitt via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. My current focus is on network programming, database systems, data manipulation and software architectures for database related apps(mostly Linux

Re: Where to go after "Programming in D"

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 19:59:19 UTC, Ali Çehreli wrote: On 03/01/2016 08:50 AM, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. Like others said, I would spend time on Phobos to become familiar with it; there are many gems in

Re: Warning: statement is not reachable

2016-03-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote: foreach(attr; __traits(getAttributes, S)) { static if (is(attr == Tag)) { return true; } } return false; }(); } void main() { static @Tag struct

Re: Where to go after "Programming in D"

2016-03-02 Thread tsbockman via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote: On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am aiming to become a hardcore and better coder(quality code) than you :) Please suggest. I'd probably skim thru the Language Reference and Phobos. Just to add to this -

Re: Where to go after "Programming in D"

2016-03-02 Thread Ali Çehreli via Digitalmars-d-learn
On 03/01/2016 12:40 PM, Daniel Kozak wrote: Yep, I have my copy (even print one) for some time on my desk :) https://twitter.com/kozzi11/status/700340359927349249 Nooo! :( :p Ali

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
I forgot to add that the "RenderText(font,0,0,"FPS: "~to!string(fps));" was an older version where it wasn't const char *, but string. And I was using a foreach, so no null-termination. But that's beyond the point of not using GC.

Re: Template mixins and struct constructors

2016-03-02 Thread Adrian Matoga via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote: On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote: (...) You can use string mixins: template AddField(T) { enum AddField = T.stringof ~ ` b; this(Args...)(` ~ T.stringof ~ ` b, auto ref Args args)

Re: Template mixins and struct constructors

2016-03-02 Thread Adrian Matoga via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote: OK maybe this one: template AddField(T) { T b; this(Args...)(T b, auto ref Args args) { this.b = b; this(args); } this(int a) { this.a = a; } } struct Bar { int a; mixin

Three Cool Things about D?

2016-03-02 Thread Wulfrick via Digitalmars-d-learn
It looks like the link in wiki.dlang.org/Videos to Andrei's "Three Cool Things about D" is dead. Do you know of another link?

Re: Warning: statement is not reachable

2016-03-02 Thread ag0aep6g via Digitalmars-d-learn
On 01.03.2016 22:30, Tamas wrote: struct Tag {} template isTagged(S) { enum bool isTagged = delegate() { foreach(attr; __traits(getAttributes, S)) { static if (is(attr == Tag)) { return true; } }

Re: Weird struct stuff

2016-03-02 Thread Ali Çehreli via Digitalmars-d-learn
On 03/01/2016 05:11 PM, asdf wrote: > import std.stdio : writeln; > > struct foo > { > long* bar; > > this (long l) > { > long d = l; > bar = Unfortunately, 'bar' is pointing at the temporary stack-based variable 'd'. > } > } > > int main() > { > foo

typeof(0x123f).stringof

2016-03-02 Thread ric maicle via Digitalmars-d-learn
Shouldn't this print 'float'? writeln(typeof(0x123f).stringof);

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 05:04:37 UTC, David G. Maziero wrote: char[256] buff; va_list ap; va_start( ap, text ); sprintf( buff.ptr, text, ap ); va_end( ap ); Sorry again, where it reads "sprintf" should be "vsprintf".

Re: Installing DUB on OSX

2016-03-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-03-02 05:12, Joel wrote: Wait a minute, I get this: Build directory .dub/build/application-debug-posix.osx-x86_64-dmd_2070-2EBE4466CF46539CC1D524962E530835/ is not writable. Falling back to direct build in the system's temp folder. Is ~/.dub writable by you? What about the sub

Template mixins and struct constructors

2016-03-02 Thread Adrian Matoga via Digitalmars-d-learn
I can do this: struct Foo { int a; string b; this(int a) { this.a = a; } this(Args...)(string b, auto ref Args args) { this.b = b; this(args); } } unittest { auto foo1 = Foo(5); auto foo2 = Foo("foo", 15); } However, the following code is invalid:

Re: In language tooling

2016-03-02 Thread sigod via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 02:36:50 UTC, Charles wrote: Watched a video on Jonathan Blow's language that he's developing, and he has a pretty neat idea of having tools being part of the language. Looking at the first 15 minutes(https://www.youtube.com/watch?v=OHZwYYW9koI) or so of the

Re: Template mixins and struct constructors

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote: I can do this: struct Foo { int a; string b; this(int a) { this.a = a; } this(Args...)(string b, auto ref Args args) { this.b = b; this(args); } } unittest { auto foo1 = Foo(5); auto

Re: Where to go after "Programming in D"

2016-03-02 Thread karabuta via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 01:14:15 UTC, tsbockman wrote: On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote: On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am aiming to become a hardcore and better coder(quality code) than you :) Please suggest. I'd probably skim

Re: Three Cool Things about D?

2016-03-02 Thread Wulfrick via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 20:15:00 UTC, Wulfrick wrote: It looks like the link in wiki.dlang.org/Videos to Andrei's "Three Cool Things about D" is dead. Do you know of another link? Maybe this? https://www.youtube.com/watch?v=3NihZVcZqto

Re: Three Cool Things about D?

2016-03-02 Thread Ali Çehreli via Digitalmars-d-learn
On 03/01/2016 12:17 PM, Wulfrick wrote: On Tuesday, 1 March 2016 at 20:15:00 UTC, Wulfrick wrote: It looks like the link in wiki.dlang.org/Videos to Andrei's "Three Cool Things about D" is dead. Do you know of another link? Maybe this? https://www.youtube.com/watch?v=3NihZVcZqto Yes, that

Weird struct stuff

2016-03-02 Thread asdf via Digitalmars-d-learn
import std.stdio : writeln; struct foo { long* bar; this (long l) { long d = l; bar = } } int main() { foo f = foo(12345); writeln(*f.bar); //writefoo(f); writeln(*f.bar); return 0; } void writefoo(foo f) { writeln(*f.bar); } If I

In language tooling

2016-03-02 Thread Charles via Digitalmars-d-learn
Watched a video on Jonathan Blow's language that he's developing, and he has a pretty neat idea of having tools being part of the language. Looking at the first 15 minutes(https://www.youtube.com/watch?v=OHZwYYW9koI) or so of the video, is this something that could be accomplished in D with

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 01:39:13 UTC, David G. Maziero wrote: Consider the following function: void RenderText( FontBMP font, int x, int y, const char* text ) { for( int r=0; text[r]!='\0'; ++r ) { You're asking for trouble here. There's no guarantee that any D

Re: Installing DUB on OSX

2016-03-02 Thread Joel via Digitalmars-d-learn
On Sunday, 28 February 2016 at 11:06:26 UTC, Jacob Carlborg wrote: On 2016-02-28 04:33, Joel wrote: Things just silently not work. Joels-MacBook-Pro:packages joelcnz$ ls -l -a ~/ | grep dub drwxr-xr-x4 joelcnz staff 136 26 Sep 12:47 .dub Joels-MacBook-Pro:packages joelcnz$ That

std.range: Lockstep vs. Zip

2016-03-02 Thread Manuel Maier via Digitalmars-d-learn
Hi there, I was wondering why I should ever prefer std.range.lockstep over std.range.zip. In my (very limited) tests std.range.zip offered the same functionality as std.range.lockstep, i.e. I was able to iterate using `foreach(key, value; std.range.zip(...)) {}` which, according to the docs,

Re: Warning: statement is not reachable

2016-03-02 Thread Tamas via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 09:37:03 UTC, Johan Engelen wrote: On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote: Thanks, fixing this single issue solved the compiler crash too. Did the compiler crash? Or just exit? (a crash would still be a bug) Crashed, just like in the case of

Re: Three Cool Things about D?

2016-03-02 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 20:26:36 UTC, Ali Çehreli wrote: On 03/01/2016 12:17 PM, Wulfrick wrote: On Tuesday, 1 March 2016 at 20:15:00 UTC, Wulfrick wrote: It looks like the link in wiki.dlang.org/Videos to Andrei's "Three Cool Things about D" is dead. Do you know of another link? Maybe

Re: Warning: statement is not reachable

2016-03-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote: My d code doesn't compile using ldc2 1.0.0-alpha or anything above DMD v2.068.0 Using these compilers I get a lot of "Warning: statement is not reachable". Then the both compiler crashes. ldc2 -w reach.d dmd -w reach.d reach.d:

Auto field member?

2016-03-02 Thread Hanh via Digitalmars-d-learn
Hi, Is there a way to declare a class field 'auto'? I have a problem when I try to 'promote' a variable to a field. import std.csv; import std.typecons; class Test { this() { auto text = "Joe,Carpenter,30\nFred,Blacksmith,40\r\n"; auto reader =

Re: typeof(0x123f).stringof

2016-03-02 Thread ric maicle via Digitalmars-d-learn
On Wednesday, 02 March, 2016 10:23 AM, ric maicle wrote: Shouldn't this print 'float'? writeln(typeof(0x123f).stringof); Oh man, I should better sleep!

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
I figured out what I wanted. Thanks for your answer Mike, sorry to bother you though. Here's the result: void RenderText( FontBMP font, int x, int y, const char* text, ... ) { SDL_Rect rect1, rect2; rect2.x = x; rect2.y = y; rect2.w = font.width;

Re: Warning: statement is not reachable

2016-03-02 Thread Tamas via Digitalmars-d-learn
Thanks, fixing this single issue solved the compiler crash too. Thanks also for the tip using hasUDA! Works nicely!

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread cym13 via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 05:04:37 UTC, David G. Maziero wrote: I figured out what I wanted. Thanks for your answer Mike, sorry to bother you though. [...] Even null-terminated be sure to profile your loop, for isn't garanteed to be faster than foreach at all and foreach is definitely

Re: Template mixins and struct constructors

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 13:18:23 UTC, Adrian Matoga wrote: On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote: On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote: (...) You can use string mixins: template AddField(T) { enum AddField = T.stringof ~ `

Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
Hi. I think it's the first time I post here. I've been flirting with D for some time, but now I decided to start a little project. Consider the following function: void RenderText( FontBMP font, int x, int y, const char* text ) { SDL_Rect rect1, rect2; rect2.x = x;

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
Yes, I'm aware of the null-termination thing. I might have pasted code that I already changed. But I already messed with sformat, and it seems that it does use the GC. I've put @nogc in RenderText, and the compiler says sformat uses GC, so I don't know. But the thing is, I don't want to

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread David G. Maziero via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 05:04:37 UTC, David G. Maziero wrote: void RenderText( FontBMP font, int x, int y, const char* text, Just one more correction for future reference, RenderText should be extern(C) void RenderText... in order for it to work correctly with va_start/etc.

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Luis via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 04:12:13 UTC, Mike Parker wrote: On Wednesday, 2 March 2016 at 01:39:13 UTC, David G. Maziero wrote: Consider the following function: void RenderText( FontBMP font, int x, int y, const char* text ) { for( int r=0; text[r]!='\0'; ++r ) {

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 10:57:35 UTC, Luis wrote: Read https://dlang.org/spec/arrays.html#strings and try to use std.string.toStringz (http://dlang.org/phobos/std_string.html#.toStringz) Yes, but that's not what you use when you want to avoid allocation.

Re: Template mixins and struct constructors

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote: I can do this: struct Foo { int a; string b; this(int a) { this.a = a; } this(Args...)(string b, auto ref Args args) { this.b = b; this(args); } } unittest { auto foo1 = Foo(5); auto

Re: Template mixins and struct constructors

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 14:50:15 UTC, Adrian Matoga wrote: On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote: OK maybe this one: template AddField(T) { T b; this(Args...)(T b, auto ref Args args) { this.b = b; this(args); } this(int a) {

How to set the Path to access the phone on windows?

2016-03-02 Thread FrankLike via Digitalmars-d-learn
Hi,everyone: I want to access the phone on Windows7,but get a error: std.file.FileException@std\file.d(3368):\\computer\myPhone\SDCard\myfiles: 0x0041c112 0x0043E601 The error is only on Windows7,it's ok on linux,I doubt it's not a error with file.d,maybe a

Warning: statement is not reachable

2016-03-02 Thread Tamas via Digitalmars-d-learn
My d code doesn't compile using ldc2 1.0.0-alpha or anything above DMD v2.068.0 Using these compilers I get a lot of "Warning: statement is not reachable". Then the both compiler crashes. I minimized the code to get the same warning, although the compilers do not crash this time, so this

Re: Where to go after "Programming in D"

2016-03-02 Thread karabuta via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 17:53:27 UTC, David DeWitt wrote: On Tuesday, 1 March 2016 at 17:21:16 UTC, David DeWitt wrote: On Tuesday, 1 March 2016 at 16:50:12 UTC, karabuta wrote: I am almost done with the "programming in D" book. Where will you suggest a go from there. My current focus is

Re: Auto field member?

2016-03-02 Thread Rikki Cattermole via Digitalmars-d-learn
On 02/03/16 3:50 PM, Hanh wrote: Hi, Is there a way to declare a class field 'auto'? I have a problem when I try to 'promote' a variable to a field. import std.csv; import std.typecons; class Test { this() { auto text = "Joe,Carpenter,30\nFred,Blacksmith,40\r\n";

Re: Formatting a string on a variadic parameter function without using GC

2016-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 04:12:13 UTC, Mike Parker wrote: char buf[1024]; Ugh. And the proper declaration in D: char[1024] buf;

Re: Warning: statement is not reachable

2016-03-02 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote: Thanks, fixing this single issue solved the compiler crash too. Did the compiler crash? Or just exit? (a crash would still be a bug)

Re: std.range: Lockstep vs. Zip

2016-03-02 Thread HSteffenhagen via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 08:51:07 UTC, Manuel Maier wrote: Hi there, I was wondering why I should ever prefer std.range.lockstep over std.range.zip. In my (very limited) tests std.range.zip offered the same functionality as std.range.lockstep, i.e. I was able to iterate using

Re: Installing DUB on OSX

2016-03-02 Thread Joel via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 08:55:40 UTC, Jacob Carlborg wrote: On 2016-03-02 05:12, Joel wrote: Wait a minute, I get this: Build directory .dub/build/application-debug-posix.osx-x86_64-dmd_2070-2EBE4466CF46539CC1D524962E530835/ is not writable. Falling back to direct build in the system's

Re: Template mixins and struct constructors

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
Dne 2.3.2016 v 21:39 Adam D. Ruppe via Digitalmars-d-learn napsal(a): On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote: Is it by design or is it a bug? And, if it is by design, what is the reason for that? That's by design. It allows you to override names from a template

Re: Template mixins and struct constructors

2016-03-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote: Is it by design or is it a bug? And, if it is by design, what is the reason for that? That's by design. It allows you to override names from a template mixin like inheritance but no runtime cost. Read my tip of the week here

Unable to instantiate template with same name as function

2016-03-02 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. I have a function I want to make CTFE-able as a template. string ta(string s) { return s ~ "1"; } template ta(string s) { enum ta = ta(s); } void main() { string s = ta!"s"; } Compiling the above I get the errors: (2): Error: forward reference of variable ta (3): Error: template instance

Re: Unable to instantiate template with same name as function

2016-03-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 03, 2016 11:42:13 Shriramana Sharma via Digitalmars-d-learn wrote: > Hello. I have a function I want to make CTFE-able as a template. > > string ta(string s) { return s ~ "1"; } > template ta(string s) { enum ta = ta(s); } > void main() { string s = ta!"s"; } > > Compiling the

Re: Installing DUB on OSX

2016-03-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-03-02 23:41, Joel wrote: I don't seem to have a folder 'build' there. It all seems writable. Hmm, that's really weird. I guess that's the folder it fails to write. Is it running as a different user. What if you change the permissions to allow everything, i.e. "chmod 777 ~/.dub".

Re: Unable to instantiate template with same name as function

2016-03-02 Thread Daniel Kozak via Digitalmars-d-learn
Dne 3.3.2016 v 07:12 Shriramana Sharma via Digitalmars-d-learn napsal(a): Hello. I have a function I want to make CTFE-able as a template. string ta(string s) { return s ~ "1"; } template ta(string s) { enum ta = ta(s); } void main() { string s = ta!"s"; } Compiling the above I get the