Re: Version() for unittest OR debug?

2014-06-10 Thread Kagamin via Digitalmars-d-learn
debug version = DebugOrUnittest; else version(unittest)version = DebugOrUnittest; version(DebugOrUnittest) { static assert(false,"DebugOrUnittest"); }

Re: Basic dynamic array question. Use of new versus no new.

2014-06-10 Thread Ali Çehreli via Digitalmars-d-learn
On 06/10/2014 08:06 PM, Matt wrote: > On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry wrote: >> int[] array; // initially empty >> array.length = 5; // now has 5 elements >> >> while in Mr. Alexandrescu's book, it says >> >> To create a dynamic array, use a new expression (§ 2.3.6.1 on p

Re: problem with Access Violation, and I'm not sure where

2014-06-10 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 02:59:40 UTC, Matt wrote: I previously asked this over in the DigitalMars.D board(http://forum.dlang.org/thread/huftyrtbomaimuqkm...@forum.dlang.org#post-hrqvqlzzbkgafvjdtjnb:40forum.dlang.org), but it was suggested I ask it over here instead. I have the following

Re: crt1.o: could not read symbols: Bad value

2014-06-10 Thread Tim via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 20:29:56 UTC, FreeSlave wrote: dmd has -shared option. Try it instead of -L-shared. I'm getting a similar error: /usr/bin/ld: /usr/local/bin/../lib64/libphobos2.a(object__a_58c.o): relocation R_X86_64_32 against `_D10TypeInfo_m6__initZ' can not be used when makin

Re: Basic dynamic array question. Use of new versus no new.

2014-06-10 Thread Kapps via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry wrote: In Mr. Cehreli's book it says Additionally, the length of dynamic arrays can be changed by assigning a value to this property: int[] array; // initially empty array.length = 5; // now has 5 elements while in Mr. Alexandrescu's bo

Re: Basic dynamic array question. Use of new versus no new.

2014-06-10 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 02:30:01 UTC, WhatMeWorry wrote: In Mr. Cehreli's book it says Additionally, the length of dynamic arrays can be changed by assigning a value to this property: int[] array; // initially empty array.length = 5; // now has 5 elements while in Mr. Alexandrescu's bo

Basic dynamic array question. Use of new versus no new.

2014-06-10 Thread WhatMeWorry via Digitalmars-d-learn
In Mr. Cehreli's book it says Additionally, the length of dynamic arrays can be changed by assigning a value to this property: int[] array; // initially empty array.length = 5; // now has 5 elements while in Mr. Alexandrescu's book, it says To create a dynamic array, use a new expression (§

Re: Class Data Members Name Reflection

2014-06-10 Thread Kapps via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 20:01:37 UTC, Nordlöw wrote: Notice that A.init.tupleof segfaults for classes so that is _not_ an adviced solution in a generic solution! There's no need to use .init: import std.stdio; struct Foo { int a, b; } void main() { writeln(__traits(id

Re: Class Data Members Name Reflection

2014-06-10 Thread Kapps via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 16:13:31 UTC, Adam D. Ruppe wrote: Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: S s; foreach(idx, member; s.tupleof) { writeln("Name: ", s.tupleof[idx].stringof[2..$]); } The tupleof[idx] inside th

Re: hijacking override from template mixin

2014-06-10 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 9 June 2014 at 16:13:50 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 15:54:21 UTC, Ivan Kazmenko wrote: I'd expect a "multiple overrides of same function" error, much like if I just paste the mixin code by hand. Is that a bug or working by design? In the latter case, please

Re: D aliases vs. C typedefs

2014-06-10 Thread Chris Cain via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 22:00:34 UTC, Ali Çehreli wrote: http://stackoverflow.com/questions/10758811/c-syntax-for-functions-returning-function-pointers int (*(*(*f3)(int))(double))(float); "f3 is a ..." Ali f3 is a pointer to a function taking an int returning a pointer to a function

Re: Splitting Ranges using Lambda Predicates

2014-06-10 Thread Nordlöw
Either way, it shouldn't be too hard to implement. Base it off "splitter!pred", which is actually quite trivial. AFAIK, your What do you mean by basing it off splitter!pred - should I start with some existing splitter algorithm in Phobos or start from scratch? Thx.

Re: D aliases vs. C typedefs

2014-06-10 Thread Ali Çehreli via Digitalmars-d-learn
On 06/10/2014 01:48 PM, monarch_dodra wrote: > I am ***INCREDIBLY*** glad D's stance is simply "depth first left to > right". I completely agree. > It *supports* C style, but unless you are copy pasting some C > code, you'd have to be mad in your head to actually ever use it. > > Honestly, try

Re: Splitting Ranges using Lambda Predicates

2014-06-10 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 21:26:50 UTC, monarch_dodr What exactly are you requesting though? - Split on the "edge" lowercase to uppercase? - Split on uppercase but keep the uppercase element? Thinking about this more: Do you *actually* have two different predicates, or are they mutually excl

Re: Splitting Ranges using Lambda Predicates

2014-06-10 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 21:11:17 UTC, Nordlöw wrote: 1. someName => SomeName My example is dumb and incorrect. I actually want this to do the following 2. "_someGreatVariableName" => "Some Great Varible Name" The current splitter works on the notion of splitter "tokens", eg, it splits

Re: Splitting Ranges using Lambda Predicates

2014-06-10 Thread Nordlöw
1. someName => SomeName My example is dumb and incorrect. I actually want this to do the following 2. "_someGreatVariableName" => "Some Great Varible Name"

Splitting Ranges using Lambda Predicates

2014-06-10 Thread Nordlöw
I'm missing a version of splitter that can be used to split ranges based on arbitrary predicates. I need to for conversion between different symbol casings, typically: 1. someName => SomeName In this case the lambda should take two arguments (a,b) where in 1. a should be lowercase and b shou

Source File and Position of User Defined Type

2014-06-10 Thread Nordlöw
Is there a way to, programatically (trait), lookup the source file and position of a user defined type either dynamically or, even better, statically?

Re: D aliases vs. C typedefs

2014-06-10 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 20:33:03 UTC, Ali Çehreli wrote: I think they are actually legal: This is D's support of C-style array declaration acting the same in alias declaration: Ali C-style array declaration has got to be one of C's *worst* abominations. There's no real *technical* ration

Re: D aliases vs. C typedefs

2014-06-10 Thread Ali Çehreli via Digitalmars-d-learn
On 06/10/2014 01:18 PM, Tom Browder via Digitalmars-d-learn wrote: >>> alias int[2] val5[2]; // D: a 2-dimensional array of ints? (int[2][2]) >>> ? >> >> Pretty strange. :) >> >> pragma(msg, val5); >> >> outputs this: >> >> int[2][2] > > Okay, checks with my guess. > >>> alias int[4] v

Re: crt1.o: could not read symbols: Bad value

2014-06-10 Thread FreeSlave via Digitalmars-d-learn
dmd has -shared option. Try it instead of -L-shared.

crt1.o: could not read symbols: Bad value

2014-06-10 Thread Tim via Digitalmars-d-learn
Hi guys, I've the following few lines: module test; export: extern(D): int test() { return 0; } ... and compile it using the following line: dmd -m64 -fPIC -L-shared test.d -oflibtest.so But when I try to compile it, I always get the following error: /usr/bin/ld: /usr/lib/gcc/x8

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
On Tuesday, 10 June 2014 at 17:29:35 UTC, Dicebot wrote: On Tuesday, 10 June 2014 at 16:10:09 UTC, Nordlöw wrote: Is there a way to iterate over the symbolic names of the data members of a class instance? I'm currently using .tupleof to get its values (and in turn types) to implement pretty

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
BTW: Can DMD serve use file and line location of user defined type aswell? Thx! Correction: I mean serve *us*

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
I am not sure I understand the question. Does this help? struct A { int x; double y; } void main() { foreach (idx, elem; A.init.tupleof) { pragma(msg, __traits(identifier, A.tupleof[idx])); } } // output: // x // y Exactly what I wanted!

D aliases vs. C typedefs

2014-06-10 Thread Tom Browder via Digitalmars-d-learn
I haven't found a detailed description of simple aliases. TPDL shows aliases of this form: alias TYPE NAME; with some complex examples of D types aliased to a simpler name. The D lang web site language reference says nothing about aliases (except as it's described in the grammar), and the D l

Re: Class Data Members Name Reflection

2014-06-10 Thread Dicebot via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 16:10:09 UTC, Nordlöw wrote: Is there a way to iterate over the symbolic names of the data members of a class instance? I'm currently using .tupleof to get its values (and in turn types) to implement pretty printing to multiple backends (currently testing HTML) u

Re: Class Data Members Name Reflection

2014-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 16:30:52 UTC, Nordlöw wrote: What trait should I use to filter out data members? No trait, more like an is thing to see if the thing has an init. I think static if(is(typeof(__traits(getMember, Thing, name).init)) { } will do it. (BTW the sample chapter of my boo

Re: Dub. Mercurial (bitbucket.org). Projects deployment

2014-06-10 Thread Uranuz via Digitalmars-d-learn
Also I have additional question to this post. 6. If I would convert my repo to git, but use anather hosting that github.org for example my own local server or bitbucket.org. How could I specify source for loading dependencies? This is unclear from dub documentation. Is it a tool for working wit

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
On Tuesday, 10 June 2014 at 16:13:31 UTC, Adam D. Ruppe wrote: Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: What trait should I use to filter out data members? S s; foreach(idx, member; s.tupleof) { writeln("Name: ", s.tupleo

Re: enum template shorthand and short circuit evaluation

2014-06-10 Thread Byron Heads via Digitalmars-d-learn
On Tue, 10 Jun 2014 17:06:08 +0200, Artur Skawina via Digitalmars-d-learn wrote: > On 06/10/14 02:28, Byron via Digitalmars-d-learn wrote: >> Should this work? It seems like the short circuit booleans are not >> working: >> >> enum isPrimitive(T) = isBasicType!T || (isArray!T && isBasicType! >>

Re: Class Data Members Name Reflection

2014-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: S s; foreach(idx, member; s.tupleof) { writeln("Name: ", s.tupleof[idx].stringof[2..$]); } The tupleof[idx] inside the loop is important instead of just using member because then y

Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
Is there a way to iterate over the symbolic names of the data members of a class instance? I'm currently using .tupleof to get its values (and in turn types) to implement pretty printing to multiple backends (currently testing HTML) using as much of D's compile time reflection as possible:

Decimal type documentation

2014-06-10 Thread Poyeyo via Digitalmars-d-learn
Hello, has anyone used this https://github.com/andersonpd/decimal implementation? I'm learning D and want to know where to start for the decimal (or bigfloat) stuff. The goal is to be able to read and write some data from a SQL DB with a decimal(10,2) field.

Re: enum template shorthand and short circuit evaluation

2014-06-10 Thread Artur Skawina via Digitalmars-d-learn
On 06/10/14 02:28, Byron via Digitalmars-d-learn wrote: > Should this work? It seems like the short circuit booleans are not > working: > > enum isPrimitive(T) = isBasicType!T || (isArray!T && isBasicType! > (ForeachType!T)); [...] > But this style works: > > template isPrimitive(T) > { >

Re: Version() for unittest OR debug?

2014-06-10 Thread bearophile via Digitalmars-d-learn
Juanjo Alvarez: Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||) Regarding your latest ER, Walter is usually not fond of such ideas. I have seen many similar ideas being shot down. Bye, bearophile

Re: Version() for unittest OR debug?

2014-06-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 10/06/14 16:06, bearophile wrote: You can define a enum boolean value in the version unittest block, and another inside the debug {} else {}. And then you can use "if (b1 || b2) { ... }". "static if" is probably what's needed. -- /Jacob Carlborg

Re: Version() for unittest OR debug?

2014-06-10 Thread bearophile via Digitalmars-d-learn
Juanjo Alvarez: Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||) At first I tough I could do: version(unittest, debug) {} You can define a enum boolean value in the version unittest block, and another inside the debu

Version() for unittest OR debug?

2014-06-10 Thread Juanjo Alvarez via Digitalmars-d-learn
Hi, Probably I pretty simple question, how could I mark some code to be compiled when in debug OR unittest mode? (or both, ||) At first I tough I could do: version(unittest, debug) {} but this doesn't work. Then I tried to define a new version: version(DebugOrUnittest) { version = debug;

Dub. Mercurial (bitbucket.org). Projects deployment

2014-06-10 Thread Uranuz via Digitalmars-d-learn
I have web-application project in D language hosted on bitbucket.org. So I using Mercurial repository. I exactly have two *logical* projects but currently they are in one repo. The first is my library that includes not only D code, but also some resources like HTML-page templates (not compiled