Re: D 50% slower than C++. What I'm doing wrong?

2012-04-14 Thread jerro
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

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-14 Thread jerro
(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!

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-14 Thread jerro
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

Re: Templates in classes => what is wrong?

2012-04-15 Thread jerro
- 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?

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread jerro
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

Re: Not-so-unpredictable seed?

2012-04-17 Thread jerro
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?

Re: Not-so-unpredictable seed?

2012-04-17 Thread jerro
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?

Re: Not-so-unpredictable seed?

2012-04-17 Thread jerro
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

Re: Question about arrays

2012-04-22 Thread jerro
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

Re: Question about arrays

2012-04-22 Thread jerro
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

Re: Range of random numbers

2012-04-23 Thread jerro
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(

Re: Range of random numbers

2012-04-23 Thread jerro
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?

Re: Pointer to variables in D

2012-04-26 Thread jerro
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

Re: Pointer to variables in D

2012-04-26 Thread jerro
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; }

Re: static functions?

2012-05-20 Thread jerro
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

Re: std.range.put?

2012-05-21 Thread jerro
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

Re: std.range.put?

2012-05-21 Thread jerro
void put(int v){ arr ~= v; } should be void put(T v){ *arr ~= v; }

Re: D under Linux Mint

2012-05-23 Thread jerro
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

Re: speeding up + ctfe question

2012-05-26 Thread jerro
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

Re: speeding up + ctfe question

2012-05-26 Thread jerro
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

Re: Windows - ZeroMemory macro

2012-05-26 Thread jerro
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

Re: speeding up + ctfe question

2012-05-27 Thread jerro
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

Re: speeding up + ctfe question

2012-05-27 Thread jerro
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

Re: speeding up + ctfe question

2012-05-28 Thread jerro
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

Re: BitArray - Is there one?

2012-05-28 Thread jerro
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

Re: Is it possible to force CTFE?

2012-06-10 Thread jerro
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

Re: align(16) struct member throws an exception with movdqa

2012-06-10 Thread jerro
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

Re: Very strange problem with comparing floating point numbers

2012-09-29 Thread jerro
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

Re: Very strange problem with comparing floating point numbers

2012-09-30 Thread jerro
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

Re: Metaprogramming: check for ref

2012-09-30 Thread jerro
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

Re: Very strange problem with comparing floating point numbers

2012-09-30 Thread jerro
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

Re: Very strange problem with comparing floating point numbers

2012-09-30 Thread jerro
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

Re: Functional vs simple code

2012-10-02 Thread jerro
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

Re: Splitting a string on multiple tokens

2012-10-09 Thread jerro
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

Re: Libraries for machine learning or artificial intelligence.

2012-11-25 Thread jerro
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/).

Re: Error: SIMD vector types not supported on this platform

2012-11-25 Thread jerro
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,

Re: Bug with offsetof?

2012-11-25 Thread jerro
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

Re: Error: SIMD vector types not supported on this platform

2012-11-26 Thread jerro
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):

Re: Error: SIMD vector types not supported on this platform

2012-11-26 Thread jerro
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.

Re: path matching problem

2012-11-27 Thread jerro
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,

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread jerro
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

Re: path matching problem

2012-11-27 Thread jerro
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'

Re: path matching problem

2012-11-28 Thread jerro
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

Re: Type converter from build in to user type

2012-11-29 Thread jerro
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,

Re: How works internally ParallelForEach

2012-12-01 Thread jerro
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

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread jerro
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

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread jerro
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

Re: structs are now lvalues - what is with "auto ref"?

2012-12-30 Thread jerro
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.

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread jerro
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

Re: structs are now lvalues - what is with "auto ref"?

2013-01-01 Thread jerro
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

Re: structs are now lvalues - what is with "auto ref"?

2013-01-02 Thread jerro
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.

Re: structs are now lvalues - what is with "auto ref"?

2013-01-03 Thread jerro
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

Re: Calculating mean and standard deviation with std.algorithm.reduce

2013-02-13 Thread jerro
... 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

Re: Calculating mean and standard deviation with std.algorithm.reduce

2013-02-13 Thread jerro
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

Re: Calculating mean and standard deviation with std.algorithm.reduce

2013-02-13 Thread jerro
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

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread jerro
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

Re: Importing problems

2013-02-13 Thread jerro
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

Re: Importing problems

2013-02-13 Thread jerro
Please file a bug report on this. Done.

Re: rdmd hung?

2013-02-15 Thread jerro
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

Re: Issues with std.regex

2013-02-16 Thread jerro
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

Re: Issues with std.regex

2013-02-16 Thread jerro
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

Re: How to dynamically alias a struct to a byte array?

2013-02-17 Thread jerro
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

Re: Linker errors and how to catch them

2013-02-18 Thread jerro
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

Re: Linker errors and how to catch them

2013-02-18 Thread jerro
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

Re: D-DLLs & Python

2013-02-19 Thread jerro
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

Re: Any python-like generator patterns in D?

2013-02-21 Thread jerro
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

Re: Any guide to stream (string) processing in D? | Re: Any python-like generator patterns in D?

2013-02-21 Thread jerro
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

Re: Any guide to stream (string) processing in D? | Re: Any python-like generator patterns in D?

2013-02-21 Thread jerro
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

Re: Linking C and D

2013-02-27 Thread jerro
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

Re: Concurrency and program speed

2013-02-28 Thread jerro
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

Re: unpredictableSeed

2013-03-03 Thread jerro
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.

Re: how to get top N distinct elements from range?

2013-03-08 Thread jerro
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

Re: how to get top N distinct elements from range?

2013-03-08 Thread jerro
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

Re: Passing several tuples (T...) to templates without expanding them

2013-03-13 Thread jerro
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

Avoid initializing a struct field.

2013-05-04 Thread jerro
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.

Re: Avoid initializing a struct field.

2013-05-04 Thread jerro
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

Re: Avoid initializing a struct field.

2013-05-06 Thread jerro
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

Re: lookup fields struct

2013-05-26 Thread jerro
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,