Re: core.stdc.config

2014-01-29 Thread Jacob Carlborg
On 2014-01-30 05:42, Mike Parker wrote: All of the core.* modules are part of DRuntime, not Phobos. Unfortunately none of the core.stdc.* modules are documented. It's understandable that duplicating the documentation of the C library is not done since that would require extra work. But it wo

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Maxim Fomin
On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote: On Wednesday, 29 January 2014 at 16:15:36 UTC, Tobias Pankrath wrote: On Wednesday, 29 January 2014 at 16:01:08 UTC, Cooler wrote: Do you read my post? I am answering... why do I need fun3() if I already have fun1() and fun2(). fu

Re: core.stdc.config

2014-01-29 Thread Mike Parker
On 1/30/2014 12:28 PM, Craig Dillabaugh wrote: Is it not part of Phobos? Are there standard modules in D that are not included in Phobos? If so, where would one find the list of these modules. All of the core.* modules are part of DRuntime, not Phobos.

Re: Sorting structs?

2014-01-29 Thread Jesse Phillips
On Thursday, 30 January 2014 at 03:00:43 UTC, Paul-Andre wrote: On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov wrote: On Wednesday, 29 January 2014 at 10:30:06 UTC, Boomerang wrote: // also it's worth using ref const to avoid // unnecessary copies I am new to D. Why shou

Re: Source code annotations alla Java

2014-01-29 Thread Jay Norwood
On Friday, 21 January 2011 at 20:50:39 UTC, Jonathan M Davis wrote: On Friday, January 21, 2011 12:36:23 Ary Manzana wrote: On 1/20/11 5:48 PM, Jacob Carlborg wrote: > On 2011-01-20 21:34, Steven Schveighoffer wrote: >> On Thu, 20 Jan 2011 15:03:55 -0500, Jacob Carlborg >> wrote: >>> On 2011-

core.stdc.config

2014-01-29 Thread Craig Dillabaugh
So, there is a module core.stdc.config (referenced here): http://dlang.org/interfaceToC.html That is presumably part of the D Standard library. I am curious to know why no mention of this library is included at: http://dlang.org/phobos/index.html Is it not part of Phobos? Are there standard

Re: Sorting structs?

2014-01-29 Thread Paul-Andre
On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov wrote: On Wednesday, 29 January 2014 at 10:30:06 UTC, Boomerang wrote: // also it's worth using ref const to avoid // unnecessary copies I am new to D. Why should someone use "ref const" instead of "in"?

Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000

2014-01-29 Thread Xavier Bigand
Le 22/01/2014 14:13, Flamaros a écrit : On Wednesday, 22 January 2014 at 02:11:02 UTC, TheFlyingFiddle wrote: On Saturday, 18 January 2014 at 19:40:38 UTC, Xavier Bigand wrote: I am not sure the issue come really from my code, cause it just works fine on ATI cards, I do something Nvidia drivers

Re: Message passing pattern matching

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 21:50:28 UTC, Casper Færgemand wrote: A small example: while (true) { receive( (Tid tid, AddTid _) {some code} (Tid tid, RemoveTid _) {some other code} (string s) {broadcast stuff} ) } struct AddTid {} struct RemoveTid {} From where I sit that'

Re: Message passing pattern matching

2014-01-29 Thread Casper Færgemand
A small example: while (true) { receive( (Tid tid, AddTid _) {some code} (Tid tid, RemoveTid _) {some other code} (string s) {broadcast stuff} ) } struct AddTid {} struct RemoveTid {}

Message passing pattern matching

2014-01-29 Thread Casper Færgemand
Hey, I'm handling concurrency with message passing, previously with D's concurrency, now with Vibe-d, which I assume works the same way. My app is a chat server, and when a connection is opened to a client, I store the Tid of the thread (or fibre?) handling sending messages out to the client.

Re: A small question default values in tmplate-functions

2014-01-29 Thread Gary Willoughby
On Wednesday, 29 January 2014 at 18:24:22 UTC, Uplink_Coder wrote: is it legal or is it not ? Yours isn't, no.

Re: Win32 with D: Using RegisterClassExA instead of RegisterClass

2014-01-29 Thread BeschBesch
You need to fill in the cbSize field like so: wce.cbSize = WNDCLASSEXA.sizeof; Ungh. How embarassing. Now it works, thank you.

Static Factory

2014-01-29 Thread Frustrated
(Guess is didn't get sent, I guess I'm just a big spam bot cause I keep getting flagged every post) The following code demonstrates a way to have an easy factory in D requiring very little work. I imagine it can be improved to handle the abstract case(basically dependencies/constraints). Any ide

