Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 03:07:12 + MachineCode via Digitalmars-d-learn wrote: > You're welcome :) what do you call git head is the dmd compiler > compiled from dmd's source code on github? yes. i'm updating my compiler on dayly basis, so my "git head" is really "head". ;-) but i also have alot

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread MachineCode via Digitalmars-d-learn
On Monday, 27 October 2014 at 02:27:32 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 27 Oct 2014 02:19:49 + MachineCode via Digitalmars-d-learn wrote: It worked fine for me. Output: > abc > abc Environment: Win 8.1 64-bit (but dmd target is 32-bit, IIRC), dmd v2.066.0 yes, thank

Re: forum.dlang.org open source?

2014-10-26 Thread Mike via Digitalmars-d-learn
On Monday, 27 October 2014 at 02:24:04 UTC, MachineCode wrote: On Sunday, 26 October 2014 at 23:57:41 UTC, Mike wrote: Are you going to use HTML in the posts? because neither Walter and probably forum maintainer wants to use it. I don't plan on adding HTML to the posts. And you don't need to

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 02:25:50 +0200 ketmar via Digitalmars-d-learn wrote: for those who interested here is the patch that broke everything: https://github.com/D-Programming-Language/dmd/pull/3806/ i simply forgot that i included it for testing purposes, and it breaks something inside Phobos. si

Re: Where is a variable declared in a module allocated?

2014-10-26 Thread MachineCode via Digitalmars-d-learn
On Saturday, 25 October 2014 at 22:16:12 UTC, John Colvin wrote: On Saturday, 25 October 2014 at 21:52:13 UTC, MachineCode wrote: Where is a variable declared in a module allocated? is it same as a C's global? for example: module foo; int myvar; that is in thread local storage. __shared, s

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 02:19:49 + MachineCode via Digitalmars-d-learn wrote: > It worked fine for me. Output: > > > abc > > abc > > Environment: Win 8.1 64-bit (but dmd target is 32-bit, IIRC), dmd > v2.066.0 yes, thank you too. that was one of my custom patches that broke this. i already fou

Re: forum.dlang.org open source?

2014-10-26 Thread MachineCode via Digitalmars-d-learn
On Sunday, 26 October 2014 at 23:57:41 UTC, Mike wrote: Does forum.dlang.org have an open source repository somewhere that we can contribute pull requests to, or are bug reports to recommended procedure. I see that the left navigation menu needs updating, and I think we can wordsmith the foru

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread MachineCode via Digitalmars-d-learn
On Monday, 27 October 2014 at 00:26:00 UTC, ketmar via Digitalmars-d-learn wrote: Hello. let's assume we have this code: void doWrite(A...) (A args) { import std.stdio; import std.conv; writeln(to!string(args[0])); } void main () { char[3] a0 = "abc"; char[3] a1 = ['a

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Oct 2014 17:41:28 -0700 Ali Çehreli via Digitalmars-d-learn wrote: > Yeah, works with git head. ah, thank you. seems that one of the custom patches i'm using broke that. i just checked this on unpatched DMD, and it works too. sorry for the noise. signature.asc Description: PGP signa

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread Ali Çehreli via Digitalmars-d-learn
On 10/26/2014 05:33 PM, anonymous wrote: On Monday, 27 October 2014 at 00:26:00 UTC, ketmar via Digitalmars-d-learn wrote: Hello. let's assume we have this code: void doWrite(A...) (A args) { import std.stdio; import std.conv; writeln(to!string(args[0])); } void main () {

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 00:33:13 + anonymous via Digitalmars-d-learn wrote: > On Monday, 27 October 2014 at 00:26:00 UTC, ketmar via > Digitalmars-d-learn wrote: > > Hello. > > > > let's assume we have this code: > > > > void doWrite(A...) (A args) { > > import std.stdio; > > import std

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread anonymous via Digitalmars-d-learn
On Monday, 27 October 2014 at 00:26:00 UTC, ketmar via Digitalmars-d-learn wrote: Hello. let's assume we have this code: void doWrite(A...) (A args) { import std.stdio; import std.conv; writeln(to!string(args[0])); } void main () { char[3] a0 = "abc"; char[3] a1 = ['a

Re: passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 02:25:50 +0200 ketmar via Digitalmars-d-learn wrote: p.s. i know how to block using non-dynamic arrays in this case, but i don't want to. i found this when writing writef-like function with CTFE parsing of formatting string and spent alot of time looking for bug in my code. ;-

