Re: C++ interface problem

2015-04-30 Thread Benjamin Thaut via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 19:04:11 UTC, extrawurst wrote: On Wednesday, 29 April 2015 at 13:55:46 UTC, Benjamin Thaut wrote: On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote: here is the shortened version of the returned class CSteamID:

Re: [dvm] Can't install compilers on Mac

2015-04-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-04-29 23:24, Chris wrote: Yes. Doesn't work. What happens when you run ./dvm install dvm? What is the output? If the installation of DVM itself fails you will not be able to install compilers. You can verify the installation of DVM by opening a new shell session (a new tab or

Re: getopt helpWanted

2015-04-30 Thread wobbles via Digitalmars-d-learn
On Wednesday, 29 April 2015 at 22:02:29 UTC, novice2 wrote: Hello. Help me please to understand, how to show usage help to user, who enter wrong options? For example, user not provided required filename. I want to show error message, and program usage help text. But likely getopt don't

Re: getopt helpWanted

2015-04-30 Thread novice2 via Digitalmars-d-learn
Thank you, Brian!

Re: shouldn't this code at least trigger a warning?

2015-04-30 Thread ketmar via Digitalmars-d-learn
On Wed, 29 Apr 2015 10:48:36 +, Gary Willoughby wrote: Please raise an issue in bugzilla. This is obviously an error. done: https://issues.dlang.org/show_bug.cgi?id=14532 signature.asc Description: PGP signature

Re: shouldn't this code at least trigger a warning?