Re: A small question default values in tmplate-functions

2014-01-29 Thread Tobias Pankrath
valid according to spec ? Only trailing parameter can have default arguments.

Re: A small question default values in tmplate-functions

2014-01-29 Thread Uplink_Coder
import std.stdio; import core.vararg; auto veryStableAPI(bool brave = false)(string parameter, ...) { static if (!brave) { pragma(msg, "I'm not brave"); } else { pragma(msg, "I'm very brave"); } } void main(string[]

Re: N-body bench

2014-01-29 Thread Stanislav Blinov
Regarding dmd it looks awfully similar to this: http://d.puremagic.com/issues/show_bug.cgi?id=9449 I'd need to do some more runs though.

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote: Where argument has the same length? After function call, or inside function? I don't understand what my intention should be to push me to use fun3()? Where argument has the same length? After function call, or inside function? I don'

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Sergei Nosov
On Wednesday, 29 January 2014 at 14:48:12 UTC, Cooler wrote: If, however, in fun3 you change the size of the array - it may reallocate. Like, if you're appending to `x` - it will allocate a new array and make x point to it. Now `a` and `x` point to distinct arrays. And any change you do using `

Re: Any library with OAuth support?

2014-01-29 Thread ilya-stromberg
On Wednesday, 22 January 2014 at 11:58:17 UTC, Rikki Cattermole wrote: On Wednesday, 22 January 2014 at 11:14:22 UTC, ilya-stromberg wrote: Do you know any library with OAuth support? Not currently. But I can add it to my todo list for Cmsed[0]. [0] https://github.com/rikkimax/Cmsed Yes, it

Re: N-body bench

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 16:54:54 UTC, bearophile wrote: Stanislav Blinov: I meant how to make it compile with ldc2? I've translated the code, it compiles and works with dmd (although segfaults in -release mode for some reason, probably a bug somewhere). But with ldc2: nbody.d(68):

Re: Keywords: How to trick the compiler?

2014-01-29 Thread Ary Borenszweig
On 1/28/14, 3:17 PM, Chris wrote: On Tuesday, 28 January 2014 at 17:18:44 UTC, Ary Borenszweig wrote: On 1/28/14, 11:30 AM, bearophile wrote: Ary Borenszweig: In Ruby you can do this: class Foo def end 1 end end Foo.new.end Ruby is a different language from D, they define "code safet

Re: Keywords: How to trick the compiler?

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 17:11:32 UTC, Ary Borenszweig wrote: Yes, as there are other ways for body: _body, _body, Body, HtmlBody, etc. But "body" is the best one. torso? ;)

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 16:54:27 UTC, Cooler wrote: On Wednesday, 29 January 2014 at 16:36:44 UTC, Stanislav Blinov wrote: On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote: Where argument has the same length? After function call, or inside function? I don't understand what

Re: N-body bench

2014-01-29 Thread bearophile
Stanislav Blinov: I meant how to make it compile with ldc2? I've translated the code, it compiles and works with dmd (although segfaults in -release mode for some reason, probably a bug somewhere). But with ldc2: nbody.d(68): Error: undefined identifier __simd nbody.d(68): Error: undefined i

