Re: Deploying Vibe.d applications to OpenShift

2014-07-24 Thread Nikolay via Digitalmars-d-learn
Please let me know how you did it, because I know it's possible with the DIY-cartridge they provide you(atleast it should be). I tried it some time ago. It is possible but: - vibe.d requires a lot of memory for project compilation - it is hard to install additional libraries (it is not usual

Re: Grabing C(++) stdout

2014-07-24 Thread Chris via Digitalmars-d-learn
On Wednesday, 23 July 2014 at 16:46:04 UTC, FreeSlave wrote: On Wednesday, 23 July 2014 at 15:35:59 UTC, Chris wrote: The C++ code does this: size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream ); // stream is stdout and text appears in the console (a string). I don't

Type deduction on templated constructor.

2014-07-24 Thread francesco cattoglio via Digitalmars-d-learn
So, I have this code (also on http://dpaste.dzfl.pl/3f767b17e83c) This Vector(T) struct is taken from gfm.math.vector. struct Vector(T) { T x, y, z; this(X : T, Y : T, Z : T)(X x_, Y y_, Z z_) { x = x_; y = y_; z = z_; } } void main() { Ve

Re: Type deduction on templated constructor.

2014-07-24 Thread bearophile via Digitalmars-d-learn
francesco cattoglio: should this code compile? I understand that the literal "1" is "int" therefore it can screw type deduction, but I wonder if the compiler should be smart enough to deduce it correctly. To keep both the compiler and programmers sane, D templates don't perform implicit type

Re: Type deduction on templated constructor.

2014-07-24 Thread francesco cattoglio via Digitalmars-d-learn
On Thursday, 24 July 2014 at 09:38:14 UTC, bearophile wrote: francesco cattoglio: should this code compile? I understand that the literal "1" is "int" therefore it can screw type deduction, but I wonder if the compiler should be smart enough to deduce it correctly. To keep both the compiler

Re: How to know whether a file's encoding is ansi or utf8?

2014-07-24 Thread Kagamin via Digitalmars-d-learn
I first try to load the file as utf8 (or some 8kb at the start of it) with encoding exceptions turned on, if I catch an exception, I reload it as ansi, otherwise I assume it's valid utf8.

Re: Deploying Vibe.d applications to OpenShift

2014-07-24 Thread Etienne via Digitalmars-d-learn
On 2014-07-24 3:45 AM, Nikolay wrote: Please let me know how you did it, because I know it's possible with the DIY-cartridge they provide you(atleast it should be). I tried it some time ago. It is possible but: - vibe.d requires a lot of memory for project compilation - it is hard to inst

Re: Deploying Vibe.d applications to OpenShift

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 02:48:45 UTC, Rutger wrote: On Thursday, 24 July 2014 at 01:47:43 UTC, Rikki Cattermole wrote: On 24/07/2014 1:28 p.m., Rutger wrote: Hello! Really enjoying D so far and have started to toy around with Vibe.d. I was just wondering if someone here has had any experie

zlibs gzip dosent work with http

2014-07-24 Thread Sean Campbell via Digitalmars-d-learn
I'm trying to add gzip compression to a HTTP server i wrote in D. here is the code that dose the gzip encoding. if ((Info.modGzip) & (indexOf(client.getRequestHeaderFieldValue("Accept-Encoding"),"gzip") != -1)){ writeln("gzip"); auto gzip = new Compress(HeaderFormat.gzip);

Segfault games with factorials

2014-07-24 Thread Darren via Digitalmars-d-learn
I have the following code in fac.d (modified from the factorial examples on RosettaCode): #!/usr/bin/rdmd import std.bigint; pure BigInt factorial(BigInt n) { static pure BigInt inner(BigInt n, BigInt acc) { return n == 0 ? acc : inner(n - 1, acc * n); } return inner(n, BigI

Re: zlibs gzip dosent work with http

2014-07-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 July 2014 at 13:09:53 UTC, Sean Campbell wrote: I'm trying to add gzip compression to a HTTP server i wrote in D. here is the code that dose the gzip encoding. I know zlib gzip works for http, I used it in my cgi.d if(gzipResponse && acceptsGzip && isAll) {

Re: Segfault games with factorials

2014-07-24 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: > I have the following code in fac.d (modified from the factorial > examples on RosettaCode): > > #!/usr/bin/rdmd > import std.bigint; > > pure BigInt factorial(BigInt n) { > static pure BigInt inner(BigInt n, Big

Re: Segfault games with factorials

2014-07-24 Thread Darren via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: I have the following code in fac.d (modified from the factorial examples on RosettaCode): #!/usr/bin/rdmd import std.bigint; pure

Re: Segfault games with factorials

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote: On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: I have the following code in fac.d (modified from the factorial examples

Re: D JSON (WAT?!)

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 15:15:36 +, Pavel wrote: > Ok, let me start with the sample code: > > import std.stdio; > import std.json; > > void main() { >scope(failure) writeln("FaILED!!"); >string jsonStr = `{ "name": "1", "type": "r" }`; >auto parsed = parseJSON(jsonStr); >string s

Re: D JSON (WAT?!)

2014-07-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: string s = parsed["fail"].str; Since there is no entry "fail" in the object, it returns a null JSON_VALUE pointer. Trying to get the string out of it is then seen as a null pointer access and kills the program. Check for null on a ke

D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`; auto parsed = parseJSON(jsonStr); string s = parsed["fail"].str; writeln(s == ""); writeln(s is null); writel

Re: D JSON (WAT?!)

2014-07-24 Thread bearophile via Digitalmars-d-learn
Adam D. Ruppe: Check for null on a key before trying to get a value out. Is something like the get() function usable here? Bye, bearophile

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: string s = parsed["fail"].str; Since there is no entry "fail" in the object, it returns a null JSON_VALUE pointer. Trying to get the string out of it is then seen as a nul

Re: D JSON (WAT?!)

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn
Am 24.07.2014 17:29, schrieb Pavel: On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: string s = parsed["fail"].str; Since there is no entry "fail" in the object, it returns a null JSON_VALUE pointer. Trying to get the str

Re: D JSON (WAT?!)

2014-07-24 Thread Ali Çehreli via Digitalmars-d-learn
On 07/24/2014 08:29 AM, Pavel wrote: writeln(parsed["fail"] == null); Now compiler complains: Error: incompatible types for ((parsed.opIndex("fail")) == (null)): 'JSONValue' and 'typeof(null)' WAT?! Comparing against null should be done with the 'is' operator, not the == operator: i

Re: D JSON (WAT?!)

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`; auto parsed = parseJSON(jsonStr); string s = parsed["fail"

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:31:30 UTC, Daniel Gibson wrote: Am 24.07.2014 17:29, schrieb Pavel: On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: string s = parsed["fail"].str; Since there is no entry "fail" in the obj

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:20:58 UTC, Justin Whear wrote: On Thu, 24 Jul 2014 15:15:36 +, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`;

Re: Segfault games with factorials

2014-07-24 Thread safety0ff via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote: It does seem that's the case. Which is odd, as I thought that DMD and LDC did TCO. Not in this case obviously. DMD doesn't do it with the :? operator: https://issues.dlang.org/show_bug.cgi?id=3713

Re: D JSON (WAT?!)

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`;

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:34:22 UTC, Ali Çehreli wrote: On 07/24/2014 08:29 AM, Pavel wrote: writeln(parsed["fail"] == null); Now compiler complains: Error: incompatible types for ((parsed.opIndex("fail")) == (null)): 'JSONValue' and 'typeof(null)' WAT?! Comparing against null sho

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`;

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio;

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln("F

Re: D JSON (WAT?!)

2014-07-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio;

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen wrote: On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pav

Re: D JSON (WAT?!)

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn
Am 24.07.2014 17:54, schrieb Pavel: Guess what, here's a new snippet: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`; auto parsed = parseJSON(jsonStr).object; writeln("fail" in parsed); } Output

Re: D JSON (WAT?!)

2014-07-24 Thread bearophile via Digitalmars-d-learn
Pavel: writeln(cast(bool)("fail" in parsed)); Produces "false"... but why on earth boolean expression would output null? In D if you perform an associative array "in", the return isn't a boolean but a pointer. It's zero if the item is not present. And it's a valid pointer to the value if t

Re: D JSON (WAT?!)

2014-07-24 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 24, 2014 at 03:54:20PM +, Pavel via Digitalmars-d-learn wrote: [...] > Guess what, here's a new snippet: > > import std.stdio; > import std.json; > > void main() { > scope(failure) writeln("FaILED!!"); > string jsonStr = `{ "name": "1", "type": "r" }`; > auto parsed = parseJ

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:59:52 UTC, Daniel Gibson wrote: Am 24.07.2014 17:54, schrieb Pavel: Guess what, here's a new snippet: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!"); string jsonStr = `{ "name": "1", "type": "r" }`; auto parsed = parse

Re: D JSON (WAT?!)

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 15:54:20 +, Pavel wrote: > On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen wrote: >> On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: >>> On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John C

Re: D JSON (WAT?!)

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:54:21 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen wrote: On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John Colv

Re: D JSON (WAT?!)

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: > > Thanks to all you folks who explained "in" operator for me. My bad. > Let's focus on the real problem, which is JSON wrapper class. Is it > needed? Wouldn't it be better to get AA from parseJSON? The following are valid JSON: auto json1 = pars

Passing an array by reference?

2014-07-24 Thread Rishub Nagpal via Digitalmars-d-learn
1 class Test 2 { 3 int[][] array; 4 this(ref int[][] d) 5 { 6 array = d; 7 } 8 9 } 10 11 void main() 12 { 13 Test t = new Test([[1,1],[1,1]]); //does not compile 14 } 15 what is the best way to pass a literal ([[1,2],[3,4]]) by reference? Is

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:02:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 03:54:20PM +, Pavel via Digitalmars-d-learn wrote: [...] Guess what, here's a new snippet: import std.stdio; import std.json; void main() { scope(failure) writeln("FaILED!!");

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:09:25 UTC, Justin Whear wrote: On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: Thanks to all you folks who explained "in" operator for me. My bad. Let's focus on the real problem, which is JSON wrapper class. Is it needed? Wouldn't it be better to get AA from

Re: Passing an array by reference?

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:06:00 UTC, Rishub Nagpal wrote: 1 class Test 2 { 3 int[][] array; 4 this(ref int[][] d) 5 { 6 array = d; 7 } 8 9 } 10 11 void main() 12 { 13 Test t = new Test([[1,1],[1,1]]); //does not compile 14 } 15 what is

Re: Passing an array by reference?

2014-07-24 Thread Rishub Nagpal via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:15:44 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 16:06:00 UTC, Rishub Nagpal wrote: 1 class Test 2 { 3 int[][] array; 4 this(ref int[][] d) 5 { 6 array = d; 7 } 8 9 } 10 11 void main() 12 { 13 Test t = new Test([[1,1]

Re: D JSON (WAT?!)

2014-07-24 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/24/14, 1:09 PM, Justin Whear wrote: On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: Thanks to all you folks who explained "in" operator for me. My bad. Let's focus on the real problem, which is JSON wrapper class. Is it needed? Wouldn't it be better to get AA from parseJSON? The followi

Re: D JSON (WAT?!)

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 13:49:27 -0300, Ary Borenszweig wrote: > Nope, a JSON can only be an array or an object (hash). Ary, can you point out the place in the spec where this is specified? Not to be pedantic, but the spec only seems to define a "JSON value", not a "JSON document".

Re: D JSON (WAT?!)

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 16:14:15 +, Pavel wrote: > On Thursday, 24 July 2014 at 16:09:25 UTC, Justin Whear wrote: >> On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: >>> >>> Thanks to all you folks who explained "in" operator for me. My bad. >>> Let's focus on the real problem, which is JSON wrap

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote: > I was reading Ali's book (http://ddili.org/ders/d.en/index.html) > and saw this piece of code on how to get the true size of an object: > > MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize, > MyClass) * 10); > > Tha

How to copy an object to separate allocated memory?

2014-07-24 Thread Gary Willoughby via Digitalmars-d-learn
I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw this piece of code on how to get the true size of an object: MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 10); That got me thinking, how would i actually 'fill' this memory with ins

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn
Am 24.07.2014 19:05, schrieb Gary Willoughby: I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw this piece of code on how to get the true size of an object: MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 10); That got me thinking, how wou

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 17:05:18 UTC, Gary Willoughby wrote: I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw this piece of code on how to get the true size of an object: MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 10); That

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 17:07:29 +, Justin Whear wrote: > On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote: > >> I was reading Ali's book (http://ddili.org/ders/d.en/index.html) >> and saw this piece of code on how to get the true size of an object: >> >> MyClass* buffer = cast(MyClass*

Mocking serial device

2014-07-24 Thread Alfredo Palhares via Digitalmars-d-learn
Hello, I am writing an application that connects to a serial device in /dev/ttyUSB0 and trows some binary data back and forth. How can i mock and run some unit testing without having to connect to the device every time? -- Regards, Alfredo Palhares

dual with statement

2014-07-24 Thread Jay Norwood via Digitalmars-d-learn
I was playing around with use of the dual WITH statement. I like the idea, since it makes the code within the with cleaner. Also, I got the impression from one of the conference presentations ... maybe the one on the ARM debug ... that there are some additional optimizations available that

Re: Mocking serial device

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 17:15:02 +, Alfredo Palhares wrote: > Hello, > > I am writing an application that connects to a serial device in > /dev/ttyUSB0 and trows some binary data back and forth. > > > How can i mock and run some unit testing without having to connect to > the device every time?

Re: Mocking serial device

2014-07-24 Thread Alfredo Palhares via Digitalmars-d-learn
Hello, How about capturing some data from the device and writing it to a file? When you want to test, open the test data file instead of the device file. That would not work since the data is two way, for the device to even trow data at me I need to send some values to it. -- Regards, Alf

Appender.put return value

2014-07-24 Thread JR via Digitalmars-d-learn
Is there a big reason why Appender.put doesn't return &this? http://dpaste.dzfl.pl/bb840e3e349e It would allow for convenient chaining. :<

Re: Appender.put return value

2014-07-24 Thread Temtaime via Digitalmars-d-learn
Offtop It's better to return "this" and have return type "ref auto" i think.

Re: D JSON (WAT?!)

2014-07-24 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/24/14, 1:58 PM, Justin Whear wrote: On Thu, 24 Jul 2014 13:49:27 -0300, Ary Borenszweig wrote: Nope, a JSON can only be an array or an object (hash). Ary, can you point out the place in the spec where this is specified? Not to be pedantic, but the spec only seems to define a "JSON value"

Create a general array

2014-07-24 Thread Robert Rimoczi via Digitalmars-d-learn
Hi! Can I somehow make a general array where I can store everykind of object? doubles, ints, float, class objects? Or is there any method for it?

Re: Create a general array

2014-07-24 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 24 July 2014 at 19:43:23 UTC, Robert Rimoczi wrote: Hi! Can I somehow make a general array where I can store everykind of object? doubles, ints, float, class objects? Or is there any method for it? void main() { import std.variant, std.stdio; class Four { overrid

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 24 July 2014 at 17:07:47 UTC, Justin Whear wrote: On Thu, 24 Jul 2014 17:07:29 +, Justin Whear wrote: On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote: I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw this piece of code on how to get the true

Re: dual with statement

2014-07-24 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 24 July 2014 at 17:19:36 UTC, Jay Norwood wrote: I was playing around with use of the dual WITH statement. I like the idea, since it makes the code within the with cleaner. Also, I got the impression from one of the conference presentations ... maybe the one on the ARM debug ...

Re: dual with statement

2014-07-24 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 24 July 2014 at 17:19:36 UTC, Jay Norwood wrote: Anyway, a problem I ran into was if two structures had the same member names, for example struct ar.r and ar.psm in this case below. In this case, there was no way for the compiler to determine from which structure to get the membe

Re: dual with statement

2014-07-24 Thread bearophile via Digitalmars-d-learn
monarch_dodra: From what I can observe, the compiler resolves the ambiguity by chosing the first match in terms of scope. Eg, there's shadowing. From my previous code: with (t) { writeln(k); //prints t.k with(s) { writeln(k); //prints s.k: it is now shadowing t.k A re

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 18:49:27 UTC, Ary Borenszweig wrote: On 7/24/14, 1:58 PM, Justin Whear wrote: On Thu, 24 Jul 2014 13:49:27 -0300, Ary Borenszweig wrote: Nope, a JSON can only be an array or an object (hash). Ary, can you point out the place in the spec where this is specified?

Re: Appender.put return value

2014-07-24 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 24 July 2014 at 17:43:36 UTC, JR wrote: Is there a big reason why Appender.put doesn't return &this? http://dpaste.dzfl.pl/bb840e3e349e It would allow for convenient chaining. :< AFAIK, no reason no. That said, it wouldn't be useable in generic code.

Re: D JSON (WAT?!)

2014-07-24 Thread Pavel via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:09:25 UTC, Justin Whear wrote: On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: Thanks to all you folks who explained "in" operator for me. My bad. Let's focus on the real problem, which is JSON wrapper class. Is it needed? Wouldn't it be better to get AA from

Re: dual with statement

2014-07-24 Thread Jay Norwood via Digitalmars-d-learn
On Thursday, 24 July 2014 at 20:16:53 UTC, monarch_dodra wrote: Or did I miss something? Yes, sorry, I should have pasted a full example previously. The code at the end is with the Raw_met members renamed (they were originally a and b but clashed). So, if Raw_met members were still a and b

Re: Deploying Vibe.d applications to OpenShift

2014-07-24 Thread Nikolay via Digitalmars-d-learn
You should compile and test on a CentOS 6.3 machine first and then write the cartridge using the wget command to move the same libevent package and the compiled vibe.d binary. You won't be able to compile on a cartridge. Yes but what if I use some additional libriaries? Every new librar