passing non-dynamic arrays to variadic functions

2014-10-26 Thread ketmar via Digitalmars-d-learn
Hello. let's assume we have this code: void doWrite(A...) (A args) { import std.stdio; import std.conv; writeln(to!string(args[0])); } void main () { char[3] a0 = "abc"; char[3] a1 = ['a', 'b', 'c']; doWrite(a0); doWrite(a1); } i don't know why, but this code

Re: Problems with Mutex

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 02:07:09 +0200 ketmar via Digitalmars-d-learn wrote: > > Thank you for clearing this up. If I understand correctly, > > __gshared is more of a hack to get C-like global variables, > > whilst shared is typed shared variable and more preferred? > yes and no. 'shared' is the pa

Re: forum.dlang.org open source?

2014-10-26 Thread anonymous via Digitalmars-d-learn
On Sunday, 26 October 2014 at 23:57:41 UTC, Mike wrote: Does forum.dlang.org have an open source repository somewhere that we can contribute pull requests to, or are bug reports to recommended procedure. http://forum.dlang.org/help#contributing

Re: Problems with Mutex

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Oct 2014 23:37:25 + Neven via Digitalmars-d-learn wrote: > >Mutex mutex; > >static this() > >{ > > mutex = new Mutex(); > >} > > I have synchronization problems with this one. Even when I > prepend __gshared Mutex mutex in this case. ah, there is another subtle thing. 'static th

forum.dlang.org open source?

2014-10-26 Thread Mike via Digitalmars-d-learn
Does forum.dlang.org have an open source repository somewhere that we can contribute pull requests to, or are bug reports to recommended procedure. I see that the left navigation menu needs updating, and I think we can wordsmith the forum descriptions a little to make it clearer where to post

Re: Problems with Mutex

2014-10-26 Thread Neven via Digitalmars-d-learn
@Damian You can use auto mutex = cast(shared)(new Mutex()); Not working; Error: constructor core.sync.mutex.Mutex.this core.sync.mutex.Mutex cannot be constructed at compile time, because the constructor has no available source code Mutex mutex; static this() { mutex = new Mutex(); } I

Re: Problems with Mutex

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Oct 2014 22:53:07 + Neven via Digitalmars-d-learn wrote: > Why cannot I globally have auto mutex = new Mutex? And why it > works now when I put __gshared? this is because 'auto mutex = new Mutex' is not a global declaration, it's thread-local declaration. all D variables are threa

Re: Problems with Mutex

2014-10-26 Thread Damian via Digitalmars-d-learn
On Sunday, 26 October 2014 at 22:53:09 UTC, Neven wrote: On Sunday, 26 October 2014 at 22:21:17 UTC, Damian wrote: On Sunday, 26 October 2014 at 22:14:25 UTC, Neven wrote: I'm trying to use Mutex from core.sync.mutex; but when I try to initialize it at compile time this error pops up: Error:

Re: Problems with Mutex

2014-10-26 Thread Damian via Digitalmars-d-learn
On Sunday, 26 October 2014 at 22:53:09 UTC, Neven wrote: On Sunday, 26 October 2014 at 22:21:17 UTC, Damian wrote: On Sunday, 26 October 2014 at 22:14:25 UTC, Neven wrote: I'm trying to use Mutex from core.sync.mutex; but when I try to initialize it at compile time this error pops up: Error:

Re: Problems with Mutex

2014-10-26 Thread Neven via Digitalmars-d-learn
On Sunday, 26 October 2014 at 22:21:17 UTC, Damian wrote: On Sunday, 26 October 2014 at 22:14:25 UTC, Neven wrote: I'm trying to use Mutex from core.sync.mutex; but when I try to initialize it at compile time this error pops up: Error: constructor core.sync.mutex.Mutex.this core.sync.mutex.Mu

Re: Problems with Mutex

2014-10-26 Thread Damian via Digitalmars-d-learn
On Sunday, 26 October 2014 at 22:14:25 UTC, Neven wrote: I'm trying to use Mutex from core.sync.mutex; but when I try to initialize it at compile time this error pops up: Error: constructor core.sync.mutex.Mutex.this core.sync.mutex.Mutex cannot be constructed at compile time, because the con

Problems with Mutex

2014-10-26 Thread Neven via Digitalmars-d-learn
I'm trying to use Mutex from core.sync.mutex; but when I try to initialize it at compile time this error pops up: Error: constructor core.sync.mutex.Mutex.this core.sync.mutex.Mutex cannot be constructed at compile time, because the constructor has no available source code So I try to initia