Re: N-body bench

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 16:43:35 UTC, bearophile wrote: Stanislav Blinov: Hmm.. How would one use core.simd with LDC2? It doesn't seem to define D_SIMD. Or should I go for builtins? I don't know if this is useful for you, but here I wrote a basic usage example of SIMD in ldc2 (seco

Re: Using std.algorithm how to uniq and sort a multidimensional array?

2014-01-29 Thread bearophile
Meta: auto tags = tags.flatMap!uniq.array ? That's another solution. In Phobos a flatMap can be useful (just as a zip overload that accepts a function to apply on the pairs, named zipWith in haskell: http://zvon.org/other/haskell/Outputprelude/zipWith_f.html ). Bye, bearophile

Re: N-body bench

2014-01-29 Thread bearophile
Stanislav Blinov: Hmm.. How would one use core.simd with LDC2? It doesn't seem to define D_SIMD. Or should I go for builtins? I don't know if this is useful for you, but here I wrote a basic usage example of SIMD in ldc2 (second D entry): http://rosettacode.org/wiki/Four_bits_adder#D Bye,

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote: Where argument has the same length? After function call, or inside function? I don't understand what my intention should be to push me to use fun3()? Gosh. To allow the function to modify the contents, but not the size of the array

Re: N-body bench

2014-01-29 Thread Stanislav Blinov
On Friday, 24 January 2014 at 15:56:26 UTC, bearophile wrote: If someone if willing to test LDC2 with a known benchmark, there's this one: http://benchmarksgame.alioth.debian.org/u32/performance.php?test=nbody A reformatted C++11 version good as start point for a D translation: http://codepa

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 16:01:08 UTC, Cooler wrote: Do you read my post? I am answering... why do I need fun3() if I already have fun1() and fun2(). fun3 guarantees that the argument has the same length for example.

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 15:38:34 UTC, Cooler wrote: It's not unpredictable, at least not more unpredictable then fun2. Should we dissallow this two? int[] a = [1,2,3,4]; b = a; b ~= [5, 6, 7, 8]; You don't understand me. You consider that I am author of the fun() and the caller sid

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 15:11:33 UTC, Cooler wrote: Yes, that is how slices work in D. The following article explains the "non-determinism" that you mention: http://dlang.org/d-array-article.html Ali Thank you for the article. Quotation from the article "It is a good idea to note i

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Sergei Nosov
On Wednesday, 29 January 2014 at 15:11:33 UTC, Cooler wrote: Yes, that is how slices work in D. The following article explains the "non-determinism" that you mention: http://dlang.org/d-array-article.html Ali Thank you for the article. Quotation from the article "It is a good idea to note i

Re: HTTPS, SSL, TLS client on D

2014-01-29 Thread Adam D. Ruppe
You can also use OpenSSL. I wrote a little wrapper class that extends std.socket.Socket for it: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/sslsocket.d If you download that file and compile it with your app: dmd yourfile.d sslsocket.d you s

Re: A possible enhancement related to is()

2014-01-29 Thread bearophile
Jakob Ovrum: We can already do this, but you have to omit the `Unused` alias (a semi-recent enhancement allows for that): --- import std.traits : Unqual; struct Tuple(Args...) {} enum isTuple(T) = is(Unqual!T : Tuple!Types, Types...); Thank you. Bye, bearophile

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Ali Çehreli
On 01/29/2014 02:55 AM, Cooler wrote: Consider 3 functions taking array as an argument: void fun1(in int[] x){...} void fun2(ref int[] x){...} void fun3(int[] x){...} auto a = new int[10]; fun1(a); // Guaranteed that "a" will not be changed fun2(a); // Guaranteed that we will see any chan

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Sergei Nosov
On Wednesday, 29 January 2014 at 13:15:30 UTC, Cooler wrote: On Wednesday, 29 January 2014 at 12:40:00 UTC, Tobias Pankrath wrote: On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote: Thank you for detailed explanation. But the question is - "Is that correct that language allows ambiguo

Re: toStringz in std.file

2014-01-29 Thread Ilya Yaroshenko
On Wednesday, 29 January 2014 at 08:29:42 UTC, Jakob Ovrum wrote: On Wednesday, 29 January 2014 at 08:27:14 UTC, Ilya Yaroshenko wrote: Hi! Why in std.file toStringz used without store a pointer in function body to prevent GC collection? https://github.com/D-Programming-Language/phobos/blob/ma

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread simendsjo
On Wednesday, 29 January 2014 at 13:15:30 UTC, Cooler wrote: On Wednesday, 29 January 2014 at 12:40:00 UTC, Tobias Pankrath wrote: On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote: Thank you for detailed explanation. But the question is - "Is that correct that language allows ambiguo

Re: Set global immutables from main/getopt?

2014-01-29 Thread anonymous
On Wednesday, 29 January 2014 at 10:15:03 UTC, Stanislav Blinov wrote: On Wednesday, 29 January 2014 at 00:28:29 UTC, Meta wrote: You can also use the Github Gist feature for displaying code, can't you? But you'd need a github account for that, won't you? :) no

Re: Sorting structs?

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 12:44:37 UTC, Tobias Pankrath wrote: On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov wrote: // Or avoid foreach altogether: studs.map!((ref const s) => writeln(s.name)); } Did you test this one? std.algorithm.map is lazy. Ah yes, sorry,

Re: Sorting structs?

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 11:24:54 UTC, Stanislav Blinov wrote: // Or avoid foreach altogether: studs.map!((ref const s) => writeln(s.name)); } Did you test this one? std.algorithm.map is lazy.

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote: Thank you for detailed explanation. But the question is - "Is that correct that language allows ambiguous behavior?" Where is it ambiguous?

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread simendsjo
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote: Thank you for detailed explanation. But the question is - "Is that correct that language allows ambiguous behavior?" Could you expand your example? fun(int[] a) {} is passing a by value, that is, the pointer and length is copied ove

Re: Array as an argument, ambiguous behaviour.

2014-01-29 Thread Tobias Pankrath
On Wednesday, 29 January 2014 at 10:55:57 UTC, Cooler wrote: Consider 3 functions taking array as an argument: void fun1(in int[] x){...} void fun2(ref int[] x){...} void fun3(int[] x){...} auto a = new int[10]; fun1(a); // Guaranteed that "a" will not be changed fun2(a); // Guaranteed th

Re: Sorting structs?

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 10:30:06 UTC, Boomerang wrote: I'll paste here with comments: import std.algorithm; import std.stdio; import std.array; void main() { struct Student { string name; float grade; } Student[] studs; writeln("Enter student data.

Re: Set global immutables from main/getopt?

2014-01-29 Thread Dicebot
One can always turn global into pointer to immutable - it will preserve most benefits but can be always replaced with differently initialized one.

Re: Sorting structs?

2014-01-29 Thread Boomerang
Also sorry for double posting but I'm confused how the sorting works when we only specify to be sorted by grade. I think in C++, disregarding other data members can lead to loss of data in things such as std::set.

Re: Sorting structs?

2014-01-29 Thread Boomerang
Thanks for the help so far. My current code is here: http://dpaste.dzfl.pl/b9acff399649 Are there problems with my code, or do you have suggestions to improve it?

Re: Sorting structs?

2014-01-29 Thread Stanislav Blinov
It's also worth noting that you can avoid passing structs into predicate function by value, and instead pass them by reference: sort!((ref const a, ref const b) => a.grade > b.grade)(students); This is useful for "heavy" structs to save on performance. E.g. in this case, Student.sizeof is 24 byt

Re: Set global immutables from main/getopt?

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 00:28:29 UTC, Meta wrote: You can also use the Github Gist feature for displaying code, can't you? But you'd need a github account for that, won't you? :)

Re: HTTPS, SSL, TLS client on D

2014-01-29 Thread Andrea Fontana
On Wednesday, 29 January 2014 at 09:07:18 UTC, Uranuz wrote: In this case I want client programme on D that will communicate with some server over secure HTTP. I want to be able to update DNS records via it's web API using web interface of my web application written on D. I could do it using some

Re: Sorting structs?

2014-01-29 Thread Stanislav Blinov
On Wednesday, 29 January 2014 at 09:33:50 UTC, Boomerang wrote: I would appreciate it if you explained your approach and gave source code illustrating it. Thanks! This can be solved without sorting in reverse or overloading anything in C++ (with a predicate version of sort() algorithm), and

Re: Sorting structs?

2014-01-29 Thread Benjamin Thaut
Am 29.01.2014 10:33, schrieb Boomerang: Hello everybody. I'm trying to learn D by solving simple exercises. The current exercise: read names and grades of students, then print the names of students in descending order of their grades. In C++, I would define a Student struct, overload the operat

Sorting structs?

2014-01-29 Thread Boomerang
Hello everybody. I'm trying to learn D by solving simple exercises. The current exercise: read names and grades of students, then print the names of students in descending order of their grades. In C++, I would define a Student struct, overload the operators: bool operator<(const Student&, const

Re: HTTPS, SSL, TLS client on D

2014-01-29 Thread Uranuz
In this case I want client programme on D that will communicate with some server over secure HTTP. I want to be able to update DNS records via it's web API using web interface of my web application written on D. I could do it using some cross-site request on JavaScript XmlHTTPRequest, but I want t

Re: HTTPS, SSL, TLS client on D

2014-01-29 Thread Andrea Fontana
On Wednesday, 29 January 2014 at 07:20:52 UTC, Uranuz wrote: I continue to practice with web applications on D and I have some questions about secure protocols of data transmissions. I don't have any experience with SSL/TLS so I need an advice how to get started. Is there any ready solution how

Re: A possible enhancement related to is()

2014-01-29 Thread Andrej Mitrovic
On 1/29/14, Jakob Ovrum wrote: > On a related note, I would like the body of a template to be able > to access aliases introduced in IsExpression's in the template's > constraints. Me too, but I can't remember if this was filed in bugzilla.

toStringz in std.file

2014-01-29 Thread Ilya Yaroshenko
Hi! Why in std.file toStringz used without store a pointer in function body to prevent GC collection? https://github.com/D-Programming-Language/phobos/blob/master/std/file.d Best Regards, Ilya

Re: toStringz in std.file

2014-01-29 Thread Jakob Ovrum
On Wednesday, 29 January 2014 at 08:27:14 UTC, Ilya Yaroshenko wrote: Hi! Why in std.file toStringz used without store a pointer in function body to prevent GC collection? https://github.com/D-Programming-Language/phobos/blob/master/std/file.d Best Regards, Ilya It is assumed that the pointe