A few questions about safe concurrent programming assumptions

2013-10-02 Thread Nicholas Smith
Hi there, I have a few questions about what is safe to assume when writing concurrent code in D with data sharing (as opposed to message passing). After doing a fair amount of reading, I'm still slightly hazy about what shared does and doesn't guarantee. Here is the only assumption I unders

directx bindings problem

2013-10-02 Thread evilrat
i'm trying directx bindings from dsource (http://dsource.org/projects/bindings/wiki/DirectX) and encountered problem, when calling swap chain getbuffer it suddenly crashes. does anyone using it? any help please :( // Create a render target view ID3D11Texture2D* pBackBuffer; // C++ vers

Re: come back to D

2013-10-02 Thread Jacob Carlborg
On 2013-10-02 23:07, Spacen Jasset wrote: I recently heard about dub and other useful things happening in the D world after being away from it for a long while. So, as you do I thought I would see what's going on. C:\bzr\mk4k-dmd2>dub build Checking dependencies in 'C:\bzr\mk4k-dmd2' Building c

Re: val.init

2013-10-02 Thread Jacob Carlborg
On 2013-10-02 19:54, Sean Kelly wrote: I think it used to work roughly this way but was changed… um… maybe 2 years ago? It has worked like this for as long as I can remember. I've been using D for 6-7 years. -- /Jacob Carlborg

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Andrej Mitrovic
On 10/3/13, Craig Dillabaugh wrote: > void main( string[] args ) { > string str = "Hello"; > write( "file.txt", str ); > > string hello_file = readText("file.txt"); > > writeln( hello_file ); > } You can also disambiguate by preferring one symbol over another with an alias: alias

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 00:04:31 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote: Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 00:04:31 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote: Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Jonathan M Davis
On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote: > Hello, > I have the following program: > > import std.file; > import std.stdio; > > void main( string[] args ) { > string str = "Hello"; > write( "file.txt", str ); > > string hello_file = readText("file.txt"); > > writeln( hello_

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
On Wednesday, 2 October 2013 at 23:39:39 UTC, Craig Dillabaugh wrote: Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello_file = readText("file.txt"); writeln( hello_file

Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello_file = readText("file.txt"); writeln( hello_file ); } When I try to compile this I get: test.d(6): Error: std.stdio.wr

Re: Write to file in a function

2013-10-02 Thread Adam D. Ruppe
On Wednesday, 2 October 2013 at 21:44:37 UTC, Paul wrote: auto fout = File("myfile.csv", "w"); is what I'm currently using. You should be able to just pass fout to a function normally: void writeTo(File fout) { fout.writeln("info,here,etc"); } void main() { auto fout = File("myfile.csv"

Re: Write to file in a function

2013-10-02 Thread Ali Çehreli
On 10/02/2013 02:44 PM, Paul wrote: I would like to open a file before I enter a function and be able to write to it while I'm in the function. I'm not having any luck. Shared? Global? Pass a pointer to the funcion? auto fout = File("myfile.csv", "w"); is what I'm currently using. Thanks for a

Write to file in a function

2013-10-02 Thread Paul
I would like to open a file before I enter a function and be able to write to it while I'm in the function. I'm not having any luck. Shared? Global? Pass a pointer to the funcion? auto fout = File("myfile.csv", "w"); is what I'm currently using. Thanks for any assistance.

come back to D

2013-10-02 Thread Spacen Jasset
I recently heard about dub and other useful things happening in the D world after being away from it for a long while. So, as you do I thought I would see what's going on. C:\bzr\mk4k-dmd2>dub build Checking dependencies in 'C:\bzr\mk4k-dmd2' Building configuration "application", build type de

Re: mutable, const, immutable guidelines

2013-10-02 Thread Daniel Davidson
On Wednesday, 2 October 2013 at 17:07:55 UTC, Ali Çehreli wrote: On 10/02/2013 06:09 AM, Daniel Davidson wrote: > 1. If a variable is never mutated, make it const, not immutable. > 2. Make the parameter reference to immutable if that is how you will use > it anyway. It is fine to ask a favor fro

Re: Error: bad type/size of operands for the cmov instruction

2013-10-02 Thread Joseph Cassman
On Wednesday, 2 October 2013 at 19:35:58 UTC, Joseph Cassman wrote: Any ideas? Looks like my testing was flawed. The docs say that byte values are not supported so I tried the above code with the other operand sizes and it works. Missed the right combination of instructions in testing. Ple

Error: bad type/size of operands for the cmov instruction

2013-10-02 Thread Joseph Cassman
I cannot figure out why I get this error b.d(6): Error: bad type/size of operands 'cmovz' Failed: 'dmd' '-v' '-o-' 'b.d' '-I.' from the following code. void main() { asm { movCL,1; movAL,1; cmpAL,0; cmovz BL,CL; } } I get the same error when

Re: Ddoc WEB function

2013-10-02 Thread Jonathan M Davis
On Wednesday, October 02, 2013 13:46:23 Joseph Rushton Wakeling wrote: > Hello all, > > I've noticed that various places in Phobos docs use the WEB function, as in > e.g.: > > Authors: $(WEB erdani.org, Andrei Alexandrescu) > > However, this seems to be some custom function that only works with

Re: code formatting issue

2013-10-02 Thread bearophile
Alexandr Druzhinin: ? I didn't understand about trailing [] I meant something more like this, but I don't know how much of an improvement this is: import std.typecons, std.typetuple; template Foo(T1, T2) { enum Foo = 1; } void main() { int x; float f; enum y = Foo!(typeof

Re: val.init

2013-10-02 Thread Sean Kelly
On Oct 1, 2013, at 7:10 PM, Nick Sabalausky wrote: > I thought variable.init was different from T.init and gave the value of > the explicit initializer if one was used. Was I mistaken?: > > import std.stdio; > void main() > { > int a = 5; > writeln(a.init); // Outputs 0, not 5 > }

Re: mutable, const, immutable guidelines

2013-10-02 Thread Ali Çehreli
On 10/02/2013 06:09 AM, Daniel Davidson wrote: > I'm reviewing Ali's insightful presentation from 2013 DConf. I > wonder has he or anyone else followed up on the concepts or > formalized some guidelines that could achieve consensus. I have not followed up on those concepts. > 1. If a variable i

Re: Ddoc WEB function

2013-10-02 Thread H. S. Teoh
On Wed, Oct 02, 2013 at 01:46:23PM +0200, Joseph Rushton Wakeling wrote: > Hello all, > > I've noticed that various places in Phobos docs use the WEB function, as in > e.g.: > > Authors: $(WEB erdani.org, Andrei Alexandrescu) > > However, this seems to be some custom function that only wo

Re: Phobos - pure, const, safe, nothrow

2013-10-02 Thread Kenji Hara
On Wednesday, 2 October 2013 at 13:31:04 UTC, Joseph Rushton Wakeling wrote: On 29/09/13 11:37, monarch_dodra wrote: On Sunday, 29 September 2013 at 09:00:56 UTC, simendsjo wrote: What is the status of adding these annotations to phobos? It's difficult to use these until phobos gets them. E.g.

Re: code formatting issue

2013-10-02 Thread Alexandr Druzhinin
02.10.2013 22:47, bearophile пишет: It's often a good idea to use typeof to keep the code more DRY and safer. I'm sure keeping the code dry and clean is very good idea, but using typeof is rather verbose and just is unusual and verbose a little bit. Another possible solution is to put the

Re: code formatting issue

2013-10-02 Thread bearophile
Alexandr Druzhinin: auto msg = receiveOnly!( typeof(request_id), typeof(zoom), typeof(x), typeof(y), typeof(path), typeof(url) )(); Or may be I'm worrying about nonsense and better I'd start thinking about more useful things? :) It's often a go

code formatting issue

2013-10-02 Thread Alexandr Druzhinin
I'm curious what is the best way to code like this: // request_id zoom x y pathurl auto msg = receiveOnly!(size_t, zoom, uint, uint, string, string)(); or like this auto msg = receiveOnly!( typeof(request_id), typeof(zoom), typeof(x),

Re: unsigned interger overflow

2013-10-02 Thread Alexandr Druzhinin
02.10.2013 12:41, Jonathan M Davis пишет: On Wednesday, October 02, 2013 12:32:24 Alexandr Druzhinin wrote: Is it safe to replace code: uint index; // do something index++; if(index == index.max) index = index.init; by the following code uint index; // do something index++; /// I use unsigned

Re: Phobos - pure, const, safe, nothrow

2013-10-02 Thread Joseph Rushton Wakeling
On 29/09/13 11:37, monarch_dodra wrote: On Sunday, 29 September 2013 at 09:00:56 UTC, simendsjo wrote: What is the status of adding these annotations to phobos? It's difficult to use these until phobos gets them. E.g. to! and format is not pure. Most of phobos is templated, meaning it relies o

mutable, const, immutable guidelines

2013-10-02 Thread Daniel Davidson
I'm reviewing Ali's insightful presentation from 2013 DConf. I wonder has he or anyone else followed up on the concepts or formalized some guidelines that could achieve consensus. I definitely agree it would be helpful to have a 50 Ways To Improve Your D. The first thing I'd like to see is a se

Re: possible nested class/struct alias this bug

2013-10-02 Thread Eberhard
On Tuesday, 1 October 2013 at 17:35:07 UTC, Artur Skawina wrote: The symbols are looked up in parent scope first, the implicit conversion happens later. I expected the compiler to check the aliasThis member right after the current scope. The language reference only says, that undefined lookup

Ddoc WEB function

2013-10-02 Thread Joseph Rushton Wakeling
Hello all, I've noticed that various places in Phobos docs use the WEB function, as in e.g.: Authors: $(WEB erdani.org, Andrei Alexandrescu) However, this seems to be some custom function that only works with the dlang.org website build process -- if you just run regular dmd -o- -D on t

Re: unsigned interger overflow

2013-10-02 Thread Jonathan M Davis
On Wednesday, October 02, 2013 11:15:00 monarch_dodra wrote: > Last time I read TDPL, I *seem* to remember that it stated that D > targeted *exclusively* 2's complement architechture. So I'd > conclude that, even if it is not *specified*, the only logical > behavior for signed under/over flow, is t

Re: CommonType and non-built-in types

2013-10-02 Thread Joseph Rushton Wakeling
On 01/10/13 13:15, monarch_dodra wrote: By using the operator's return type, you get, basically, what the compiler believes is the "common type" that you'd get from either a T1, or a T2. Back to the code: static if (is(typeof(true ? T[0].init : T[1].init) U)) This basically checks if ternary co

Re: unsigned interger overflow

2013-10-02 Thread monarch_dodra
On Wednesday, 2 October 2013 at 08:51:43 UTC, qznc wrote: On Wednesday, 2 October 2013 at 05:41:50 UTC, Jonathan M Davis wrote: On Wednesday, October 02, 2013 12:32:24 Alexandr Druzhinin wrote: Is it safe to replace code: uint index; // do something index++; if(index == index.max) index = inde

Re: Learning D - first steps and best practices

2013-10-02 Thread John Colvin
On Wednesday, 2 October 2013 at 01:19:21 UTC, Jesse Phillips wrote: For me, if the program didn't format brackets on the same line I wouldn't use it. I'm guessing you don't use druntime or phobos then :p

Re: CommonType and non-built-in types

2013-10-02 Thread Joseph Rushton Wakeling
On 01/10/13 13:13, John Colvin wrote: This contains quite a bit of trickery. A ternary expression must evaluate to a single, statically known type. Therefore, true ? T[0].init : T[1].init will only be a valid expression if there is a common type between T[0] and T[1] Ohh! It's saying "U is the

Re: unsigned interger overflow

2013-10-02 Thread qznc
On Wednesday, 2 October 2013 at 05:41:50 UTC, Jonathan M Davis wrote: On Wednesday, October 02, 2013 12:32:24 Alexandr Druzhinin wrote: Is it safe to replace code: uint index; // do something index++; if(index == index.max) index = index.init; by the following code uint index; // do something

Re: Learning D - first steps and best practices

2013-10-02 Thread Jonathan M Davis
On Wednesday, October 02, 2013 10:38:10 qznc wrote: > On Wednesday, 2 October 2013 at 03:28:59 UTC, Jonathan M Davis > > wrote: > > On Wednesday, October 02, 2013 03:19:19 Jesse Phillips wrote: > >> For me, if the program didn't format brackets on the same line > >> I > >> wouldn't use it. If you

Re: Learning D - first steps and best practices

2013-10-02 Thread qznc
On Wednesday, 2 October 2013 at 03:28:59 UTC, Jonathan M Davis wrote: On Wednesday, October 02, 2013 03:19:19 Jesse Phillips wrote: For me, if the program didn't format brackets on the same line I wouldn't use it. If you start making things configurable, may as well improve indent's support fo

Re: val.init

2013-10-02 Thread monarch_dodra
On Wednesday, 2 October 2013 at 02:10:35 UTC, Nick Sabalausky wrote: I thought variable.init was different from T.init and gave the value of the explicit initializer if one was used. Was I mistaken?: import std.stdio; void main() { int a = 5; writeln(a.init); // Outputs 0, not 5