On Sunday, 15 April 2012 at 02:20:34 UTC, Joseph Rushton Wakeling
wrote:
On 14/04/12 23:03, q66 wrote:
He also uses a class. And -noboundscheck should be
automatically induced by
-release.
Ahh, THAT probably explains why some of my numerical code is so
markedly different in speed when compil
(I have a memory of a program that took
~0.004s with a C/C++ version and 1s with D, and the difference
seemed to be just startup time for the D program.)
I have never seen anything like that. Usually the minimal time to
run a D program is something like:
j@debian:~$ time ./hello
Hello world!
On Sunday, 15 April 2012 at 03:41:55 UTC, jerro wrote:
(I have a memory of a program that took
~0.004s with a C/C++ version and 1s with D, and the difference
seemed to be just startup time for the D program.)
I have never seen anything like that. Usually the minimal time
to run a D program
- Return 0 from main() for successful exit, anything else by
convention means some sort of error.
Why not just declare main return type to be void?
On Tuesday, 17 April 2012 at 01:30:30 UTC, ReneSac wrote:
On Monday, 16 April 2012 at 22:58:08 UTC, Timon Gehr wrote:
On 04/17/2012 12:24 AM, ReneSac wrote:
Windows.
DMC runtime !
DMC = Digital Mars Compiler? Does Mingw/GDC uses that? I think
that both, g++ and GDC compiled binaries, use th
On Wednesday, 18 April 2012 at 03:47:31 UTC, Joseph Rushton
Wakeling wrote:
Can anyone explain to me why, when I compile & run this code,
the two samples seeded with the unpredictableSeed always come
out with the same starting value?
On Wednesday, 18 April 2012 at 03:47:31 UTC, Joseph Rushton
Wakeling wrote:
Can anyone explain to me why, when I compile & run this code,
the two samples seeded with the unpredictableSeed always come
out with the same starting value?
On Wednesday, 18 April 2012 at 05:05:20 UTC, Joseph Rushton
Wakeling wrote:
On 18/04/12 06:43, jerro wrote:
According to the comment the call to prime() is necessary
so that the result doesn't always start with the same element.
But prime() uses the gen member which is only assigned after
On Sunday, 22 April 2012 at 22:17:11 UTC, Stephen Jones wrote:
Thanks for the replies. I am still uncertain about something.
The documentation distinguishes between dynamic slices (int[5]
a = new int[5]) which are managed by the runtime, and stack
allocated arrays (int[5] b). The problem I have
On Sunday, 22 April 2012 at 23:01:26 UTC, jerro wrote:
On Sunday, 22 April 2012 at 22:17:11 UTC, Stephen Jones wrote:
Thanks for the replies. I am still uncertain about something.
The documentation distinguishes between dynamic slices (int[5]
a = new int[5]) which are managed by the runtime
What about (untested):
auto uniformRange(T1 lower, T2 upper) {
return count().map!(_ => uniform(lower, upper))();
}
Where count() is just:
http://d.puremagic.com/issues/show_bug.cgi?id=7839
In the meantime cycle([0]) is acceptable but slower (untested):
return cycle([0]).map!(_ => uniform(
It's for a different purpose. So the count() I was proposing
will need a different name.
Couldn't it just be iota with no parameters?
This is the closest thing:
---
struct C {
int x;
int* ptr() @property { return &x; }
}
C foo;
*foo.ptr = 10;
assert(foo.x = 10);
---
Now you can also do:
struct C
{
int x;
}
int* ptr() @property { return &x; }
C foo;
*foo.ptr = 10;
assert(foo.x = 10);
if you can't or don't want to cha
Now you can also do:
struct C
{
int x;
}
int* ptr() @property { return &x; }
C foo;
*foo.ptr = 10;
assert(foo.x = 10);
if you can't or don't want to change C.
int* ptr() @property { return &x; }
should be
int* ptr(ref C c) @property { return &c.x; }
On Sunday, 20 May 2012 at 21:19:14 UTC, p0xel wrote:
This seems to work when the class is in the same file as
main(), but if I move it to it's own file and use "import foo"
it errors. What am I missing?
When you write "import foo;" and then foo.bar, the compiler
thinks that
you a referring to
On Monday, 21 May 2012 at 11:26:33 UTC, simendsjo wrote:
Shouldn't the following work?
import std.range;
import std.stdio;
void main() {
int[] a;
a.reserve(10);
//a.put(1); // Attempting to fetch the front of an empty
array of int
a.length = 1;
writeln(a.length); // 1
void put(int v){ arr ~= v; }
should be
void put(T v){ *arr ~= v; }
On Wednesday, 23 May 2012 at 21:46:24 UTC, snow wrote:
Hello, Ive tried to install D under Linux and followed the steps
described on . this page http://dlang.org/dmd-linux.html . I
checked all folders after every step and everything is where it
should be. In the secound step I did both, adding dm
On Saturday, 26 May 2012 at 13:49:53 UTC, maarten van damme wrote:
Is there an easy way to speed up or is this the
ceiling?
I got a 30 percent speedup by replacing this line:
if(&& canFind(quicktestPrimes, possiblePrime))
with this:
if(quicktestPrimes.back >= possiblePrime &&
canFind(qui
On Saturday, 26 May 2012 at 18:40:53 UTC, maarten van damme wrote:
well, I was thinking about using a sieve but when you were to
request
prime 400_000 you're sieve would blow up in size.
Because you only need primes up to sqrt(n) to check if n is prime,
you can make a sieve based range that on
On Sunday, 27 May 2012 at 03:29:17 UTC, dnewbie wrote:
In C I can write
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
In D, there is no ZeroMemory. Please help me.
You could use c memset:
import std.c.string;
memset(cast(void*)&ofn, 0, ofn.sizeof);
or this:
(cast(byte*)& a)[0 .. a.sizeo
I ran in two problems. It was extremely fast when sieving a
byte array
of 1 million entries (without optimizations at all) but when
trying
with 10_000_000 entries the program crashes before it even
starts to
execute (main isn't reached).
You say it does compile, but then crashes immediatly? I
On Sunday, 27 May 2012 at 17:00:01 UTC, maarten van damme wrote:
ok, can't seem to reproduce the crashing. now on to optimizing
my
sieve a bit more ,9 miliseconds for 1_000_000 is still to slow.
--
Er is zon buiten. Zonnige zondag namiddag met priemgetallen in
de
plaats van buiten zitten. Tss
I tried using 6k+-1 for all primes and for some reason it
performed
slower. I think I have something completely inefficient
somewhere,
can't figure out where though.
You aren't, by any chance, using divisions or remainders? those
are much slower than, say, multiplications (unless the divisor
i
That is, for one thing, sub is asymmetric :)
Hmm well subs would all happen at the 1 bit level. So let's
compare.
xor
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0
sub
0 - 0 = 0
0 - 1 = -1 (or non-zero/true, truncates to 1)
1 - 0 = 1
1 - 1 = 0
Sorry, seems the same unless we are going with carry
1) Is there a way to force a function to be always executed at
compile time (when it's possible to do so) no matter what
context it's called in?
No, but you could wrap it in a template to force it to always
execute at compile time. Of course it could then only be called
at compile time.
2) Is
On Monday, 11 June 2012 at 03:19:08 UTC, ixid wrote:
struct a
{ align(16) int[4] test = [1,2,3,4];
}
a test;
asm
{
movdqa XMM0, test ;
addps XMM0, XMM0;
movdpa test, XMM0 ;
}
This works fine with unaligned movdqu but thro
The second one uses fstp twice, then fld twice. I don't know,
maybe
this could be a bug.
You're right the lack of one fst/fld in the first case is a bug.
x87 floating point registers are 80 bit. This:
fstpdword [ebp-0CH]
Converts the value in ST0 to single precision float and stores it
I don't really agree with that. floating point operations are
just inexact, regardless of optimizations. That's how they
work, period.
It is true that they are inexact, but inexact and
non-deterministic are not the same thing. Floating point
operations are deterministic. Doing the same operat
On Sunday, 30 September 2012 at 20:51:54 UTC, mist wrote:
Thanks!
Unfortunately, return type issue is more important in my case.
I'll check if implementation from ParameterStorageClassTuple
can be adapted for return types though.
I think this should work:
template returnsRef(alias f)
{
e
Technically (AFAIK), IEEE754 does need require reproducibility,
ergo determinism.
It actually requires more than that:
"Algebraic operations covered by IEEE 754, namely + , - , * , / ,
square root and Binary <-> Decimal Conversion with rare
exceptions, must be Correctly Rounded to the prec
On Monday, 1 October 2012 at 04:10:25 UTC, Ivan Agafonov wrote:
On Sunday, 30 September 2012 at 06:20:56 UTC, jerro wrote:
The second one uses fstp twice, then fld twice. I don't know,
maybe
this could be a bug.
You're right the lack of one fst/fld in the first case is a
bug. x8
While fiddling with this I came across something that seems odd
in the behaviour of reduce and wondered if it's intended. It
rather limits the usefulness of reduce with UFCS to "a + b" and
"a - b".
Reduce works correctly when provided with a seed argument:
reduce!"a + b + 2"(0, [1,1,1]).write
On Wednesday, 10 October 2012 at 00:18:17 UTC, ixid wrote:
Is there an effective way of splitting a string with a set of
tokens? Splitter feels rather limited and multiple passes gives
you an array of arrays of strings rather than an array of
strings. I'm not sure if I'm missing an obvious appl
Or alternative what about libraries for linear algebra and
statistic
methods ?
For statistics, there is dstats
(https://github.com/dsimcha/dstats) and for linear algebra, there
is scid (https://github.com/cristicbz/scid/).
On Thursday, 22 November 2012 at 21:26:20 UTC, Michael wrote:
On Wednesday, 8 August 2012 at 16:09:46 UTC, Simen Kjaeraas
wrote:
On Wed, 08 Aug 2012 15:46:23 +0200, ixid
wrote:
I'm using the recently released DMD2 version 2.060.
SIMD operations are not supported for Windows at the moment,
This works for me if I add parentheses to the line where you get
the error like this:
writeln(TestStruct().x.offsetof);//bug here
The error you were getting is not related to offsetof. The
problem seems to be that if you write TestStruct.x inside a
non-static method, the compiler thinks you a
On Monday, 26 November 2012 at 21:41:01 UTC, Michael wrote:
You can use them now with GDC. You can download Windows
binaries at https://bitbucket.org/goshawk/gdc/downloads.
It's has some dependencies that is hard to find.
You need to download this file (it's an installer for tdm gcc
4.6.1):
I don't know when dmd on windows will get SIMD support.
I have checked windows 64 bit dmd alpha now and it already
supports SIMD.
On Tuesday, 27 November 2012 at 19:40:56 UTC, Charles Hixson
wrote:
Is there a better way to do this? (I want to find files that
match any of some extensions and don't match any of several
other strings, or are not in some directories.):
import std.file;
...
string exts = "*.{txt,utf8,
won't. You seem to be looking for a function which will insert
an element
between every element in a range rather than one that joins
ranges, and I'm
not aware of any function in Phobos which will do that. There
may be a way to
get one to do what you want, but I can't think of how at the
moment
You could replace the inner loop with somehting like:
bool excl = exclude.any!(part => name.canFind(part));
std.algorithm seems to generally be running the match in the
opposite direction, if I'm understanding it properly. (Dealing
with D template is always confusing to me.) OTOH, I couldn'
OTOH, I still don't know where "any" is documented. It's
clearly some sort of template instantiation, but it doesn't
seem to be defined in either std.string or std.object (or
anywhere else I've thought to check). And it look as if it
would be something very useful to know.
It's documented h
On Friday, 30 November 2012 at 02:59:06 UTC, js.mdnq wrote:
I have a struct I am trying convert from int's to the type.
Since I can't add a opCast overload to an int I don't know how
to do it. My opCast convertors in my class do not work for the
assignment operator:
class myType
{
opCast,
On Saturday, 1 December 2012 at 12:51:27 UTC, thedeemon wrote:
On Saturday, 1 December 2012 at 11:36:16 UTC, Zardoz wrote:
The prevois code should work better if i set "total" to be
sahred and hope that D shared vars have nnow the internal
barries working ,or I need to manually use semaphores
plementing it right now AFAIK, that pretty much puts
the chances at
zero.
I've played with this a bit today. The code is at
https://github.com/jerro/dmd/tree/auto-ref. I know next to
nothing about DMD, so it could be all kinds of wrong, but it does
at least seem to work.
What do you thi
On Sunday, 30 December 2012 at 13:57:26 UTC, Namespace wrote:
I've played with this a bit today. The code is at
https://github.com/jerro/dmd/tree/auto-ref. I know next to
nothing about DMD, so it could be all kinds of wrong, but it
does at least seem to work.
What do you think should h
On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote:
Just hope for the best. Did you create a pull request?
No. I need to first make it work correctly with const at the very
least.
On Tuesday, 1 January 2013 at 01:10:20 UTC, Namespace wrote:
On Sunday, 30 December 2012 at 16:11:44 UTC, jerro wrote:
On Sunday, 30 December 2012 at 16:00:22 UTC, Namespace wrote:
Just hope for the best. Did you create a pull request?
No. I need to first make it work correctly with const at
So it is ready to merge?
I honestly don't know. I don't know enough about the DMD code
base to be confident that there aren't some serious problems with
my changes.
Another problem is that it isn't entirely clear how auto ref is
supposed to work. Should auto ref on templates work as it does
In my opinion you should do both, thread and also pull request.
I thank you again for your work. I'm using it already.
I have opened a pull request now and replied to the thread about
auto ref on digitalmars.D.
On Wednesday, 2 January 2013 at 01:05:09 UTC, Namespace wrote:
Maybe it's best to just make a pull request and let others
inspect the changes and discuss the semantics of auto ref. Or
maybe it would be better to make a thread in digitalmars.D
first?
In my opinion you should do both, thread an
... where k represents the index count 1, 2, 3, ... However,
it's not evident to me how you could get reduce() to know this
counting value.
You would use zip and sequence to add indices to x, like this:
reduce!reducer(initial, zip(x, sequence!"n"))
Where calculating Q[k] is concerned, you ne
reduce!reducer(MQ(x.front, 0), zip(x, sequence!"n"))
A small correction : you would need to use x.drop(1) instead of
x, because the first element of x is only used to compute the
initial value of 1. If you wanted k to have the same meaning as
the one in your formula, you would need to use seq
See enumerate():
http://d.puremagic.com/issues/show_bug.cgi?id=5550
I like this enumerate() thing. Is there any particular reason why
it isn't in phobos, or is it just that no one has added it yet?
I think with enumerate it becomes:
MQ(x.front, 0).enumerate(1).reduce!reducer()
I think the ar
When you are comparing LDC and GDC, you should either use
-mcpu=generic for ldc or -march=native for GDC, because their
default targets are different. GDC will produce code that works
on most x86_64 (if you are on a x86_64 system) CPUs by default,
and LDC targets the host CPU. But this does not
On Wednesday, 13 February 2013 at 18:42:51 UTC, H. S. Teoh wrote:
On Wed, Feb 13, 2013 at 06:57:52PM +0100, Korey Peters wrote:
Thanks for your response, H.S.Teoh.
On Wednesday, 13 February 2013 at 17:47:09 UTC, H. S. Teoh
wrote:
>You need to specify both files on the command line, so that
>t
Please file a bug report on this.
Done.
No progress is being made.
So, my questions:
- is this a potential deadlock in rdmd? I believe it attempts
to parallelize the work.
- has anyone experienced this?
I don't remember experiencing this with rdmd, but I have seen
something similar with my scripts that were starting processes
from
std.regex.RegexException@/usr/include/dmd/phobos/std/regex.d(1942):
wrong CodepointSet
Pattern with error: `[ 0-9a-zA-Z.*=+-;()"'[]` <--HERE--
`<>,{}^#/\\]`
(Entire error here: http://pastebin.com/Su9XzbXW)
You need to put \ in front of [ or ] if you want to match those
two characters. The r
Pattern with error: `[ 0-9a-zA-Z.*=+-;()"'\[\]<>,{}^#/\]`
<--HERE-- ``
The problem here is that you have \ right before the ] at the end
of the string. Because it is preceeded by \, ] is interpretted as
a character you are matching on, not as a closing bracket for the
initial [. If you want t
The only thing I've though of so far is to declare a class that
holds a bunch of abstract methods, and then have multiple
descendants that each have a special variant of the struct.
And even then I've either got to copy it again, or to cast it
each time I use it. (Though at least with this ap
On Monday, 18 February 2013 at 12:55:13 UTC, Lubos Pintes wrote:
Hi,
I just updated to DMD 2.062. I then tried to recompile somewhat
bigger project. After fixing some errors, I received dozens of
errors like this:
Error 42: Symbol Undefined _D3std6string6formatFYAya
(immutable(char)[] std.stri
On Monday, 18 February 2013 at 16:47:00 UTC, Lubos Pintes wrote:
I am playing with library dgui.
In 2.060, everything built fine.
One of library samples imports std.string. Perhaps the VisualD
doesn't include necessary library?
I updated the DMD as follows: I deleted the dmd2 from C:\D
folder a
D doesn't use null termination for it's strings, strings are
immutable(char)[]. You can form a D slice from a pointer by
going
slice = ptr[0..length]
where length is the length of the array the pointer represents.
You can't just take a c style string and expect writeln to work
with it.
You ca
P.S. I am in the process of translating my Turkish D book to
English. For
completeness, here are the two chapters about ranges:
http://ddili.org/ders/d/araliklar.html
http://ddili.org/ders/d/araliklar_baska.html
Why not link to the english translation, too?
http://ddili.org/ders/d.en/ran
D has a concept of iterators, which are similar to python's
iterators, but more general (python iterators are roughly
equivalent to input ranges). There are no generator functions in
D, but you can use fibers to get similar functionality, as Nick
Sabalausky showed in this thread:
http://forum
On Thursday, 21 February 2013 at 16:19:51 UTC, jerro wrote:
D has a concept of iterators
Should be:
D has a concept of ranges
On Wednesday, 27 February 2013 at 18:40:40 UTC, monarch_dodra
wrote:
On Wednesday, 27 February 2013 at 17:08:38 UTC, Alexandr
Druzhinin wrote:
27.02.2013 23:50, monarch_dodra пишет:
dmc seems to start choking when my font files start to reach
about 15 Mo.
I suppose there's a switch somewher
The timings on my (4 core) machine are:
sequential: 7.7s
concurent : 2.1s
Which is about what one would expect. One thing that could be
contributing to the timings you are seeing is Turbo Boost
(http://en.wikipedia.org/wiki/Intel_Turbo_Boost). Some mobile
processors have large (like for examp
But from googling around I see that /dev/random can block
fairly quickly, after only a handful of numbers :-(
You can solve this by using /dev/urandom instead, as Jerome have
said already.
Is something equivalent available on Windows?
There's CryptGenRandom.
On Friday, 8 March 2013 at 13:33:24 UTC, Andrea Fontana wrote:
I wonder if exists a way to get top n distinct elements from a
range (infinite too!)
It's impossible to do that for infinite ranges
A (not efficient) way to to this is
range.array.sort.uniq.take(n) but it's a bit overkill, it sort
On Friday, 8 March 2013 at 15:53:56 UTC, Andrea Fontana wrote:
On Friday, 8 March 2013 at 14:43:29 UTC, jerro wrote:
On Friday, 8 March 2013 at 13:33:24 UTC, Andrea Fontana wrote:
I wonder if exists a way to get top n distinct elements from
a range (infinite too!)
It's impossible to do
and a template
template t(alias A, alias B) {
// something something
}
Given
alias Tuple!(int, 1) A;
alias Tuple!(int, 1) B;
Is it possible to send this to template t as follows
t!(A, B)
without it expanding to
t!(int, 1, int, 1)
?
Not as far as I know. You can work that around it b
Is there a way to avoid default initializing a struct field in D?
The following doesn't seem to work:
struct Foo
{
int[42] buffer = void;
int bar;
}
I know I can do this:
Foo foo = void
But then all fields are uninitialized.
What code have you used to test it, and what is the result you
have seen?
I was using this code:
extern(C) void foo(Foo* r)
{
Foo tmp;
*r = tmp;
}
And here is the generated assembly (when using "= void"):
push %rbp
mov%rsp,%rbp
sub$0xc0,%rsp
mov%rdi,-0x10(%rbp)
movabs $0
On Monday, 6 May 2013 at 15:15:47 UTC, Steven Schveighoffer wrote:
On Sat, 04 May 2013 14:11:02 -0400, jerro wrote:
Is there a way to avoid default initializing a struct field in
D? The following doesn't seem to work:
struct Foo
{
int[42] buffer = void;
int bar;
}
I know I c
On Sunday, 26 May 2013 at 14:19:13 UTC, mimi wrote:
Hi!
I am want to get list of fields types and offsets in struct by
the template.
I.e., lookup through this struct:
struct S {
int a;
string b;
someptr* c;
};
template Lookup!( S )(); returns something as:
field #0, int, offset 0
field #1,
78 matches
Mail list logo