Re: object hijacked ?
On 09/10/14 22:06, Dicebot wrote: I think this is an issue with the import resolution, not module system. The way it is implemented right now DMD stops searching for object.d / object.di once it has found one. So while your module name is not interpreted as object _original_ object.di does not get imported and you get lot of different issues from missing declarations. So it just picks the first filename matching object and doesn't care about its module name. -- /Jacob Carlborg
Re: std.container.Array deep-copy?
On Thursday, 9 October 2014 at 21:24:55 UTC, qznc wrote: On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup. However, the error is still open. You cannot give an Array!X argument to constructor/replace/insertBefore of Array!X instances? You will just need to slice it to provide a range.
__traits(getMember) works only the second time
Hi, by executing the example source code, following output is returned: Reference: Child false true At first childStr is not found, then it is found? Is this a bug? Kind regards André - module app; import test; class Child : Parent { mixin ComponentTemplate; @property string childStr(){return ;} } void main() { auto child = new Child(); child.getParameters(); } - module test; template Params(this MyType) { string[] Params() { pragma(msg, Reference: ~ MyType.stringof); pragma(msg, is(typeof(__traits(getMember, MyType, childStr; pragma(msg, is(typeof(__traits(getMember, MyType, childStr; return []; } } mixin template ComponentTemplate() { private enum parameters = Params!(typeof(this)); string[] getParameters() { return parameters; } } class Parent { @property string parentStr(){return ;} }
Re: __traits(getMember) works only the second time
On 10/10/2014 8:08 p.m., andre wrote: Hi, by executing the example source code, following output is returned: Reference: Child false true At first childStr is not found, then it is found? Is this a bug? Kind regards André - module app; import test; class Child : Parent { mixin ComponentTemplate; @property string childStr(){return ;} } void main() { auto child = new Child(); child.getParameters(); } - module test; template Params(this MyType) { string[] Params() { pragma(msg, Reference: ~ MyType.stringof); pragma(msg, is(typeof(__traits(getMember, MyType, childStr; pragma(msg, is(typeof(__traits(getMember, MyType, childStr; return []; } } mixin template ComponentTemplate() { private enum parameters = Params!(typeof(this)); string[] getParameters() { return parameters; } } class Parent { @property string parentStr(){return ;} } Wrong trait for the job. Use hasMember instead. Although interesting use case. Could be a bug somewhere in there.
Re: __traits(getMember) works only the second time
Certainly a bug; please file a report at https://issues.dlang.org/
Re: std.container.Array deep-copy?
On Friday, 10 October 2014 at 06:27:35 UTC, yazd wrote: On Thursday, 9 October 2014 at 21:24:55 UTC, qznc wrote: On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup. However, the error is still open. You cannot give an Array!X argument to constructor/replace/insertBefore of Array!X instances? You will just need to slice it to provide a range. Like the following? That did not work. Array!Foo y = Array!Foo(x[]);
Re: How do I write __simd(void16*, void16) ?
On Thu, 09 Oct 2014 17:19:05 -0400 Etienne via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Unforunately the gcc.buildints module seems to be generated during compilation of gdc, so you might want to get a binary version or compile it yourself to see the module. OK, thanks ! why, ketmar to the rescue! gcc.builtins is empty module. ;-) actually, importing it works like a trigger, and then programmer has access to GCC builtins defined in GCC source. one can read GCC documentation to find more information about 'em. also, importing this module defines some types. here they are: __builtin_va_list The target's va_list type )) __builtin_clongThe D equivalent of the target's C long type __builtin_culong The D equivalent of the target's C unsigned long __builtin_machine_intSigned word-sized integer __builtin_machine_uint Unsigned word-sized integer __builtin_pointer_intSigned pointer-sized integer __builtin_pointer_uint Unsigned pointer-sized integer signature.asc Description: PGP signature
Re: Byte Array Literal
On Thu, 09 Oct 2014 20:08:11 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The problem is that cast. No one wants a string, most people want a ubyte[]. This doesn't make the cut. it's handy, people wants it, it will break almost nothing... no way. signature.asc Description: PGP signature
COFF on Win32 how to try?
I would like to try recently merged COFF support on Win32 for a hybrid D/C++ application. Until now I tried that (hybridizing) only with DMD from the official installer and in x64 mode. My question is: how to try the same in 32 bits?
Re: Splitting Ranges using Lambda Predicates
On Friday, 10 October 2014 at 05:55:00 UTC, Nordlöw wrote: On Thursday, 9 October 2014 at 22:01:31 UTC, monarch_dodra wrote: My quick guess is you are missing the *global* imports for the restraints. The compiler doesn't complain because the constraint is in a is(typeof(...)) test. The reason the typeof fails is simply cause the compiler has no idea what unaryFun is. I don't understand. The restraints are commented out at https://github.com/nordlow/justd/blob/master/slicer.d I made a couple of changes and now it works but I don't quite understand why... Thanks anyway. Sorry, I read your compile error wrong, and was on my phone. Anyways, I'm a bit worried, because it looks like an internal phobos compile error. May I request you attempt to re-create and potentially reduce the issue? I want to make sure you didn't uncover a bug...
Re: std.container.Array deep-copy?
Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0
Re: std.container.Array deep-copy?
On Friday, 10 October 2014 at 10:32:17 UTC, yazd wrote: Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0 yeah man.
Re: __traits(getMember) works only the second time
I use the syntax is(typeof(__traits(getMember, MyType, childStr))) to check whether a member is public visible or not. (The example above is only a reduced example) By the way hasMember works correctly. I will file an issue. Kind regards André On Friday, 10 October 2014 at 07:25:28 UTC, Rikki Cattermole wrote: On 10/10/2014 8:08 p.m., andre wrote: Wrong trait for the job. Use hasMember instead. Although interesting use case. Could be a bug somewhere in there.
Re: What is a sink delegate?
On Friday, 10 October 2014 at 04:42:04 UTC, thedeemon wrote: On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try(Joel, 35); t.toString(s = writeln(s)); } I think that the problem pointed by the OP is that toString is usually used automatically for struct in std.conv when it's implemented. I'm myself quite dubitatif in front of this syntax, even if IIRC during one talk of the DConf 2014 someone claim that's it's faster.
Re: How to install dmd2 in centos 5.3 x64
On Wednesday, 26 February 2014 at 00:56:53 UTC, thr4wa wrote: i already tried LD_LIBRARY_PATH (and alternatives), however, looking deeper it seems like the admin has disabled LD_LIBRARY_PATH on this system (work terminal): http://stackoverflow.com/questions/9843178/linux-capabilities-setcap-seems-to-disable-ld-library-path On Tuesday, 25 February 2014 at 22:37:28 UTC, FreeSlave wrote: It's not dmd problem, it's up to ld linker and the issue is same for other compiled languages including C and C++. You should specify LD_LIBRARY_PATH variable in your system before executing any compiled D application. You can add export of this environment variable to your $HOME/.profile or $HOME/.bashrc depending on your system or edit paths in /etc/ld.so.conf.d or /etc/ld.so.conf. The other way is to copy libphobos to path where ld can find it by default, for example, /usr/local/lib. Hello, thr4wa, do you solve your problem, described above? I have same error: /usr/bin/ld: cannot find -l:libphobos2.a What I tried to do: 1) export LD_LIBRARY_PATH=/usr/lib64 2) copy libphobos2.a and libphobos2.so to /usr/lib64 3) soft link to this libraries from /usr/lib 4) added dmd -L-L/usr/lib64 compile flags in the dmd.conf file 5) added /usr/lib64 to the /etc/ld.so.conf
Re: dupping to allow vector operation?
On Thursday, 9 October 2014 at 18:01:27 UTC, John Colvin wrote: On Thursday, 9 October 2014 at 11:29:14 UTC, bearophile wrote: Observe: void main() { int[3] a1 = [1, 3, 6]; int[] a2 = a1[] * 3; // line 3, Error int[] a3 = a1.dup[] *= 3; // line 4, OK? int[] a4 = (a1[] * 3).dup; // line 5, Error } Currently the operation in line 4 is accepted: test.d(3,17): Error: array operation a1[] * 3 without destination memory not allowed test.d(5,18): Error: array operation a1[] * 3 without destination memory not allowed Is it a good idea to support something like line 5? Bye, bearophile Why not? Looks fine to me, you've explicitly allocated some new memory for the result to sit in, the lack of which is the motivation for lines 3 an 5 being errors. To clarify: 4 is good, 3 and 5 are not.
Re: How do I write __simd(void16*, void16) ?
On 2014-10-10 4:12 AM, ketmar via Digitalmars-d-learn wrote: actually, importing it works like a trigger, and then programmer has access to GCC builtins defined in GCC source. one can read GCC documentation to find more information about 'em. Hi ketmar, Which type would have to be sent to the corresponding functions? I have a hard time figuring out how to use the __m128i with the proper mangling. Does it use core.simd's Vector!x types there?
Re: How to install dmd2 in centos 5.3 x64
On Friday, 10 October 2014 at 11:41:04 UTC, Rafael wrote: On Wednesday, 26 February 2014 at 00:56:53 UTC, thr4wa wrote: i already tried LD_LIBRARY_PATH (and alternatives), however, looking deeper it seems like the admin has disabled LD_LIBRARY_PATH on this system (work terminal): http://stackoverflow.com/questions/9843178/linux-capabilities-setcap-seems-to-disable-ld-library-path On Tuesday, 25 February 2014 at 22:37:28 UTC, FreeSlave wrote: It's not dmd problem, it's up to ld linker and the issue is same for other compiled languages including C and C++. You should specify LD_LIBRARY_PATH variable in your system before executing any compiled D application. You can add export of this environment variable to your $HOME/.profile or $HOME/.bashrc depending on your system or edit paths in /etc/ld.so.conf.d or /etc/ld.so.conf. The other way is to copy libphobos to path where ld can find it by default, for example, /usr/local/lib. Hello, thr4wa, do you solve your problem, described above? I have same error: /usr/bin/ld: cannot find -l:libphobos2.a What I tried to do: 1) export LD_LIBRARY_PATH=/usr/lib64 2) copy libphobos2.a and libphobos2.so to /usr/lib64 3) soft link to this libraries from /usr/lib 4) added dmd -L-L/usr/lib64 compile flags in the dmd.conf file 5) added /usr/lib64 to the /etc/ld.so.conf Finally, I solved it by the following way: 1) disable linking phobos: -defaultlib= 2) link it manually: -L-lphobos2 (because default link flag -l:libphobos2.a is not worked for me)
Re: How do I write __simd(void16*, void16) ?
On Fri, 10 Oct 2014 08:31:44 -0400 Etienne via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Which type would have to be sent to the corresponding functions? I have a hard time figuring out how to use the __m128i with the proper mangling. Does it use core.simd's Vector!x types there? i know nothing about SIMD, but this compiles: import core.simd; import gcc.builtins; void main () { float4 a, b; auto tmp = __builtin_ia32_mulps(a, b); // a*b } i don't know what the hell this means, but at least it accepts types from core.simd. ;-) so i assume that other such builtins will accept other types too. signature.asc Description: PGP signature
Re: How do I write __simd(void16*, void16) ?
On 2014-10-10 9:01 AM, ketmar via Digitalmars-d-learn wrote: import core.simd; import gcc.builtins; void main () { float4 a, b; auto tmp = __builtin_ia32_mulps(a, b); // a*b } i don't know what the hell this means, but at least it accepts types from core.simd. ;-) so i assume that other such builtins will accept other types too. Nice! Nobody knows simd but they all know how to make it work. Go figure =)
Re: What is a sink delegate?
On 10/10/14 1:00 AM, Ali Çehreli wrote: On 10/09/2014 08:06 PM, Joel wrote: On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return foo; } for example, you would use: void toString(void delegate(string) sink) { sink(foo); } The sink argument there is then free to view and discard the data or to make a private copy using whatever scheme it desires. How do you use that toString? Maybe an example? Below is my failed effort. import std.stdio; struct Try { string name; long age; void toString(void delegate(string) sink) { sink(foo); } } void main() { Try t = Try(Joel, 35); writeln(t); } The signature of that toString is different from what I have been seeing and using. The following works: void toString(void delegate(const(char)[]) sink) const { The delegate parameter is what is important. The function that is going to be passed in takes a const(char)[], which actually should, but does not, implicitly cast to a delegate(string) (see issue https://issues.dlang.org/show_bug.cgi?id=3075). The const outside is irrelevant to whether it will accept it or not, that is a contract between the toString function and your object. If you want a non-const toString, I think that should work. (actually, testing it...) Yep, it works without the const on the outside. -Steve
Re: How do I write __simd(void16*, void16) ?
On Fri, 10 Oct 2014 09:09:09 -0400 Etienne via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 2014-10-10 9:01 AM, ketmar via Digitalmars-d-learn wrote: import core.simd; import gcc.builtins; void main () { float4 a, b; auto tmp = __builtin_ia32_mulps(a, b); // a*b } i don't know what the hell this means, but at least it accepts types from core.simd. ;-) so i assume that other such builtins will accept other types too. Nice! Nobody knows simd but they all know how to make it work. Go figure =) btw, i'm ready to do tests with 32-bit gdc if necessary. you can mail/jabber me (the address is the same ;-) if you need. signature.asc Description: PGP signature
Re: std.container.Array deep-copy?
On Friday, 10 October 2014 at 10:59:59 UTC, Sag Academy wrote: On Friday, 10 October 2014 at 10:32:17 UTC, yazd wrote: Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0 yeah man. You are right. Sorry. I probably messed up my test file somehow.
Re: What is a sink delegate?
On 10/10/2014 06:30 AM, Steven Schveighoffer wrote: On 10/10/14 1:00 AM, Ali Çehreli wrote: On 10/09/2014 08:06 PM, Joel wrote: On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return foo; } for example, you would use: void toString(void delegate(string) sink) { sink(foo); } The sink argument there is then free to view and discard the data or to make a private copy using whatever scheme it desires. How do you use that toString? Maybe an example? Below is my failed effort. import std.stdio; struct Try { string name; long age; void toString(void delegate(string) sink) { sink(foo); } } void main() { Try t = Try(Joel, 35); writeln(t); } The signature of that toString is different from what I have been seeing and using. The following works: void toString(void delegate(const(char)[]) sink) const { The delegate parameter is what is important. The function that is going to be passed in takes a const(char)[], That is what I meant. which actually should, but does not, implicitly cast to a delegate(string) (see issue https://issues.dlang.org/show_bug.cgi?id=3075). The const outside is irrelevant to whether it will accept it or not, that is a contract between the toString function and your object. If you want a non-const toString, I think that should work. (actually, testing it...) Yep, it works without the const on the outside. But not for const objects. The following program does not call the user defined toString: import std.stdio; import std.conv; struct S { int i; void toString(void delegate(const(char)[]) sink) { sink(i.to!string); } } void main() { const c = S(42); writeln(c); } Add a const at the end, now it calls the user defined one. -Steve Ali
Re: COFF on Win32 how to try?
On 10.10.2014 10:37, Szymon Gatner wrote: I would like to try recently merged COFF support on Win32 for a hybrid D/C++ application. Until now I tried that (hybridizing) only with DMD from the official installer and in x64 mode. My question is: how to try the same in 32 bits? You need a recent version of dmd, druntime and phobos from github: https://github.com/D-Programming-Language If you have never built these yourself, Digger might be of great help: https://github.com/CyberShadow/Digger/releases. It will also fetch these from github and download tools needed for building. Digger doesn't know about COFF32 yet, though. Then build druntime inside its directory: make -f win64.mak MODEL=32mscoff CC=\%VCINSTALLDIR%\bin\cl.exe\ target unittest and phobos: make -f win64.mak MODEL=32mscoff CC=\%VCINSTALLDIR%\bin\cl.exe\ AR=\%VCINSTALLDIR%\bin\lib.exe\ Add a configuration section [Environment32mscoff] to your sc.ini and add options matching these: https://github.com/D-Programming-Language/dmd/blob/master/ini/windows/bin/sc.ini#L84 Building is done with option -m32mscoff instead of -m32/-m64.
Re: Forward Reference
On Thursday, 9 October 2014 at 19:26:20 UTC, Njkp wrote: On Thursday, 9 October 2014 at 19:04:56 UTC, Anibal wrote: Hi everyone, I'm trying to something like a tree structure. The following: import std.container; class Tree { private SList!Tree subTree; } Produces: class Tree no size yet for forward reference. How i should proceed in order to keep this declaration? Thanks a lot! PD: (You guys are incredibly quick to answer, that's awesome!) make a pointer list instead, which has a fixed size: --- import std.container; class Tree { private SList!(Tree*) subTree; } --- fixed size: the item as pointer. But, BTW if you put a class as an item collection it's always a fixed size, a class is always a ptr. Better, you 'll be able to use the pointer without dereference. But you prefear the solution of the other guy...It's ok. I just hope that your subtree will not have to be reorganized too often...because with an array, it'll be very very very slow...
Re: What is a sink delegate?
On 10/10/14 11:20 AM, Ali Çehreli wrote: On 10/10/2014 06:30 AM, Steven Schveighoffer wrote: The const outside is irrelevant to whether it will accept it or not, that is a contract between the toString function and your object. If you want a non-const toString, I think that should work. (actually, testing it...) Yep, it works without the const on the outside. But not for const objects. I think that's what I said :) It's a contract between the toString function and your object, it has nothing to do with writeln accepting the function. There are some quirky requirements for certain magic functions in phobos that have to be exactly a certain signature for the compiler to use it. Now, obviously, the toy example can be labeled const. But not one that might, say, cache some state in order to compute the output. The following program does not call the user defined toString: import std.stdio; import std.conv; struct S { int i; void toString(void delegate(const(char)[]) sink) { sink(i.to!string); Don't do this. Do this instead: import std.format; sink.formattedWrite(i); The former allocates memory on the heap, just to throw it away. You are completely losing the benefit of the sink. -Steve
Re: COFF on Win32 how to try?
On Friday, 10 October 2014 at 16:14:56 UTC, Rainer Schuetze wrote: On 10.10.2014 10:37, Szymon Gatner wrote: I would like to try recently merged COFF support on Win32 for a hybrid D/C++ application. Until now I tried that (hybridizing) only with DMD from the official installer and in x64 mode. My question is: how to try the same in 32 bits? You need a recent version of dmd, druntime and phobos from github: https://github.com/D-Programming-Language If you have never built these yourself, Digger might be of great help: https://github.com/CyberShadow/Digger/releases. It will also fetch these from github and download tools needed for building. Digger doesn't know about COFF32 yet, though. Then build druntime inside its directory: make -f win64.mak MODEL=32mscoff CC=\%VCINSTALLDIR%\bin\cl.exe\ target unittest and phobos: make -f win64.mak MODEL=32mscoff CC=\%VCINSTALLDIR%\bin\cl.exe\ AR=\%VCINSTALLDIR%\bin\lib.exe\ Add a configuration section [Environment32mscoff] to your sc.ini and add options matching these: https://github.com/D-Programming-Language/dmd/blob/master/ini/windows/bin/sc.ini#L84 Building is done with option -m32mscoff instead of -m32/-m64. Hi, thanks for all the information. I got Digger (pretty nice tool btw) and it pulled all neccessary repos from GitHub. As my understanding is that I should not be doing Build with Diggger I just opened Windows console, entered druntime dir and typed: d:\digger-1.0\repo\druntimemake -f win64.mak MODEL=32mscoff CC=\%VCINSTALLDIR %\bin\cl.exe\ and got: dmd -c -o- -Isrc -Iimport -Hfimport\core\sync\barrier.di src\core\sync\barrier.d src\core\stdc\stdio.d(859): Error: found 'nothrow' when expecting '{' src\core\stdc\stdio.d(861): Error: mismatched number of curly brackets src\core\stdc\stdio.d(862): Error: mismatched number of curly brackets src\core\stdc\stdio.d(863): Error: mismatched number of curly brackets src\core\stdc\stdio.d(864): Error: mismatched number of curly brackets src\core\stdc\stdio.d(865): Error: mismatched number of curly brackets src\core\stdc\stdio.d(866): Error: mismatched number of curly brackets src\core\stdc\stdio.d(867): Error: mismatched number of curly brackets src\core\stdc\stdio.d(871): Error: asm statements must end in ';' src\core\stdc\stdio.d(874): Error: found 'private' instead of statement src\core\stdc\stdio.d(884): Error: no identifier for declarator add src\core\stdc\stdio.d(887): Error: no identifier for declarator usDone src\core\stdc\stdio.d(887): Error: Declaration expected, not ':' src\core\stdc\stdio.d(894): Error: Declaration expected, not '(' src\core\stdc\stdio.d(896): Error: Declaration expected, not 'foreach' src\core\stdc\stdio.d(896): Error: Declaration expected, not '0' src\core\stdc\stdio.d(901): Error: no identifier for declarator __fhnd_info[fd] src\core\stdc\stdio.d(901): Error: Declaration expected, not '=' src\core\stdc\stdio.d(902): Error: Declaration expected, not 'return' src\core\stdc\stdio.d(904): Error: unrecognized declaration --- errorlevel 1
Re: What is a sink delegate?
On Friday, 10 October 2014 at 11:35:21 UTC, Hjkp wrote: On Friday, 10 October 2014 at 04:42:04 UTC, thedeemon wrote: On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try(Joel, 35); t.toString(s = writeln(s)); } I think that the problem pointed by the OP is that toString is usually used automatically for struct in std.conv when it's implemented. I'm myself quite dubitatif in front of this syntax, even if IIRC during one talk of the DConf 2014 someone claim that's it's faster. I think it was in http://dconf.org/2014/talks/strasuns.html
Re: What is a sink delegate?
Thanks thedeemon. On Friday, 10 October 2014 at 04:42:04 UTC, thedeemon wrote: On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try(Joel, 35); t.toString(s = writeln(s)); }