2015-04-30 Thread ketmar via Digitalmars-d-learn
On Wed, 29 Apr 2015 07:57:07 -0700, H. S. Teoh via Digitalmars-d-learn wrote: Switch statements in D allow all sorts of abominations, if only you would try it. I think it was originally designed to support a particular loop idiom (sorry I forgot what it was called, and don't have time to look

Ada to D - an array for storing values of each of the six bits which are sufficient

2015-04-30 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, There is an array of values to store each of which sufficiently 6 bits. As it is written down on the D? - With Ada.Text_IO; Use Ada.Text_IO; With Ada.Integer_Text_IO; Use Ada.Integer_Text_IO; procedure Program is type T_Type is range -10 .. 27; for T_Type'Size use 6; type

Re: Ada to D - an array for storing values of each of the six bits which are sufficient

2015-04-30 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: There is an array of values to store each of which sufficiently 6 bits. As it is written down on the D? You can't do it directly in D. Someone has to write a packed array data structure to do it. Bye, bearophile

Re: C++ interface problem

2015-04-30 Thread extrawurst via Digitalmars-d-learn
On Thursday, 30 April 2015 at 08:18:16 UTC, Benjamin Thaut wrote: On Wednesday, 29 April 2015 at 19:04:11 UTC, extrawurst wrote: On Wednesday, 29 April 2015 at 13:55:46 UTC, Benjamin Thaut wrote: On Monday, 27 April 2015 at 21:19:02 UTC, extrawurst wrote: here is the shortened version of the

dub -vgc

2015-04-30 Thread Robert M. Münch via Digitalmars-d-learn
How can I make use of the -vgc compiler switch in my DUB project? -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: dub building is extremely slow

2015-04-30 Thread wobbles via Digitalmars-d-learn
On Thursday, 30 April 2015 at 03:00:36 UTC, zhmt wrote: On Thursday, 30 April 2015 at 02:02:50 UTC, zhmt wrote: dub build is running on centos7. It works well until today, It becomes very slow suddenly. It will take minuties per compilation, there is 10 files in project. Has anyone

Re: Create custom data types

2015-04-30 Thread via Digitalmars-d-learn
Another possible way is to check the bounds at compile time. The different operators need to be overloaded for that. For example, if you have to types Int!(0, 100) and Int!(20, 30), the result type of an addition needs to be Int!(20, 130). Then, there can be an overloaded opCast() to bool for

Re: Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-30 Thread safety0ff via Digitalmars-d-learn
Just for fun: // map, join, text, iota, writeln, tuple import std.algorithm, std.array, std.conv, std.range, std.stdio, std.typecons; void main() { iota(1,100) .map!(a = tuple(a, a % 3 == 0 ? 0 : 4, a % 5 == 0 ? 8 : 4)) .map!(a = a[1] == a[2] ? a[0].text :

Implicit conversion error

2015-04-30 Thread Paul via Digitalmars-d-learn
When compiled on a 64 bit machine, this line int r = uniform(0, mobs.length); gives me an error: Error: cannot implicitly convert expression (uniform(0, mobs.length)) of type ulong to int but it compiles ok on a 32 bit machine. I thought it was the expression on the righthand side returning

Destruction in D

2015-04-30 Thread bitwise via Digitalmars-d-learn
After reading GC page in the reference, it seems that class destructors are called on a separate thread, in parallel to the main thread. Is this correct? What about structs? Are the destructors called when they go out of scope in a C++ RAII fashion, or do they happen on a separate thread

Capacity is first-come first served for multiple slices to all elements

2015-04-30 Thread Ali Çehreli via Digitalmars-d-learn
(Thanks to Luís Marques for waking me up.) Although it makes sense now, somehow some parts of this story is news to me after all these years. :-/ When there are multiple slices to all elements of an array, they all start with same capacity until an element is added to one of them. After

Re: Destruction in D

2015-04-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: destructors are called on a separate thread, in parallel to the main thread. Is this correct? Not necessarily. the way the GC works in D today is whenever any thread allocates, it runs the GC functions which might do a collection.

anonymous template predicates

2015-04-30 Thread Vlad Levenfeld via Digitalmars-d-learn
I was wondering if there's a mechanism to make anonymous templates, e.g. given: enum Policy {A, B} alias List = TypeTuple!(...); instead of this: enum has_policy_A (T) = T.policy == Policy.A; alias Result = Filter!(has_policy_A, List); use something like this: Filter!(T = T.policy

Re: Destruction in D

2015-04-30 Thread weaselcat via Digitalmars-d-learn
On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: After reading GC page in the reference, it seems that class destructors are called on a separate thread, in parallel to the main thread. Is this correct? There's no guarantee what thread will be used in the standard GC implementation

Re: Destruction in D

2015-04-30 Thread bitwise via Digitalmars-d-learn
On Thu, 30 Apr 2015 16:17:10 -0400, Adam D. Ruppe destructiona...@gmail.com wrote: On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote: destructors are called on a separate thread, in parallel to the main thread. Is this correct? Not necessarily. the way the GC works in D today is

Re: Destruction in D

2015-04-30 Thread Idan Arye via Digitalmars-d-learn
On Thursday, 30 April 2015 at 23:27:49 UTC, bitwise wrote: Well, the third thing was just my reasoning for asking in the first place. I need to be able to acquire/release shared resources reliably, like an OpenGL texture, for example. If you want to release resources, you are going to have to

Re: Capacity is first-come first served for multiple slices to all elements

2015-04-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 30, 2015 11:59:00 Ali Çehreli via Digitalmars-d-learn wrote: (Thanks to Luís Marques for waking me up.) Although it makes sense now, somehow some parts of this story is news to me after all these years. :-/ When there are multiple slices to all elements of an array, they

Re: dub -vgc

2015-04-30 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 30 April 2015 at 12:14:39 UTC, Robert M. Münch wrote: How can I make use of the -vgc compiler switch in my DUB project? Does dflags work ? http://code.dlang.org/package-format

How to reuse functions

2015-04-30 Thread Luigi via Digitalmars-d-learn
Hi everybody. I am tring to use a function where its parameter is another function, and at the same time are both already made - they cannot be modified - and the second one has to be conditioned before to be passed as argument. Let's say I have these function and I cannot modify: -jac(+d)

Re: Example from d-idioms is incorrect

2015-04-30 Thread Namespace via Digitalmars-d-learn
On Thursday, 30 April 2015 at 21:30:36 UTC, TheGag96 wrote: I was looking at the d-idioms website today and saw this code example: http://p0nce.github.io/d-idioms/#Adding-or-removing-an-element-from-arrays And I was kind of irked. I just recently working with removing an element from an

Re: Example from d-idioms is incorrect

2015-04-30 Thread TheGag96 via Digitalmars-d-learn
On Thursday, 30 April 2015 at 22:01:43 UTC, Justin Whear wrote: On Thu, 30 Apr 2015 21:30:34 +, TheGag96 wrote: Was the behavior of the remove() function changed recently? Thanks guys. I believe remove has always worked this way. What you're seeing is explained by this note in the

Example from d-idioms is incorrect

2015-04-30 Thread TheGag96 via Digitalmars-d-learn
I was looking at the d-idioms website today and saw this code example: http://p0nce.github.io/d-idioms/#Adding-or-removing-an-element-from-arrays And I was kind of irked. I just recently working with removing an element from an array in a small project I worked on two weeks ago, and I had to

Re: Example from d-idioms is incorrect

2015-04-30 Thread Justin Whear via Digitalmars-d-learn
On Thu, 30 Apr 2015 21:30:34 +, TheGag96 wrote: Was the behavior of the remove() function changed recently? Thanks guys. I believe remove has always worked this way. What you're seeing is explained by this note in the documentation for remove: The original array has remained of the same

Re: anonymous template predicates

2015-04-30 Thread Idan Arye via Digitalmars-d-learn
On Thursday, 30 April 2015 at 21:01:36 UTC, Vlad Levenfeld wrote: I was wondering if there's a mechanism to make anonymous templates, e.g. given: enum Policy {A, B} alias List = TypeTuple!(...); instead of this: enum has_policy_A (T) = T.policy == Policy.A; alias Result =

Re: Example from d-idioms is incorrect

2015-04-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 April 2015 at 21:30:36 UTC, TheGag96 wrote: arr.remove(1); You didn't assign the result here... the site says arr = arr.remove(index); Notice too that the docs do NOT take the array by reference; they don't necessarily modify it in-place.

Re: Example from d-idioms is incorrect

2015-04-30 Thread Namespace via Digitalmars-d-learn
Same output: [1, 10] true [1] false with dmd 2.067.1

Re: Implicit conversion error

2015-04-30 Thread bearophile via Digitalmars-d-learn
Paul: When compiled on a 64 bit machine, this line int r = uniform(0, mobs.length); .length returns a size_t, and 0 is an int. uniform() probably decides to unify those types to a size_t. A size_t is 32 bit on 32 bit machines and 64 bits on 64 bit machines. But D int is always a 32 bit

Re: Create a case-insensitive startsWith

2015-04-30 Thread Justin Whear via Digitalmars-d-learn
Note that my solution relies on the pre-release version of std.uni, those lazy functions aren't in the latest release.