Re: What is D's minimum requirements on Mac?

2015-06-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-06-11 13:34, Kagamin wrote: You can try to register as a developer: https://developer.apple.com/programs/ and get beta versions of OSX and install them on virtual box. Not sure how much it costs. OS X is free, you just need a Mac to download it :) -- /Jacob Carlborg

Re: Json

2015-06-11 Thread Cassio Butrico via Digitalmars-d-learn
On Friday, 12 June 2015 at 00:56:45 UTC, Ali Çehreli wrote: On 06/11/2015 04:58 PM, Cassio Butrico wrote: What does the .json file and how to use it? There is also the .json file that is produced by dmd's -X command line switch: dmd -X foo.d That outputs the members of the source code

Re: Json

2015-06-11 Thread Ali Çehreli via Digitalmars-d-learn
On 06/11/2015 04:58 PM, Cassio Butrico wrote: What does the .json file and how to use it? There is also the .json file that is produced by dmd's -X command line switch: dmd -X foo.d That outputs the members of the source code to foo.json in a way that may be useful for a tool. Ali

Re: Json

2015-06-11 Thread Dennis Ritchie via Digitalmars-d-learn
On Friday, 12 June 2015 at 00:35:35 UTC, Cassio Butrico wrote: Thank you for answering me so fast , where do I get the DUB for windows ? http://code.dlang.org/download

Re: Json

2015-06-11 Thread Cassio Butrico via Digitalmars-d-learn
Thank you for answering me so fast , where do I get the DUB for windows ?

Re: Json

2015-06-11 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 11 June 2015 at 23:58:33 UTC, Cassio Butrico wrote: What does the .json file and how to use it? In D a file with the extension *.json is used to describe packets that are included in your project, the dependency manager DUB. For example, you can install Eclipse with DDT and crea

Json

2015-06-11 Thread Cassio Butrico via Digitalmars-d-learn
What does the .json file and how to use it?

Re: Reading array of integers readln performance issues

2015-06-11 Thread anonymous via Digitalmars-d-learn
On Thursday, 11 June 2015 at 19:56:00 UTC, kerdemdemir wrote: Can I achieve something faster than code below? auto peopleMoney = stdin.readln().split().map!(a => to!int(a)).array(); if (peopleMoney.length == 20) writeln(":("); `std.array.split` is eager. It may be faster if you

Re: Reading array of integers readln performance issues

2015-06-11 Thread Dennis Ritchie via Digitalmars-d-learn
On Thursday, 11 June 2015 at 19:56:00 UTC, kerdemdemir wrote: Hi; To learn D better and challanging myself I am tring code computation's with D. There is a question which is about reading a line of integer which consist of 20 elements. My solution fails because "Time limit exceeded", I

Re: .sizeof dynamically allocated array

