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
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 =
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
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
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
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)
{
static
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.
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:
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
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!
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: ,
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
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
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)
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
BTW: Can DMD serve use file and line location of user defined
type aswell?
Thx!
Correction: I mean serve *us*
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
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:
dmd has -shared option. Try it instead of -L-shared.
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] val6[2]; // D: a
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*
Is there a way to, programatically (trait), lookup the source
file and position of a user defined type either dynamically or,
even better, statically?
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
1. someName = SomeName
My example is dumb and incorrect.
I actually want this to do the following
2. _someGreatVariableName = Some Great Varible Name
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 when it
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
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 to
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.
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
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
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 the
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() {
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 (§
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
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
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
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
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 page 51)
as
38 matches
Mail list logo