Re: Current limitations of -dip1000
On 10/10/2017 3:31 PM, Nordlöw wrote: I did it: https://issues.dlang.org/show_bug.cgi?id=17892 Thank you!
[Issue 17892] Scope analysis with -dip1000 fails for templated structs
https://issues.dlang.org/show_bug.cgi?id=17892 Walter Brightchanged: What|Removed |Added Keywords||safe CC||bugzi...@digitalmars.com Hardware|x86_64 |All OS|Linux |All --
Re: Why do I have to cast arguments from int to byte?
On Tue, 10 Oct 2017 19:55:36 +, Chirs Forest wrote: > It wouldn't be so bad if I didn't have to use the word cast before each > cast, bust since I have to specify both the word cast and the cast type > and then wrap both the cast type and the value in brackets... it just > explodes my code into multiple lines of unreadable mess. > > > void foo(T)(T bar, T bar2, T bar3){...} > > byte foobar = 12; > > foo!byte(foobar + 1, foobar + 22, foobar + 333); > vs. > foo!byte(cast(byte)(foobar + 1), cast(byte)(foobar + 22), > cast(byte)(foobar + 333)); You could wrap the cast in a function to clean it up a bit: void main() { byte foobar = 12; foo!byte((foobar + 1).b, (foobar + 22).b, (foobar + 333).b); } byte b(int n) pure { pragma(inline, true); // Probably not necessary. return cast(byte)n; } void foo(T)(T bar, T bar2, T bar3) { import std.stdio : writeln; import std.string : format; writeln("%s, %s, %s".format(bar, bar2, bar3)); } --Ryan
[Issue 10060] readf doesn't work with arrays
https://issues.dlang.org/show_bug.cgi?id=10060 alex.jercai...@gmail.com changed: What|Removed |Added CC||alex.jercai...@gmail.com Assignee|nob...@puremagic.com|alex.jercai...@gmail.com --
Re: Current limitations of -dip1000
On Tuesday, 10 October 2017 at 18:58:42 UTC, Nordlöw wrote: On Tuesday, 10 October 2017 at 14:12:04 UTC, 12345swordy wrote: Report any bugs to the official bug tracker here: https://issues.dlang.org/ Shall I file the bug? I did it: https://issues.dlang.org/show_bug.cgi?id=17892
[Issue 17892] New: Scope analysis with -dip1000 fails for templated structs
https://issues.dlang.org/show_bug.cgi?id=17892 Issue ID: 17892 Summary: Scope analysis with -dip1000 fails for templated structs Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: per.nord...@gmail.com When struct S { @safe: int[ 128] x; scope ref int front() return { return x[ 0]; } scope int* pointer() return { return [ 0]; } } ref int testFront() { S s; return s.front(); // error } int* testPointer() { S s; return s.pointer(); // error } is turned into a template @safe: struct ST( T) { @safe: T[ 128] x; scope ref T front() return { return x[ 0]; } scope T* pointer() return { return [ 0]; } } scope analysis (with -dip1000) no longer forbids escaping of reference and pointer as in ref int testFrontT() { ST!int s; return s.front(); // reference to stack element escapes } int* testPointerT() { ST!int s; return s.pointer(); // pointer to stack element escapes } --
Re: Multiline string literal improvements
On Tuesday, 10 October 2017 at 21:38:41 UTC, captaindet wrote: string a = |q{ firstLine(); if (cond) { secondLine() } }; you could write your own string processing function according to your needs FWIW, that's the solution in Python: https://docs.python.org/release/3.6.3/library/textwrap.html#textwrap.dedent Works even better in D because it can run at compile time.
Re: the best language I have ever met(?)
On Friday, 25 November 2016 at 19:16:43 UTC, ketmar wrote: yeah. but i'm not Andrei, i don't believe that the only compiler task is to resolve templated code. ;-) i.e. Andrei believes that everything (and more) should be moved out of compiler core and done with library templates. Andrei is genius, for sure, but he is living somewhere in future, where our PCs are not bound by memory, CPU, and other silly restrictions. ;-) tl;dr: using template for this sux. Nice to meet you, Andrei! Yes, in mathematics we are more servants than gentlemen (Charles Hermite).
Re: initializing a static array
On Tuesday, 10 October 2017 at 22:00:27 UTC, kinke wrote: [...] Ah sorry, overlooked that it's the initializer for a struct field.
Re: initializing a static array
On Tuesday, 10 October 2017 at 14:15:07 UTC, Simon Bürger wrote: On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: Maybe: double[n] bar = 0.repeat(n).array; This works fine, thanks a lot. I would have expected `.array` to return a dynamic array. But apparently the compiler is smart enough to know the length. Even the multi-dimensional case works fine: double[n][n] bar = 0.repeat(n).array.repeat(n).array; I hope this is not performance-critical code. The assembly is terrible for such code, at least for LDC, doing a GC allocation, unrolled reset to zero, then memcpying the dynamic array back to the stack: https://godbolt.org/g/uXBN75 `double[n] bar = void; bar[] = 0;` (2 lines, granted) results in a memset.
Re: Multiline string literal improvements
string a = |q{ firstLine(); if (cond) { secondLine() } }; you could write your own string processing function according to your needs to filter the code string, and use it like string a = inject(q{...}) //or string a = inject!(formatOpts)(q{...}) i have done this myself and also included positional argument formatting to my liking, optimized for CT code generation. don't have the code at my hands ATM though. could post it later if you are interested. /det
[Issue 17891] forum is dog slow
https://issues.dlang.org/show_bug.cgi?id=17891 ki...@gmx.net changed: What|Removed |Added CC||ki...@gmx.net --- Comment #2 from ki...@gmx.net --- Right now it's particularly bad, but the overall experience has been pretty bad for weeks now. Not just the web forum, but the Wiki as well. CI is also dying because dlang.org can't serve downloads at times. As I stated in http://forum.dlang.org/thread/vndgejrhmqynthwbf...@forum.dlang.org, most requests are served in an instant, but there seem to be times where the server takes 10-60 secs to respond, to the point where it's barely usable. If I have multiple pending requests during such a period (a couple of browser tabs), all of them are served at the same time once the server seems to recover. I'd much rather have a constant delay of a few seconds instead of not-that-infrequent-spikes, those are much more annoying. Of the few websites I use regularly, dlang.org leaves the worst impression performance-wise, by far. --
Re: Why do I have to cast arguments from int to byte?
On Tuesday, 10 October 2017 at 19:55:36 UTC, Chirs Forest wrote: Why? D inherited a silly rule from C where any arithmetic is promoted to int first. The big difference is D doesn't do implicit narrowing conversion... so x + 1 becomes int, but then int to byte requires an explicit cast (unless the compiler can prove the range in that particular expression - this is called "value range propagation"). I think it has proved to be a bit of a mistake :(
Re: "This week in D" state
On Tuesday, 10 October 2017 at 15:52:03 UTC, Adam D. Ruppe wrote: Of course, if someone wants to email me something I can copy/paste in, that's cool... but you could also send that to the blog... I'd like to but i would be nice to know where to write to without required piles.
Multiline string literal improvements
D has a very nice feature of token strings: string a = q{ looksLikeCode(); }; It is useful in writing mixins and to have syntax highlighting in editors. Although I like it, it is not something I ever felt like missing in other languages. What I do always miss are these two options: 1. Have something like this: string a = |q{ firstLine(); if (cond) { secondLine() } }; mean count the number of whitespace characters at the start of a first new line of string literal and then strip up to that many whitespace characters from the start of each line. 2. If we just put for example "-" instead of "|" in above example have that mean: replace all whitespace with a single space in following string literal. I think it is clear why would these be useful but if you want me I can add a few examples. This would not make any breaking changes to the language and it should be possible to simply implement it wholly in the lexer. So what do think?
Re: how to shorten templates structs name?
On 10/10/2017 04:30 AM, drug wrote: > using classes I can make an inherited class of templated class and avoid > too long mangled name: > ``` > class TemplatedClass(A, Very, Much, Args, Here) { ... } > > class ShortenClass : TemplatedClass!(A,Very, Much, Args, Here) { ... }; > ``` > Now ShortenClass has a nice mangling. > > What can be done in case of struct? I think an alias is more suitable here for both classes and structs: alias ShortenClass = TemplatedClass!(int,bool, float, ubyte, string); Ali
Re: Why do I have to cast arguments from int to byte?
On Tuesday, 10 October 2017 at 19:55:36 UTC, Chirs Forest wrote: I keep having to make casts like the following and it's really rubbing me the wrong way: void foo(T)(T bar){...} byte bar = 9; [...] Why? Because of integer promotion [1], which is inherited from C. [1] https://dlang.org/spec/type.html#integer-promotions
Re: Why do I have to cast arguments from int to byte?
On Tuesday, 10 October 2017 at 19:55:36 UTC, Chirs Forest wrote: I keep having to make casts like the following and it's really rubbing me the wrong way: void foo(T)(T bar){...} byte bar = 9; foo!byte(bar + 1); //Error: function foo!byte.foo (byte bar) is not callable using argument types (int) foo!byte(cast(byte)(bar + 1)); It wouldn't be so bad if I didn't have to use the word cast before each cast, bust since I have to specify both the word cast and the cast type and then wrap both the cast type and the value in brackets... it just explodes my code into multiple lines of unreadable mess. void foo(T)(T bar, T bar2, T bar3){...} byte foobar = 12; foo!byte(foobar + 1, foobar + 22, foobar + 333); vs. foo!byte(cast(byte)(foobar + 1), cast(byte)(foobar + 22), cast(byte)(foobar + 333)); Why? Because int (1) + ubyte (9) = int
Re: is private broken?
On Tuesday, 10 October 2017 at 20:02:32 UTC, Jonathan M Davis wrote: On Tuesday, October 10, 2017 15:33:30 Steven Schveighoffer via Digitalmars-d wrote: On 10/10/17 3:20 PM, Jonathan Marler wrote: > On windows I was able to compile the following using both > dmd.2.075.1 and dmd.2.076.1 > > From what I understand, you shouldn't be able to access > private > > fields/methods like this...am I missing something? Before I even read your code, I was pretty sure the error :) LOL. Same here. It seems like almost everyone makes this mistake unless they caught the information first by doing something like reading the spec carefully or reading TDPL. And if you always treat your types as if nothing else can access their private members and don't need the equivalent of a C++ friend function, odds are, that you'll never notice... - Jonathan M Davis FWIW this confusion found it's way into Phobos as the unittest was in the same module: https://dlang.org/phobos/std_traits.html#getSymbolsByUDA See also: https://issues.dlang.org/show_bug.cgi?id=17643
Re: is private broken?
On Tuesday, 10 October 2017 at 19:59:05 UTC, Jonathan M Davis wrote: There is - by putting them in a separate module. It was done this way to avoid the extra complication of friend functions that you get in C++, and the theory is that you're in control of everything that's in your own module, [snip] I hadn't realized this was the reason for it. Makes sense.
[Issue 17891] forum is dog slow
https://issues.dlang.org/show_bug.cgi?id=17891 --- Comment #1 from Vladimir Panteleev--- There is some maintenance running on the server right now which is impacting load. Should be resolved soon. --
Re: is private broken?
On 10/10/17 4:02 PM, Jonathan M Davis wrote: On Tuesday, October 10, 2017 15:33:30 Steven Schveighoffer via Digitalmars-d wrote: On 10/10/17 3:20 PM, Jonathan Marler wrote: On windows I was able to compile the following using both dmd.2.075.1 and dmd.2.076.1 From what I understand, you shouldn't be able to access private fields/methods like this...am I missing something? Before I even read your code, I was pretty sure the error :) LOL. Same here. It seems like almost everyone makes this mistake unless they caught the information first by doing something like reading the spec carefully or reading TDPL. And if you always treat your types as if nothing else can access their private members and don't need the equivalent of a C++ friend function, odds are, that you'll never notice... Yeah, if you look back far enough in the forums, I'm pretty sure I posted a message similar to Mr. Marler's about this shocking revelation :) -Steve
Re: is private broken?
On Tuesday, October 10, 2017 15:33:30 Steven Schveighoffer via Digitalmars-d wrote: > On 10/10/17 3:20 PM, Jonathan Marler wrote: > > On windows I was able to compile the following using both dmd.2.075.1 > > and dmd.2.076.1 > > > > From what I understand, you shouldn't be able to access private > > > > fields/methods like this...am I missing something? > > Before I even read your code, I was pretty sure the error :) LOL. Same here. It seems like almost everyone makes this mistake unless they caught the information first by doing something like reading the spec carefully or reading TDPL. And if you always treat your types as if nothing else can access their private members and don't need the equivalent of a C++ friend function, odds are, that you'll never notice... - Jonathan M Davis
Why do I have to cast arguments from int to byte?
I keep having to make casts like the following and it's really rubbing me the wrong way: void foo(T)(T bar){...} byte bar = 9; foo!byte(bar + 1); //Error: function foo!byte.foo (byte bar) is not callable using argument types (int) foo!byte(cast(byte)(bar + 1)); It wouldn't be so bad if I didn't have to use the word cast before each cast, bust since I have to specify both the word cast and the cast type and then wrap both the cast type and the value in brackets... it just explodes my code into multiple lines of unreadable mess. void foo(T)(T bar, T bar2, T bar3){...} byte foobar = 12; foo!byte(foobar + 1, foobar + 22, foobar + 333); vs. foo!byte(cast(byte)(foobar + 1), cast(byte)(foobar + 22), cast(byte)(foobar + 333)); Why?
Re: is private broken?
On Tuesday, October 10, 2017 19:50:49 Jonathan Marler via Digitalmars-d wrote: > On Tuesday, 10 October 2017 at 19:33:30 UTC, Steven Schveighoffer > > wrote: > > On 10/10/17 3:20 PM, Jonathan Marler wrote: > >> On windows I was able to compile the following using both > >> dmd.2.075.1 and dmd.2.076.1 > >> > >> From what I understand, you shouldn't be able to access > >> > >> private fields/methods like this...am I missing something? > > > > Before I even read your code, I was pretty sure the error :) > > > > private is module-based, not type based. Put your structs in a > > different module, and private will work. > > > > -Steve > > Wow I can't believe I've gone this long not realizing that. I'm > surprised there's not a way to make fields private to their own > struct/class. There is - by putting them in a separate module. It was done this way to avoid the extra complication of friend functions that you get in C++, and the theory is that you're in control of everything that's in your own module, so you should be able to deal with not having stuff access stuff in the same module when it shouldn't. And if you want nothing outside the type to have access, just stick the type in its own module. - Jonathan M Davis
Re: is private broken?
On Tuesday, 10 October 2017 at 19:33:30 UTC, Steven Schveighoffer wrote: On 10/10/17 3:20 PM, Jonathan Marler wrote: On windows I was able to compile the following using both dmd.2.075.1 and dmd.2.076.1 From what I understand, you shouldn't be able to access private fields/methods like this...am I missing something? Before I even read your code, I was pretty sure the error :) private is module-based, not type based. Put your structs in a different module, and private will work. -Steve Wow I can't believe I've gone this long not realizing that. I'm surprised there's not a way to make fields private to their own struct/class.
[Issue 17891] New: forum is dog slow
https://issues.dlang.org/show_bug.cgi?id=17891 Issue ID: 17891 Summary: forum is dog slow Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: major Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: johnnymar...@gmail.com Lately the forms have been loading alot slower, over 10 seconds to load a single page, sometimes it seems to take longer. Today (October 10, 2017) pages are taking about a minute to load each time making the forums almost unusable. --
Re: is private broken?
Hah! Beat you by 10 seconds :) -Steve
Re: is private broken?
On 10/10/17 3:20 PM, Jonathan Marler wrote: On windows I was able to compile the following using both dmd.2.075.1 and dmd.2.076.1 From what I understand, you shouldn't be able to access private fields/methods like this...am I missing something? Before I even read your code, I was pretty sure the error :) private is module-based, not type based. Put your structs in a different module, and private will work. -Steve
Re: is private broken?
https://wiki.dlang.org/Access_specifiers_and_visibility#private Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. You can access private attributes anywhere in the same module.
is private broken?
On windows I was able to compile the following using both dmd.2.075.1 and dmd.2.076.1 From what I understand, you shouldn't be able to access private fields/methods like this...am I missing something? I find it hard to believe that a bug of this magnitudue could have been introduced and not been noticed for so long. Does this compile on other people's systems as well? import std.stdio; struct SomeStruct { private int privateValue; private void privateFunction() { } } class SomeClass { private int privateValue; private void privateFunction() { } } void main() { auto someStruct = SomeStruct(42); writefln("someStruct.privateValue = %s", someStruct.privateValue); someStruct.privateFunction(); auto someStructRef = new SomeStruct(42); writefln("someStructRef.privateValue = %s", someStructRef.privateValue); someStruct.privateFunction(); auto someClass = new SomeClass(); writefln("someClass.privateValue = %s", someClass.privateValue); someClass.privateFunction(); }
Array/range-version of emplace
Why isn't there an array/range version of `emplace`, when there is one for `moveEmplace`, namely https://dlang.org/library/std/algorithm/mutation/move_emplace_all.html ?
Re: Current limitations of -dip1000
On Tuesday, 10 October 2017 at 14:12:04 UTC, 12345swordy wrote: Report any bugs to the official bug tracker here: https://issues.dlang.org/ Shall I file the bug?
[Issue 17740] ghost "internal" symbols show up sometimes
https://issues.dlang.org/show_bug.cgi?id=17740 --- Comment #9 from Mr. Smith--- Error doesn't happen when `import std.datetime : MonoTime;` is removed --
[Issue 17740] ghost "internal" symbols show up sometimes
https://issues.dlang.org/show_bug.cgi?id=17740 --- Comment #8 from Steven Schveighoffer--- Correction: PR was not about MonoTime but SysTime. But still, datetime seems to be involved. --
[Issue 17740] ghost "internal" symbols show up sometimes
https://issues.dlang.org/show_bug.cgi?id=17740 --- Comment #7 from Steven Schveighoffer--- Hm... I didn't see this before, but you have an import for MonoTime. On the original PR I saw this, it was an update to MonoTime. Can you confirm that your code works or not without MonoTime import (which seems to be doing nothing in your latest version)? --
[Issue 17740] ghost "internal" symbols show up sometimes
https://issues.dlang.org/show_bug.cgi?id=17740 --- Comment #6 from Mr. Smith--- Looks like the problem is with Piece* sentinel = new Piece; If I do that at runtime it works. --
[Issue 17890] cpp_long is not declared for Posix 64bit
https://issues.dlang.org/show_bug.cgi?id=17890 --- Comment #1 from anonymous4--- (In reply to Илья Ярошенко from comment #0) > BTW, why c_long is always 32 bit for windows? I suppose for compatibility with code written for 32-bit architecture, though long was 32-bit in 16-bit mode too. --
Re: "This week in D" state
On Tuesday, 10 October 2017 at 16:36:14 UTC, jmh530 wrote: While I liked when you did the longer stuff, I think even the slimmed down version has value. It's also probably less work for you (or someone else if they take it over). Yeah, I'll post the last couple I generated but never saved. This previous sunday though I was busy and just totally forgot to even generate.
Re: "This week in D" state
On Tuesday, 10 October 2017 at 15:52:03 UTC, Adam D. Ruppe wrote: I generated the file for a couple weeks last month, but I'm not happy at all with the forum links but also don't have much else to put in. The blog really took over for the longer form stuff I used to write. I might go ahead and post the back stuff anyway but without at least some other content it seems like a waste of time. Of course, if someone wants to email me something I can copy/paste in, that's cool... but you could also send that to the blog... While I liked when you did the longer stuff, I think even the slimmed down version has value. It's also probably less work for you (or someone else if they take it over).
[Issue 17740] ghost "internal" symbols show up sometimes
https://issues.dlang.org/show_bug.cgi?id=17740 Mr. Smithchanged: What|Removed |Added CC||mrsmit...@yandex.ru --- Comment #5 from Mr. Smith --- Here is even smaller test case: // main.d import texteditor; void main() {} // texteditor.d module texteditor; class EditorTextModel { void fun() { editor.fun2(); } TextEditor editor; } struct TextEditor { Piece* sentinel = new Piece; void fun2() {} import std.datetime : MonoTime; } struct Piece {} // dmd -m64 -lib -of="lib.lib" -debug -g -w -I="./" texteditor.d // dmd -m64 -of="app.exe" -debug -g -w -I="./" lib.lib main.d --
Re: How do I filter out data from mongodb in D-code
On Tuesday, 10 October 2017 at 09:43:10 UTC, Anders S wrote: Hi, I'm working on a middleware application that reads array of data from a POSIX pipe and insert data into the db if any position in the array has changed. This is where my problem lays, in order not to duplicate data I want to fetch the latest data/document in the array of documents. I'm using MS Code and dub to code and compile. This is the code: Collection ct = mongo.boxweb.celltab; int i = 1; for(;i < 10; i++ ){ auto cell = ct.find({"number":i}).sort({_id:-1}).limit(2).pretty(); if (insert... i++; Where "number" is the document nr in the array I get these errors source/app.d(166,54): Error: found : when expecting ; following statement source/app.d(166,56): Error: found } when expecting ; following statement source/app.d(166,57): Error: found ) instead of statement dmd failed with exit code 1. Any ideas? Isn't there a way to markup code in the forum message to separate from the bodytext? /anders Hello, I haven't used mongo and D together, but by looking at [0] and [1] I can see that mondo is using Bson, which, as far as I can tell takes an associative array. I'm guessing you need to replace the JS dictionary sintax { k: v } with the AA one [ k: v ]. I haven't been able to try this out as I am on my phone. Also, this might be more suited for the Learn thread. Regarding the code markup, as far as I know, we don't have this. Hope this helps, Eduard [0] - https://code.dlang.org/packages/mondo [1] - http://vibed.org/api/vibe.data.bson/
Re: initializing a static array
On 10/10/2017 03:36 PM, Simon Bürger wrote: I have a static array inside a struct which I would like to be initialized to all-zero like so struct Foo(size_t n) { double[n] bar = ... all zeroes ... } (note that the default-initializer of double is nan, and not zero) I tried double[n] bar = 0; // does not compile Works for me: struct Foo(size_t n) { double[n] bar = 0; } void main() { import std.stdio; Foo!5 foo; writeln(foo.bar); /* prints "[0, 0, 0, 0, 0]" */ }
Re: "This week in D" state
On Tuesday, 10 October 2017 at 07:12:19 UTC, Eliatto wrote: I noticed that "This week in D" site was seldom updated. Last activity is September, the 3rd. If Adam is busy at the moment, then I think that he should have an assistant. I generated the file for a couple weeks last month, but I'm not happy at all with the forum links but also don't have much else to put in. The blog really took over for the longer form stuff I used to write. I might go ahead and post the back stuff anyway but without at least some other content it seems like a waste of time. Of course, if someone wants to email me something I can copy/paste in, that's cool... but you could also send that to the blog...
[Issue 16510] Request: RSA digital signature validation in phobos
https://issues.dlang.org/show_bug.cgi?id=16510 --- Comment #2 from Andre--- As far as I know there is no native library available (not depending on e.g. openssl dll) which works for dmd OMF. Unfortunately even botan only works with x86 / x64 coff. --
[Issue 9362] Add a method to remove one item to std.container.SList
https://issues.dlang.org/show_bug.cgi?id=9362 Alexandru Razvan Caciulescuchanged: What|Removed |Added CC||alexandru.razva...@gmail.co ||m Assignee|nob...@puremagic.com|alexandru.razva...@gmail.co ||m --
[Issue 17740] ghost "internal" symbols show up sometimes
https://issues.dlang.org/show_bug.cgi?id=17740 --- Comment #4 from Steven Schveighoffer--- A better reduced test case: https://gist.github.com/MrSmith33/dc53d8cb6ce642fcb6dbc5863d029cec Courtesy of MrSmith: https://forum.dlang.org/post/ahoyjzxreidgosqij...@forum.dlang.org --
Re: Linking error: unresolved external symbol internal
On 10/10/17 11:09 AM, MrSmith wrote: I have a static library and an application. When linking final executable I get: lib.lib(texteditor_1d_40c.obj) : error LNK2001: unresolved external symbol internal lib.lib(textbuffer_14_3ce.obj) : error LNK2001: unresolved external symbol internal Happens on Windows 32 and 64 bit. Only with debug build. DMD 2.076.0 Error doesn't happen when I move code from library to the application. Here is reduced test case (where 2 errors happen, 4 files): https://gist.github.com/MrSmith33/29125fa3538bb03637d0aebab6ccff7c Here is smaller case (only 1 error, 2 files): https://gist.github.com/MrSmith33/dc53d8cb6ce642fcb6dbc5863d029cec If this is relevant: 3 places I found in dmd where "internal" symbol is created: * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/backend/dt.c#L420 * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L662 * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L681 No idea exactly what causes it, but here is another place I've seen it: https://issues.dlang.org/show_bug.cgi?id=17740 -Steve
Re: initializing a static array
https://run.dlang.io/is/SC3Fks
Re: Deprecation message of library functions should state the replacement function
On Tuesday, 10 October 2017 at 13:56:36 UTC, Seb wrote: On Tuesday, 10 October 2017 at 12:57:36 UTC, bauss wrote: On Tuesday, 10 October 2017 at 11:48:48 UTC, Eduard Staniloiu wrote: Hi guys, I've just build druntime on Windows and we are displaying the following deprecation message: src\core\sys\windows\odbcinst.d(157): Deprecation: function core.sys.windows.odbcinst.SQLInstallTranslatorW is deprecated. I believe that we should also state with what should the deprecated function be replaced. My 2 cents, Eduard They usually do, I just assume it was forgotten there and if you know which function is to replace it, then simply create a pr? Or simply remove it as it has been deprecated since more than two years: https://github.com/dlang/druntime/blob/8fbcc2d819a84a5340cc6ac724320cae3561cb3b/src/core/sys/windows/odbcinst.d I'm not sure we should remove it since the replacement is available starting with ODBC 3.x [0]. I've made a PR [1] that states the replacement function in the deprecation message. [0] - https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlinstalltranslator-function [1] - https://github.com/dlang/druntime/pull/1936
Re: Default hashing function for AA's
On 10/9/17 10:11 AM, RazvanN wrote: Hi all, We in the UPB dlang group have been having discussions about the hashing functions of associative arrays. In particular, we were wondering why is the AA implementation in druntime is not using the hash function implemented in druntime/src/core/internal/hash.hashOf for classes that don't define toHash(). AA uses typeid(Key).getHash. [1] For objects, this calls the virtual function `toHash`. [2] Please keep in mind that all you are hashing is the class reference pointer, as that is the default comparison for `opEquals`. It might make sense to shuffle those bits a bit, since the bucket algorithm only looks at the lower bits of the hash, and this basically guarantees keys with the default hash will be empty in the first few buckets, since class objects are aligned on a power-of-2 boundary. But I'm not sure running a full blown hash on the pointer is necessary. Perhaps just xor-ing the upper bits with the lower bits makes more sense. Alternatively, you could change the default `opEquals` but that may break things more than expected. What you *can't* do is change what the hash is based on without changing `opEquals`. Note that I wouldn't recommend using an Object as a key without defining toHash and opEquals anyway. -Steve [1] https://github.com/dlang/druntime/blob/master/src/rt/aaA.d#L310 [2] https://github.com/dlang/druntime/blob/master/src/object.d#L66
Re: Proposal: Object/?? Destruction
On 10/9/17 11:22 AM, Timon Gehr wrote: On 09.10.2017 01:20, Steven Schveighoffer wrote: My questioning comes with this: void bar(int a); void bar((int,) x); To me, it is confusing or at least puzzling that these two aren't the same. ... Well, to me it is a bit confusing that this is puzzling to you. Why should int be the same as (int,)? It does not make sense to index an integer, but (int,) can be indexed with 0 to get an integer. I understand why (int,) is different from int. What I meant was, why can't I *call* a function that takes a single int tuple with a single int value? It shouldn't matter to the caller whether you plan to fiddle with your parameter via tuple syntax or directly with a value. Again, I go back to the 2-parameter version. I can call it with 2 values, or a tuple of 2 values. It makes no difference to the callee how I call it, as long as I put 2 values on the stack. I don't see why it should be different for a single parameter function. To put it another way, in your scheme, what is the benefit to overloading a single value function call with a function call that takes a single element tuple? When would this be useful? Currently, I can call this: foo(T...)(T t) if (T.length == 1) // function that takes a single element tuple like this: foo(1); Why is this disallowed in your tuple scheme? ... I take this to mean, why does the following code not compile: void foo(T)(T t) if(T.length == 1) { ... } foo(1); Nope, I meant my original. A "tuple" as D currently uses it, can have exactly one element, and I can call that function with exactly one value. I don't have to call it as: AliasSeq!(int) v; v[0] = 1; foo(v); Which is analogous to your requirements (obviously, D is missing the syntax for tuple literals, which is why it's complicated). Note that if foo is: foo(int x); I can still call it with v. I don't see why we can't keep these kinds of allowances. I would think single value tuples and single values would be pretty much interchangeable. Well, no. Otherwise 2[0] would be allowed and equal to 2. And then, what would [2][0] be? [2] or 2? Not interchangeable in terms of usage, but interchangeable in terms of overloading. What I would have expected is for foo(int) and foo((int,)) to be equivalent mangling (like the bar(int, int) and bar((int, int)) are equivalent), and for the caller to be able to call those functions with either a single value or a singleton tuple. Inside the function, of course, they are treated differently as the callee decides whether to unpack the tuple or not via the parameters. We can also think about adding a "light" version of tuple support, that just supports unpacking for library-defined tuple types and nothing else, but I'd prefer to have proper tuples. This flew over my head :) ... If we cannot have proper tuples, having some syntactic sugar for tuple unpacking during variable declaration may still be useful: import std.typecons; auto (x,y) = tuple(1,"2"); (int x,string y) = tuple(1,"2"); This is syntactically forward-compatible. OK, this makes sense, yes. -Steve
Linking error: unresolved external symbol internal
I have a static library and an application. When linking final executable I get: lib.lib(texteditor_1d_40c.obj) : error LNK2001: unresolved external symbol internal lib.lib(textbuffer_14_3ce.obj) : error LNK2001: unresolved external symbol internal Happens on Windows 32 and 64 bit. Only with debug build. DMD 2.076.0 Error doesn't happen when I move code from library to the application. Here is reduced test case (where 2 errors happen, 4 files): https://gist.github.com/MrSmith33/29125fa3538bb03637d0aebab6ccff7c Here is smaller case (only 1 error, 2 files): https://gist.github.com/MrSmith33/dc53d8cb6ce642fcb6dbc5863d029cec If this is relevant: 3 places I found in dmd where "internal" symbol is created: * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/backend/dt.c#L420 * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L662 * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L681
Re: initializing a static array
Yeah, you are right. My fault. On Tue, Oct 10, 2017 at 4:47 PM, Adam D. Ruppe via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 10 October 2017 at 14:42:15 UTC, Daniel Kozak wrote: > >> It will return dynamic array. it is same as: >> >> double[5] = [0,0,0,0,0]; // this is still dynamicaly allocated. >> > > Not true here, the compiler knows it is going into a static array and puts > the result directly in there. It handles literals. > > The range version though will allocate since the function doesn't know > where its result ends up. It will CTFE though if the variable is static. >
Re: initializing a static array
On Tuesday, 10 October 2017 at 14:42:15 UTC, Daniel Kozak wrote: It will return dynamic array. it is same as: double[5] = [0,0,0,0,0]; // this is still dynamicaly allocated. Not true here, the compiler knows it is going into a static array and puts the result directly in there. It handles literals. The range version though will allocate since the function doesn't know where its result ends up. It will CTFE though if the variable is static.
[Issue 17890] cpp_long is not declared for Posix 64bit
https://issues.dlang.org/show_bug.cgi?id=17890 Илья Ярошенкоchanged: What|Removed |Added Keywords||C++ --
[Issue 17890] New: cpp_long is not declared for Posix 64bit
https://issues.dlang.org/show_bug.cgi?id=17890 Issue ID: 17890 Summary: cpp_long is not declared for Posix 64bit Product: D Version: D2 Hardware: x86_64 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: ilyayaroshe...@gmail.com ... BTW, why c_long is always 32 bit for windows? --
Re: initializing a static array
On Tue, Oct 10, 2017 at 4:15 PM, Simon Bürger via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: > >> On Tuesday, 10 October 2017 at 13:36:56 UTC, Simon Bürger wrote: >> >>> Is there a good way to set them all to zero? The only way I can think of >>> is using string-mixins to generate a string such as "[0,0,0,0]" with >>> exactly n zeroes. But that seems quite an overkill for such a basic task. I >>> suspect I might be missing something obvious here... >>> >> >> Maybe: >> >> double[n] bar = 0.repeat(n).array; >> > > This works fine, thanks a lot. I would have expected `.array` to return a > dynamic array. But apparently the compiler is smart enough to know the > length. Even the multi-dimensional case works fine: > > double[n][n] bar = 0.repeat(n).array.repeat(n).array; > It will return dynamic array. it is same as: double[5] = [0,0,0,0,0]; // this is still dynamicaly allocated.
Re: initializing a static array
On Tuesday, 10 October 2017 at 13:54:16 UTC, Daniel Kozak wrote: struct Double { double v = 0; alias v this; } struct Foo(size_t n) { Double[n] bar; } Interesting approach. But this might introduce problems later. For example `Double` is implicitly convertible to `double`, but `Double[]` is not implicitly convertible to `double[]`. Therefore I will stick with jmh530's solution for now, but thank you anyway.
Re: initializing a static array
On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: On Tuesday, 10 October 2017 at 13:36:56 UTC, Simon Bürger wrote: Is there a good way to set them all to zero? The only way I can think of is using string-mixins to generate a string such as "[0,0,0,0]" with exactly n zeroes. But that seems quite an overkill for such a basic task. I suspect I might be missing something obvious here... Maybe: double[n] bar = 0.repeat(n).array; This works fine, thanks a lot. I would have expected `.array` to return a dynamic array. But apparently the compiler is smart enough to know the length. Even the multi-dimensional case works fine: double[n][n] bar = 0.repeat(n).array.repeat(n).array;
Re: Current limitations of -dip1000
On Tuesday, 10 October 2017 at 10:49:54 UTC, meppl wrote: On Tuesday, 10 October 2017 at 09:55:13 UTC, meppl wrote: ... also, these differ: (with dmd v2.076.0) @safe: struct S { @safe: int* x; scope int* pointer() return { return x; } } int* testPointer() { S s; return s.pointer(); // no error } struct SA { @safe: int[ 128] x; scope int* pointer() return { return [ 0]; } } int* testPointerA() { SA s; return s.pointer(); // error } Report any bugs to the official bug tracker here: https://issues.dlang.org/
Re: initializing a static array
On Tuesday, 10 October 2017 at 13:53:37 UTC, jmh530 wrote: double[n] bar; bar[] = 0; This works at runtime only for mutable arrays, anyway.
Re: Deprecation message of library functions should state the replacement function
On Tuesday, 10 October 2017 at 12:57:36 UTC, bauss wrote: On Tuesday, 10 October 2017 at 11:48:48 UTC, Eduard Staniloiu wrote: Hi guys, I've just build druntime on Windows and we are displaying the following deprecation message: src\core\sys\windows\odbcinst.d(157): Deprecation: function core.sys.windows.odbcinst.SQLInstallTranslatorW is deprecated. I believe that we should also state with what should the deprecated function be replaced. My 2 cents, Eduard They usually do, I just assume it was forgotten there and if you know which function is to replace it, then simply create a pr? Or simply remove it as it has been deprecated since more than two years: https://github.com/dlang/druntime/blob/8fbcc2d819a84a5340cc6ac724320cae3561cb3b/src/core/sys/windows/odbcinst.d
Re: initializing a static array
On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: Maybe: double[n] bar = 0.repeat(n).array; Alt: double[n] bar; bar[] = 0;
Re: Should we have prettier string printing for exceptions and std elemts?
On Tuesday, 10 October 2017 at 11:17:09 UTC, bauss wrote: On Monday, 9 October 2017 at 18:52:03 UTC, Petar Kirov [ZombineDev] wrote: On Monday, 9 October 2017 at 17:44:12 UTC, jmh530 wrote: On Monday, 9 October 2017 at 17:19:42 UTC, Petar Kirov [ZombineDev] wrote: Printing the container type, address and length would be most useful default IMO (but in a better looking way than what we have now for std.container.array). That's your opinion though; IMO I'd rather have the elements printed by default. It's all subjective and thus there's no real reason for one or the other. FWIW I tried to propose a `dump` function one year ago [1]. There has never been a great interest in it though as while using `writeln` is a bit annoying (e.g. no spaces, no variable names) apparently all core people got used to it already ;-) If someone considers to add a pretty printing method he/she, this new symbol could also be very useful for single elements too (and thus gain chances in its acceptance). [1] https://github.com/dlang/phobos/pull/4318#issuecomment-241819997
Re: initializing a static array
struct Double { double v = 0; alias v this; } struct Foo(size_t n) { Double[n] bar; } Dne 10. 10. 2017 3:40 odpoledne napsal uživatel "Simon Bürger via Digitalmars-d-learn": I have a static array inside a struct which I would like to be initialized to all-zero like so struct Foo(size_t n) { double[n] bar = ... all zeroes ... } (note that the default-initializer of double is nan, and not zero) I tried double[n] bar = 0; // does not compile double[n] bar = {0}; // neither does this double[n] bar = [0]; // compiles, but only sets the first element, ignoring the rest Is there a good way to set them all to zero? The only way I can think of is using string-mixins to generate a string such as "[0,0,0,0]" with exactly n zeroes. But that seems quite an overkill for such a basic task. I suspect I might be missing something obvious here...
Re: initializing a static array
On Tuesday, 10 October 2017 at 13:36:56 UTC, Simon Bürger wrote: Is there a good way to set them all to zero? The only way I can think of is using string-mixins to generate a string such as "[0,0,0,0]" with exactly n zeroes. But that seems quite an overkill for such a basic task. I suspect I might be missing something obvious here... Maybe: double[n] bar = 0.repeat(n).array;
Re: how to shorten templates structs name?
Use alias this Dne 10. 10. 2017 1:30 odpoledne napsal uživatel "drug via Digitalmars-d-learn": > using classes I can make an inherited class of templated class and avoid > too long mangled name: > ``` > class TemplatedClass(A, Very, Much, Args, Here) { ... } > > class ShortenClass : TemplatedClass!(A,Very, Much, Args, Here) { ... }; > ``` > Now ShortenClass has a nice mangling. > > What can be done in case of struct? >
initializing a static array
I have a static array inside a struct which I would like to be initialized to all-zero like so struct Foo(size_t n) { double[n] bar = ... all zeroes ... } (note that the default-initializer of double is nan, and not zero) I tried double[n] bar = 0; // does not compile double[n] bar = {0}; // neither does this double[n] bar = [0]; // compiles, but only sets the first element, ignoring the rest Is there a good way to set them all to zero? The only way I can think of is using string-mixins to generate a string such as "[0,0,0,0]" with exactly n zeroes. But that seems quite an overkill for such a basic task. I suspect I might be missing something obvious here...
Re: New release v0.5 of the D bindings for SAP NetWeaver RFC SDK
On 10/08/2017 12:59 PM, Kai Nacke wrote: > The included set of example applications show how easy it is to call an > RFC. To use the library just add a dependency to your dub.json/dub.sdl > file or clone the source at https://github.com/redstar/sapnwrfc-d. Thanks, examples are nice for packages. Wondering a little about the std. usage, as it seems very unlikely to ever become standardized. Why not just use sap. or netweaver. as top level package? Also I can recommend at least some basic ddoc comments, it's really trivial to use ddox to get some nice documentation, e.g. see https://github.com/MartinNowak/bloom. If you use x:ddoxFilterArgs without "--only-documented", it should even work for undocumented functions. -Martin
[Issue 10131] To remove duplicates and keep order
https://issues.dlang.org/show_bug.cgi?id=10131 Sebchanged: What|Removed |Added CC||greensunn...@gmail.com --- Comment #1 from Seb --- PR https://github.com/dlang/phobos/pull/5774 --
Re: Deprecation message of library functions should state the replacement function
On Tuesday, 10 October 2017 at 11:48:48 UTC, Eduard Staniloiu wrote: Hi guys, I've just build druntime on Windows and we are displaying the following deprecation message: src\core\sys\windows\odbcinst.d(157): Deprecation: function core.sys.windows.odbcinst.SQLInstallTranslatorW is deprecated. I believe that we should also state with what should the deprecated function be replaced. My 2 cents, Eduard They usually do, I just assume it was forgotten there and if you know which function is to replace it, then simply create a pr?
[Issue 17889] Cross platform function to redirect standard input/output
https://issues.dlang.org/show_bug.cgi?id=17889 --- Comment #2 from RazvanN--- I was actually refering to dup2: [1] http://man7.org/linux/man-pages/man2/dup.2.html [2] https://msdn.microsoft.com/en-us/library/8syseb29.aspx --
[Issue 17889] Cross platform function to redirect standard input/output
https://issues.dlang.org/show_bug.cgi?id=17889 b2.t...@gmx.com changed: What|Removed |Added CC||b2.t...@gmx.com --- Comment #1 from b2.t...@gmx.com --- What's the relationship between "dup" and "Cross platform function to redirect standard input/output" ? --
[Issue 17889] New: Cross platform function to redirect standard input/output
https://issues.dlang.org/show_bug.cgi?id=17889 Issue ID: 17889 Summary: Cross platform function to redirect standard input/output Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: razvan.nitu1...@gmail.com I suggest adding to phobos a wrapper function for dup which works for both linux and windows. --
Deprecation message of library functions should state the replacement function
Hi guys, I've just build druntime on Windows and we are displaying the following deprecation message: src\core\sys\windows\odbcinst.d(157): Deprecation: function core.sys.windows.odbcinst.SQLInstallTranslatorW is deprecated. I believe that we should also state with what should the deprecated function be replaced. My 2 cents, Eduard
how to shorten templates structs name?
using classes I can make an inherited class of templated class and avoid too long mangled name: ``` class TemplatedClass(A, Very, Much, Args, Here) { ... } class ShortenClass : TemplatedClass!(A,Very, Much, Args, Here) { ... }; ``` Now ShortenClass has a nice mangling. What can be done in case of struct?
Re: Should we have prettier string printing for exceptions and std elemts?
On Monday, 9 October 2017 at 18:52:03 UTC, Petar Kirov [ZombineDev] wrote: On Monday, 9 October 2017 at 17:44:12 UTC, jmh530 wrote: On Monday, 9 October 2017 at 17:19:42 UTC, Petar Kirov [ZombineDev] wrote: Printing the container type, address and length would be most useful default IMO (but in a better looking way than what we have now for std.container.array). That's your opinion though; IMO I'd rather have the elements printed by default. It's all subjective and thus there's no real reason for one or the other.
[Issue 11577] Template std.typetuple.NoDuplicates removes const types for classes and structs
https://issues.dlang.org/show_bug.cgi?id=11577 --- Comment #1 from alex.jercai...@gmail.com --- What would be the correct behaviour here? Should it treat the const and nonconst as duplicates? --
Re: Current limitations of -dip1000
On Tuesday, 10 October 2017 at 09:55:13 UTC, meppl wrote: ... also, these differ: (with dmd v2.076.0) @safe: struct S { @safe: int* x; scope int* pointer() return { return x; } } int* testPointer() { S s; return s.pointer(); // no error } struct SA { @safe: int[ 128] x; scope int* pointer() return { return [ 0]; } } int* testPointerA() { SA s; return s.pointer(); // error }
Re: Current limitations of -dip1000
On Tuesday, 10 October 2017 at 02:37:21 UTC, Walter Bright wrote: On 10/9/2017 8:04 AM, Per Nordlöw wrote: ... Get rid of the templates, too. Replace T with int. Get rid of any of the layers of confusing complexity. ... this looks like an issue to me. If its a template the pointer can escape. The non-template-version doesnt let the pointer escape @safe: struct ST( T) { @safe: T[ 128] x; scope ref T front() return { return x[ 0]; } scope T* pointer() return { return [ 0]; } } ref int testFrontT() { ST!int s; return s.front(); // pointer escapes } int* testPointerT() { ST!int s; return s.pointer(); // pointer escapes } struct S { @safe: int[ 128] x; scope ref int front() return { return x[ 0]; } scope int* pointer() return { return [ 0]; } } ref int testFront() { S s; return s.front(); // error } int* testPointer() { S s; return s.pointer(); // error }
Re: How do I filter out data from mongodb in D-code
On Tuesday, 10 October 2017 at 09:43:10 UTC, Anders S wrote: I'm working on a middleware application that reads array of data from a POSIX pipe and insert data into the db if any position in the array has changed. This is where my problem lays, in order not to duplicate data I want to fetch the latest data/document in the array of documents. To clarify, This is where my problem lays, in order not to duplicate data I want to fetch the >latest data/document in the array of documents. refers to latest inserted data/document in the mongodb collection. Also that the insert of document that changed include a timestamp like this dateAdded: new Date()
How do I filter out data from mongodb in D-code
Hi, I'm working on a middleware application that reads array of data from a POSIX pipe and insert data into the db if any position in the array has changed. This is where my problem lays, in order not to duplicate data I want to fetch the latest data/document in the array of documents. I'm using MS Code and dub to code and compile. This is the code: Collection ct = mongo.boxweb.celltab; int i = 1; for(;i < 10; i++ ){ auto cell = ct.find({"number":i}).sort({_id:-1}).limit(2).pretty(); if (insert... i++; Where "number" is the document nr in the array I get these errors source/app.d(166,54): Error: found : when expecting ; following statement source/app.d(166,56): Error: found } when expecting ; following statement source/app.d(166,57): Error: found ) instead of statement dmd failed with exit code 1. Any ideas? Isn't there a way to markup code in the forum message to separate from the bodytext? /anders
Re: Catching C++ Exceptions in D - Windows and Linux
On Tuesday, 12 September 2017 at 04:33:30 UTC, Nicholas Wilson wrote: On Tuesday, 12 September 2017 at 03:51:45 UTC, Laeeth Isharc wrote: Hi. I'm here in HK with Ilya, Atila, John Colvin, and Jonathan Davis. I wondered what the current state of D catching C++ exceptions was on Linux and Windows. I know that some work was done on making this possible, and my understanding is that it is, more or less - just wondered what the rough corners might be. Thanks. Laeeth. IIRC I remember Walter saying that we should only bother to be able to catch C++ exceptions derived from std::exception, as opposed to say ints or strings. I believe the line was "those who throw ints should get what they deserve". Apart from that I believe they should "just work", although I haven't tested. OT I'm sorry I could make it to HK, I'm busy with uni all this week. I could possibly do telepresence though. Nic Thanks, Nic. Sorry about the dates - was arranged last minute. I'll drop you a line shortly in any case. Laeeth.
Some tasks in D app
Hello. I have an app for multiplayer game website. I am Facing an issue about stacking terminal. Also the app does not save the logs which is supposed to. I need someone who can fix this. Will send the app to developer. in total The tasks are : 1) Fix stacking issue in the terminal, 2) Fix saving logs 3) Fix the reconnection issue (during the game if one of the opponent has left the game then another opponent sees the pop up window which says "please wait while your opponent reconnect". But the problem is server does not reconnects the disconnected user when he comes back. 4) The same username can be logged in the server. we need to prevent this case. if the user is already in the server, then it shouldnt be allowed him to login again. We have allocated budget for all these tasks. In total we are going to pay 200-250$. Please contact me by email if you are interested : a.mammad...@liverpool.ac.uk Regards
Re: "This week in D" state
On Tuesday, 10 October 2017 at 07:12:19 UTC, Eliatto wrote: I noticed that "This week in D" site was seldom updated. Last activity is September, the 3rd. If Adam is busy at the moment, then I think that he should have an assistant. I think he's lost interest, even when he does post, he rarely puts up anything more than forum links this year. I don't blame him, it's a thankless job. That's why I suggested merging it with the blog last year, but for whatever reason that hasn't happened: http://forum.dlang.org/thread/mkxsvwxmusxifunpf...@forum.dlang.org
Re: How to call function with variable arguments at runtime?
On Tuesday, 10 October 2017 at 02:58:45 UTC, Mr. Jonse wrote: I need to store a hetrogeneous array of delegates. How can I do this but still call the function with the appropriate number of parameters at run time? I have the parameters as Variant[] params and a function/delegate pointer(void* for now). Normally I'd push the parameters on the stack and use a call, but I'm sure D has some ability to do this, like apply(foo, args) would be the same as foo(args[0], ..., args[1]). I'm not concerned about type correctness, it should always be consistent between what I call and what is stored. Thanks. Like so? import std.variant; void foo(int a, string b, float c) { import std.stdio; writefln("a = %s, b = %s, c = %s", a, b, c); } auto apply(alias fn)(Variant[] values) { import std.traits : ParameterTypeTuple; import std.conv : emplace; alias Types = ParameterTypeTuple!fn; assert(values.length == Types.length); Types args = void; foreach(i, ref arg; args) { // using emplace instead of assignment here to be fully correct emplace!(typeof(arg))(, values[i].get!(typeof(arg))); } return fn(args); } void main() { Variant[] values = [Variant(1), Variant("Hello world"), Variant(3.14159f)]; apply!foo(values); }
Re: How to call function with variable arguments at runtime?
On Tuesday, 10 October 2017 at 02:58:45 UTC, Mr. Jonse wrote: I need to store a hetrogeneous array of delegates. How can I do this but still call the function with the appropriate number of parameters at run time? I have the parameters as Variant[] params and a function/delegate pointer(void* for now). Normally I'd push the parameters on the stack and use a call, but I'm sure D has some ability to do this, like apply(foo, args) would be the same as foo(args[0], ..., args[1]). I'm not concerned about type correctness, it should always be consistent between what I call and what is stored. Thanks. Not entirely sure what you're wanting to do, but sounds a lot like variadic parameters. https://dlang.org/spec/function.html#variadic mixed with some compile-time terminology.
Re: How to make commented code to compile?
On Monday, 9 October 2017 at 15:22:54 UTC, Adam D. Ruppe wrote: On Monday, 9 October 2017 at 15:15:48 UTC, Zhuo Nengwen wrote: test(cast(ushort) 1, (m, c) => { writeln(m); writeln(m); }); Just remove the => (m, c) { // code here } Common mistake from people who worked with LINQ in C#.
"This week in D" state
I noticed that "This week in D" site was seldom updated. Last activity is September, the 3rd. If Adam is busy at the moment, then I think that he should have an assistant.
[Issue 17797] [REG 2.073.2] double print to stdout when reading stdin in another thread
https://issues.dlang.org/show_bug.cgi?id=17797 Rainer Schuetzechanged: What|Removed |Added CC||r.sagita...@gmx.de --- Comment #4 from Rainer Schuetze --- I could verify it happens with 2.073.2, but not 2.073.1. This is caused by an updated snn.lib. Might be introduced by the fix for issue 13727. --