2015-06-11 Thread Meta via Digitalmars-d-learn
On Thursday, 11 June 2015 at 20:09:38 UTC, Adel Mamin wrote: import std.stdio; void main() { ubyte[] a1 = new ubyte[65]; ubyte[65] a2; writeln("a1.sizeof = ", a1.sizeof); // prints 16 writeln("a2.sizeof = ", a2.sizeof); // prints 65 } Why a1.sizeof is 16? ubyte[] is a slice,

Re: .sizeof dynamically allocated array

2015-06-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 11 June 2015 at 20:09:38 UTC, Adel Mamin wrote: Why a1.sizeof is 16? sizeof is tied to *type*, not a variable. (I kinda wish a1.sizeof was prohibited, forcing you to say typeof(a1).sizeof so it is clear but whatever). A dynamic array's size is the length variable plus the point

.sizeof dynamically allocated array

2015-06-11 Thread Adel Mamin via Digitalmars-d-learn
import std.stdio; void main() { ubyte[] a1 = new ubyte[65]; ubyte[65] a2; writeln("a1.sizeof = ", a1.sizeof); // prints 16 writeln("a2.sizeof = ", a2.sizeof); // prints 65 } Why a1.sizeof is 16?

Reading array of integers readln performance issues

2015-06-11 Thread kerdemdemir via Digitalmars-d-learn
Hi; To learn D better and challanging myself I am tring code computation's with D. There is a question which is about reading a line of integer which consist of 20 elements. My solution fails because "Time limit exceeded", I thought it is because of my algorithm first. I realize time l

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 19:23:49 UTC, Ali Çehreli wrote: On 06/11/2015 11:43 AM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 17:34:56 UTC, Steven Schveighoffer wrote: On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun

Re: Encapsulate return value in scoped

2015-06-11 Thread Ali Çehreli via Digitalmars-d-learn
On 06/11/2015 11:43 AM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 17:34:56 UTC, Steven Schveighoffer wrote: On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn wrote

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 17:34:56 UTC, Steven Schveighoffer wrote: On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn wrote: A x = scoped!A(10); use auto x = s

Re: Encapsulate return value in scoped

2015-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn wrote: A x = scoped!A(10); use auto x = scoped!A(10); Thanks! Curious question, why doesn't compiler reject thi

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn wrote: A x = scoped!A(10); use auto x = scoped!A(10); Thanks! Curious question, why doesn't compiler reject this code?

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/11/15 7:51 AM, Daniel Kozák via Digitalmars-d-learn wrote: On Thu, 11 Jun 2015 11:43:25 + via Digitalmars-d-learn wrote: On Thursday, 11 June 2015 at 08:33:46 UTC, Daniel Kozák wrote: On Wed, 10 Jun 2015 20:22:17 + Adel Mamin via Digitalmars-d-learn wrote: ubyte[5] a = 0xAA;

Re: Python's features, which requires D

2015-06-11 Thread Dennis Ritchie via Digitalmars-d-learn
On Saturday, 23 May 2015 at 10:58:33 UTC, Kagamin wrote: On Saturday, 23 May 2015 at 02:36:14 UTC, Dennis Ritchie wrote: For example, the code in Python looks quite natural: a = [[int(j) for j in input().split()] for i in range(n)] About D-code, I can not say: auto a = stdin .byLine

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread weaselcat via Digitalmars-d-learn
On Thursday, 11 June 2015 at 07:57:47 UTC, Per Nordlöw wrote: On Wednesday, 10 June 2015 at 22:03:52 UTC, Ali Çehreli wrote: Another option: void main() { auto a2 = new ubyte[5]; But this causes an extra zero-initialization of a2. just an fyi, gdc optimizes this away(looks like it overwr

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 11:43:25 + via Digitalmars-d-learn wrote: > On Thursday, 11 June 2015 at 08:33:46 UTC, Daniel Kozák wrote: > > On Wed, 10 Jun 2015 20:22:17 + > > Adel Mamin via Digitalmars-d-learn > > > > wrote: > > > >> ubyte[5] a = 0xAA; // Fine. Five 0xAA bytes. > >> auto a2 = n

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread via Digitalmars-d-learn
On Thursday, 11 June 2015 at 08:33:46 UTC, Daniel Kozák wrote: On Wed, 10 Jun 2015 20:22:17 + Adel Mamin via Digitalmars-d-learn wrote: ubyte[5] a = 0xAA; // Fine. Five 0xAA bytes. auto a2 = new ubyte[5]; // Fine. Five 0 bytes. Now, let's say, I want to allocate an array of a size, deriv

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread via Digitalmars-d-learn
On Thursday, 11 June 2015 at 07:57:47 UTC, Per Nordlöw wrote: On Wednesday, 10 June 2015 at 22:03:52 UTC, Ali Çehreli wrote: Another option: void main() { auto a2 = new ubyte[5]; But this causes an extra zero-initialization of a2. a2[] = 0xAA;// <-- Assign to "all elements" Is

Re: What is D's minimum requirements on Mac?

2015-06-11 Thread Kagamin via Digitalmars-d-learn
Whee, $99/year.

Re: What is D's minimum requirements on Mac?

2015-06-11 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 10 June 2015 at 18:55:27 UTC, Adam D. Ruppe wrote: I'm still tempted to grab a used Mac so I can port my display stuff to Cocoa and test it, but Macs are outrageously expensive and I hate them, so want to spend as little as possible. What does dmd minimally require on a mac? If I

Re: Encapsulate return value in scoped

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn wrote: > A x = scoped!A(10); use auto x = scoped!A(10);

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 08:48:22 UTC, Yuxuan Shui wrote: Is there a way to encapsulate return value into scoped? Say I have a function that returns a new object: X new_x(T t...) { //Super complex input processing return new X(something); } And I want to encapsulate the result usin

Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
Is there a way to encapsulate return value into scoped? Say I have a function that returns a new object: X new_x(T t...) { //Super complex input processing return new X(something); } And I want to encapsulate the result using scoped, is that possible? Can I just do: return scoped!

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 10 Jun 2015 20:22:17 + Adel Mamin via Digitalmars-d-learn wrote: > ubyte[5] a = 0xAA; // Fine. Five 0xAA bytes. > auto a2 = new ubyte[5]; // Fine. Five 0 bytes. > Now, let's say, I want to allocate an array of a size, derived at > run time, and initialize it to some non-zero value at

Re: Shortest way to allocate an array and initialize it with a specific value.

2015-06-11 Thread via Digitalmars-d-learn
On Wednesday, 10 June 2015 at 22:03:52 UTC, Ali Çehreli wrote: Another option: void main() { auto a2 = new ubyte[5]; But this causes an extra zero-initialization of a2. a2[] = 0xAA;// <-- Assign to "all elements" Is auto a2 = value.repeat(size).array; better in this regar