Re: Reflections on isPalindrome

2014-10-26 Thread Nordlöw
On Friday, 24 October 2014 at 22:29:12 UTC, Peter Alexander wrote: Further, I would like to extend isPalindrome() with a minimum length argument minLength that for string and wstring does I extended my algorithm with a minLength argument https://github.com/nordlow/justd/blob/master/algorithm_e

Re: specializing template with string variable in CTFE

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Oct 2014 20:16:18 + via Digitalmars-d-learn wrote: > The documentation specifically says that: > "Any functions that execute at compile time must also be > executable at run time. [...] This means that the semantics of a > function cannot depend on compile time values of the func

Re: specializing template with string variable in CTFE

2014-10-26 Thread via Digitalmars-d-learn
On Sunday, 26 October 2014 at 19:32:28 UTC, ketmar via Digitalmars-d-learn wrote: On Sun, 26 Oct 2014 12:46:06 + via Digitalmars-d-learn wrote: The second possibility doesn't exist right now. The core problem is that the compiler needs to be able to generate runtime code for `buildWrite

Re: specializing template with string variable in CTFE

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Oct 2014 12:46:06 + via Digitalmars-d-learn wrote: > Ok, I see two possibilities. The first is to make `prstr` into a > normal function. You cannot use `stringof` then, but need to > escape the string yourself. Luckily, std.format provides > functionality for this already, albei

Re: specializing template with string variable in CTFE

2014-10-26 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Oct 2014 12:46:06 + via Digitalmars-d-learn wrote: > The second possibility doesn't exist right now. The core problem > is that the compiler needs to be able to generate runtime code > for `buildWriter()`, because it's just a function after all. but it's templated function, and i

Re: Pragma mangle and D shared objects

2014-10-26 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-10-25 23:31, H. S. Teoh via Digitalmars-d-learn wrote: Hmm. You can probably use __traits(getAllMembers...) to introspect a library module at compile-time and build a hash based on that, so that it's completely automated. If you have this available as a mixin, you could just mixin(exportL

Re: specializing template with string variable in CTFE

2014-10-26 Thread via Digitalmars-d-learn
On Sunday, 26 October 2014 at 10:48:46 UTC, ketmar via Digitalmars-d-learn wrote: Hello. the following code is not working: template prstr(string s) { enum prstr = "write("~s.stringof~");\n"; } string buildWriter() (string fmt) { return prstr!(fmt[0..$-1]); } string writer(s

Re: specializing template with string variable in CTFE

2014-10-26 Thread via Digitalmars-d-learn
On Sunday, 26 October 2014 at 12:27:55 UTC, Marc Schütz wrote: On Sunday, 26 October 2014 at 10:48:46 UTC, ketmar via Digitalmars-d-learn wrote: Hello. the following code is not working: template prstr(string s) { enum prstr = "write("~s.stringof~");\n"; } string buildWriter() (string f

Re: specializing template with string variable in CTFE

2014-10-26 Thread via Digitalmars-d-learn
On Sunday, 26 October 2014 at 10:48:46 UTC, ketmar via Digitalmars-d-learn wrote: Hello. the following code is not working: template prstr(string s) { enum prstr = "write("~s.stringof~");\n"; } string buildWriter() (string fmt) { return prstr!(fmt[0..$-1]); } Your passing the

specializing template with string variable in CTFE

2014-10-26 Thread ketmar via Digitalmars-d-learn
Hello. the following code is not working: template prstr(string s) { enum prstr = "write("~s.stringof~");\n"; } string buildWriter() (string fmt) { return prstr!(fmt[0..$-1]); } string writer(string fmt) () { enum s = buildWriter(fmt); return s; } void main () {

Re: HTML Parsing lib

2014-10-26 Thread yazd via Digitalmars-d-learn
On Saturday, 25 October 2014 at 19:44:25 UTC, Suliman wrote: I found only https://github.com/Bystroushaak/DHTMLParser But I can't get it work: C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-master>dmd find_links.d OPTLINK (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars 1989-2

Re: Generating code based on UDA

2014-10-26 Thread Rares Pop via Digitalmars-d-learn
I have found the problem. It was the nested mixin that was causing the scope degradation (not sure if that is intended behaviour). The correct way to iterate through members and get their attribute is like this: foreach(member; __traits(allMembers,T)) {