Re: A slice can lose capacity simply by calling a function

2015-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 05/03/2015 06:06 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, May 03, 2015 15:21:15 Andrew Godfrey via Digitalmars-d-learn wrote: I really don't think that it's an issue in general, but if you do want to guarantee that nothing affects the capacity of your array, then

Re: dub building is extremely slow

2015-05-04 Thread zhmt via Digitalmars-d-learn
On Thursday, 30 April 2015 at 12:31:54 UTC, wobbles wrote: 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

Error: conflicting Ddoc and obj generation options

2015-05-04 Thread zhmt via Digitalmars-d-learn
mono-d is running on centos7 with options below: first: { name: ezsock, targetType: executable, description: A minimal D application., copyright: Copyright © 2015, zhmt, authors: [zhmt], mainSourceFile: source/app.d, dependencies: {

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 03:52:21 +, Rikki Cattermole said: Have you looked at my book? https://leanpub.com/ctfe No, thanks for the hint. You will have one more reader ;-) -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-03 23:28:00 +, anonymous said: Here T would have to be a type. But you want to accept a string. So: template startsNotWith(string s,char c){ enum startsNotWith = s.length == 0 || s[0] != c; } Hi, ok, just to better understand this (I have a C++ background (even

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-03 23:28:00 +, anonymous said: You need to turn T into a parameter, so that StaticFilter can set it. (And it's really a string again, so I'm renaming to s.) template startsNotWithp(string s) { enum startsNotWithp = startsNotWith!(s, 'p'); } /* Shorthand syntax: enum

Re: CTFE template predicates

2015-05-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 May 2015 at 11:22:16 UTC, Robert M. Münch wrote: Hi, ok, just to better understand this (I have a C++ background (even quite old)): When I want to use some functions I need to specify the type? It's not possible to use T.length() which would compile if T is a string? I thought

Re: CTFE template predicates

2015-05-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 4/05/2015 11:15 p.m., Robert M. Münch wrote: On 2015-05-04 03:52:21 +, Rikki Cattermole said: Have you looked at my book? https://leanpub.com/ctfe No, thanks for the hint. You will have one more reader ;-) I'm currently live streaming, feel free to jump on and ask any questions!

Re: CTFE template predicates

2015-05-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 May 2015 at 11:41:23 UTC, Robert M. Münch wrote: Hi, I have one more questions: Is it possible to write something like this? alias rules = StaticFilter!(startsNotWith(?, 'p'), org_rules); The ? should be used for every memember of org_rules. No, we don't have template literals.

Re: Is this expected? default to public members in private class

2015-05-04 Thread Dan Olson via Digitalmars-d-learn
ketmar ket...@ketmar.no-ip.org writes: On Sun, 03 May 2015 18:07:20 -0700, Dan Olson wrote: It seems a private class or struct defaults to public members. Just curious if this is intended. I would have expected private all the way down unless overriden. i bet it is intended. protection

Re: Converting (casting?) a dynamic array to a fixed array?

2015-05-04 Thread WhatMeWorry via Digitalmars-d-learn
Many thanks. Just to recap, I got the code working with: glBufferData(GL_ARRAY_BUFFER, (verts.sizeof * verts.length), verts.ptr, GL_STATIC_DRAW); sizeof on a slice doesn't do what you think it does, it returns the size of the actual slice object I believe. I have to admit that I didn't

CTFE enums static assert

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
I find this a bit strange: // get all rules that start with p... enum BolRules = StaticFilter!(beginsWithP, __traits(allMembers,BolSource)); static assert(is(BolRules == enum)); Compiling using dmd... source/app.d(114): Error: static assert (is(BolRules == enum)) is false I'm trying to

Re: CTFE enums static assert

2015-05-04 Thread ketmar via Digitalmars-d-learn
On Mon, 04 May 2015 18:21:59 +0200, Robert M. Münch wrote: I find this a bit strange: // get all rules that start with p... enum BolRules = StaticFilter!(beginsWithP, __traits(allMembers,BolSource)); static assert(is(BolRules == enum)); Compiling using dmd... source/app.d(114): Error:

Re: A slice can lose capacity simply by calling a function

2015-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 4 May 2015 at 06:23:42 UTC, Ali Çehreli wrote: On 05/03/2015 06:06 PM, Jonathan M Davis via Digitalmars-d-learn wrote: (I am eagerly waiting for your DConf talk to see how you make sense of it all.) Well, we'll see how much I'm able to cover about arrays. The focus of the talk

Re: CTFE enums static assert

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 17:21:34 +, ketmar said: that's due to `enum` keyword abusing. enum type is something like this: enum MyEnum { A, B } and enum val = false; is a compile-time boolean constant, which will be inlined on using. i.e. compiler will inline such enum constants, and that

Re: Converting (casting?) a dynamic array to a fixed array?

2015-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 05/04/2015 08:36 AM, WhatMeWorry wrote: But just for arguments sake, wouldn't it have been better to define in dynamic array properties a .sizeofref and a .sizeof (which behaves like the static array.sizeof)? It would not work because 1) .sizeof means the size of the variable that a

Re: CTFE template predicates

2015-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-05-04 03:52:21 +, Rikki Cattermole said: Have you looked at my book? https://leanpub.com/ctfe I bought it. Will it be updated? It's very generic with respect the concept and I'm missing code examples for all the user-cases. Especially the generator part is IMO very interesting.

Re: CTFE enums static assert

2015-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 05/04/2015 11:07 AM, Robert M. Münch wrote: enum A {a, b, c}; enum members1 = __traits(allMembers, A); auto members2 = __traits(allMembers, A); 1. So the (string, string, string) output is based on the expression of members1? Meaning, the right-hand-side. There are many different

Re: CTFE template predicates

2015-05-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 5/05/2015 6:24 a.m., Robert M. Münch wrote: On 2015-05-04 03:52:21 +, Rikki Cattermole said: Have you looked at my book? https://leanpub.com/ctfe I bought it. Will it be updated? It's very generic with respect the concept and I'm missing code examples for all the user-cases.

Re: Efficiently passing structs

2015-05-04 Thread bitwise via Digitalmars-d-learn
On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need for worrying about copying like you tend to have to do

opEquals optimized away?

2015-05-04 Thread Manfred Nowak via Digitalmars-d-learn
class C{ override bool opEquals( Object o){ return true; } } unittest{ auto c= new C; assert( c == c); } `rdmd --main -unittest -cov' shows, that opEquals is not executed. Why? -manfred

Re: Efficiently passing structs

2015-05-04 Thread rsw0x via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 02:47:03 UTC, bitwise wrote: On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need

Re: opEquals optimized away?

2015-05-04 Thread anonymous via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 04:09:03 UTC, Manfred Nowak wrote: class C{ override bool opEquals( Object o){ return true; } } unittest{ auto c= new C; assert( c == c); } `rdmd --main -unittest -cov' shows, that opEquals is not executed. Why? -manfred because `c is c`

DMD phobos built with contracts check for win?

2015-05-04 Thread Dzugaru via Digitalmars-d-learn
I have to compile it myself from sources or is it available somewhere? Was playing with fibers using VisualD + DMD and lack of contract checking (for example call() on fiber in state TERM) leads to bizarre crashes :(

Re: CTFE enums static assert

2015-05-04 Thread ketmar via Digitalmars-d-learn
On Mon, 04 May 2015 20:07:27 +0200, Robert M. Münch wrote: Gives this: (string, string, string) playground.d(9): Error: no type for typeid(members1) playground.d(9):while evaluating pragma(msg, typeid(members1)) `typeid` is runtime thing, you can't use it in compile-time.

Linker command

2015-05-04 Thread Paul via Digitalmars-d-learn
Can some one tell me what this linker command means (or point me at some docs) please: dmd example.d -L-L. $@ AFAIK $@ is 'all the supplied arguments' so I don't understand what it achieves. (it's from the DAllegro5 example program, on Linux). Cheers, Paul

Re: Reading bzipped files

2015-05-04 Thread monty via Digitalmars-d-learn
On Sunday, 3 May 2015 at 14:37:32 UTC, Per Nordlöw wrote: On Saturday, 2 May 2015 at 20:37:44 UTC, tom wrote: i use Stephan Schiffels code from http://forum.dlang.org/thread/djhteyhpcnaskpabx...@forum.dlang.org?page=2 See polished version at: