Re: if (auto x = cast(C) x)

2017-08-09 Thread Meta via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 21:54:46 UTC, Q. Schroll wrote: For a class/interface type `A` and a class `C` inheriting from `A` one can do A a = getA(); if (auto c = cast(C) a) { .. use c .. } to get a `C` view on `a` if it happens to be a `C`-instance. Sometimes one cannot find a

Re: BigInt foreach loop

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 9:08 PM, Steven Schveighoffer wrote: Right, but this is not a limitation of the API, just the implementation. It could be improved. https://issues.dlang.org/show_bug.cgi?id=17736 Based on H.S. Teoh's comment in the bug report, this actually is invalid. That's a tough requirement.

Re: BigInt foreach loop

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 5:40 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Aug 09, 2017 at 09:34:26PM +, Q. Schroll via Digitalmars-d-learn wrote: On Friday, 4 August 2017 at 16:40:08 UTC, Stefan Koch wrote: [..] foreach(x;A .. B) it's lowerd to auto limit = B; auto key = A; for(auto x =

Re: Cannot use std.array.Appender in recursive types

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 6:24 PM, Nordlöw wrote: On Wednesday, 9 August 2017 at 19:00:54 UTC, Steven Schveighoffer wrote: If I change the definition of ElementType to use R.init.front instead of R.init.front.init, it compiles. But I'm pretty sure this will break other ranges. If Phobos compiles with the

delegates/lambas do not pick up calling convention

2017-08-09 Thread Johnson Jones via Digitalmars-d-learn
given somethign like Threads.threadsAddIdle which takes an extern(C) int (void*) we can't seem to do threadsAddIdle((void*) { }, null); nor because D complains is not the correct type nor can we do delegate(void*) or extern(C) delegate(void*) {} and have to resort to verbosity to get

Re: Cannot use std.array.Appender in recursive types

2017-08-09 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 19:00:54 UTC, Steven Schveighoffer wrote: If I change the definition of ElementType to use R.init.front instead of R.init.front.init, it compiles. But I'm pretty sure this will break other ranges. If Phobos compiles with the change would that change deserve a

Re: if (auto x = cast(C) x)

2017-08-09 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 21:54:46 UTC, Q. Schroll wrote: For a class/interface type `A` and a class `C` inheriting from `A` one can do A a = getA(); if (auto c = cast(C) a) { .. use c .. } to get a `C` view on `a` if it happens to be a `C`-instance. Sometimes one cannot find a

Re: Get Dll functions at compile time

2017-08-09 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 02:11:13 UTC, Johnson Jones wrote: I like to create code that automates much of the manual labor that we, as programmers, are generally forced to do. D generally makes much of this work automatable. For example, I have created the following code which makes

if (auto x = cast(C) x)

2017-08-09 Thread Q. Schroll via Digitalmars-d-learn
For a class/interface type `A` and a class `C` inheriting from `A` one can do A a = getA(); if (auto c = cast(C) a) { .. use c .. } to get a `C` view on `a` if it happens to be a `C`-instance. Sometimes one cannot find a good new name for `c` while there is no advantage of accessing

Re: gtkD window centering message up and no app on taskbar

2017-08-09 Thread Johnson Jones via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 15:10:46 UTC, Mike Wey wrote: On 09-08-17 01:00, Johnson Jones wrote: But, finally, this does seem to work: // Fixup missing taskbar icon void SetTaskBarIcon(gtk.ApplicationWindow window) { version(Windows) version(X86) {

Re: BigInt foreach loop

2017-08-09 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 09, 2017 at 09:34:26PM +, Q. Schroll via Digitalmars-d-learn wrote: > On Friday, 4 August 2017 at 16:40:08 UTC, Stefan Koch wrote: > > [..] > > > > foreach(x;A .. B) > > it's lowerd to > > auto limit = B; > > auto key = A; > > for(auto x = key;key < limit;++key) > > { > > // use

Re: BigInt foreach loop

2017-08-09 Thread Q. Schroll via Digitalmars-d-learn
On Friday, 4 August 2017 at 16:40:08 UTC, Stefan Koch wrote: [..] foreach(x;A .. B) it's lowerd to auto limit = B; auto key = A; for(auto x = key;key < limit;++key) { // use x } That's enough to know that the foreach loop does not reuse the space for the iteration variable. That was what I

Re: Get Dll functions at compile time

2017-08-09 Thread Johnson Jones via Digitalmars-d-learn
Was buggy due to refactoring. module DLLImport; /* Import DLL functions in to type T. The following example shows methodology struct DLL_gdk { @("DLLImport") public static extern(Windows) { @("libgdk-3-0.dll") {

Re: Format g bug ?

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 4:10 PM, Temtaime wrote: Sorry, messed up numbers Expected: 3.11 3.11 3.1 3.1 Seems g outputs one digit less I was bugged by this too. It's not a bug. For the %f specifier, the number represents the number of digits *after* the decimal. For the %g specifier, the number

Re: Format g bug ?

2017-08-09 Thread Temtaime via Digitalmars-d-learn
Sorry, messed up numbers Expected: 3.11 3.11 3.1 3.1 Seems g outputs one digit less

Format g bug ?

2017-08-09 Thread Temtaime via Digitalmars-d-learn
import std.stdio; void main() { writefln(`%.2g`, 3.11); writefln(`%.2f`, 3.11); writefln(`%.1g`, 3.11); writefln(`%.1f`, 3.11); } 3.1 3.11 3 3.1 But expected 3.1 3.11 3.1 3.11

Re: gtkD window centering message up and no app on taskbar

2017-08-09 Thread Johnson via Digitalmars-d-learn
Also, could there be an easier way to import everything that is generally required? I'm using an import script that does the work but I have to replace it upgrade time I upgrade gtkD(since I have to delete everything). I find that having a ton of imports is a big ugly. What I use is, which

Re: gtkD window centering message up and no app on taskbar

2017-08-09 Thread Johnson via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 15:10:46 UTC, Mike Wey wrote: On 09-08-17 01:00, Johnson Jones wrote: But, finally, this does seem to work: // Fixup missing taskbar icon void SetTaskBarIcon(gtk.ApplicationWindow window) { version(Windows) version(X86) {

Re: Cannot use std.array.Appender in recursive types

2017-08-09 Thread Timon Gehr via Digitalmars-d-learn
On 09.08.2017 21:00, Steven Schveighoffer wrote: On 8/9/17 2:25 PM, Nordlöw wrote: Why doesn't appending to `subs` work with std.array.Appender in struct T { string src; import std.array : Appender; Appender!(T[]) subs; } T t; t.subs ~=

Re: Cannot use std.array.Appender in recursive types

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 2:25 PM, Nordlöw wrote: Why doesn't appending to `subs` work with std.array.Appender in struct T { string src; import std.array : Appender; Appender!(T[]) subs; } T t; t.subs ~= T.init; // ERRORS t.subs.put(T.init); // ERRORS

Cannot use std.array.Appender in recursive types

2017-08-09 Thread Nordlöw via Digitalmars-d-learn
Why doesn't appending to `subs` work with std.array.Appender in struct T { string src; import std.array : Appender; Appender!(T[]) subs; } T t; t.subs ~= T.init; // ERRORS t.subs.put(T.init); // ERRORS when it works with builtin arrays as in

Re: Express "Class argument may not be null" ?

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 1:05 PM, Johan wrote: On Wednesday, 9 August 2017 at 12:47:49 UTC, Steven Schveighoffer wrote: On 8/8/17 3:59 PM, Johan Engelen wrote: In C++, it is clear that the _caller_ is doing the dereferencing, and the dereference is also explicit. In fact it's not doing any dereferencing.

Re: Express "Class argument may not be null" ?

2017-08-09 Thread Johan via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 12:47:49 UTC, Steven Schveighoffer wrote: On 8/8/17 3:59 PM, Johan Engelen wrote: In C++, it is clear that the _caller_ is doing the dereferencing, and the dereference is also explicit. In fact it's not doing any dereferencing. It's just under the hood

Re: gtkD window centering message up and no app on taskbar

2017-08-09 Thread Mike Wey via Digitalmars-d-learn
On 09-08-17 01:00, Johnson Jones wrote: But, finally, this does seem to work: // Fixup missing taskbar icon void SetTaskBarIcon(gtk.ApplicationWindow window) { version(Windows) version(X86) { import core.sys.windows.winuser, gdk.Window; auto

Re: Efficiently streaming data to associative array

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/17 3:43 PM, Anonymouse wrote: On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote: I wouldn't use formattedRead, as I think this is going to allocate temporaries for a and b. What would you suggest to use in its stead? My use-case is similar to the OP's in that I

Re: Is it's possible to make modular pug template in vibed?

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 5:30 AM, Suliman wrote: Big thanks! Now I understand. Now i redone dlang.ru in diet templates. Great! Am I right understand that include is needed only for small includes without any nesting levels? No, includes can be as big as you want, with as many nested levels as you

Re: Express "Class argument may not be null" ?

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/17 4:00 PM, Andre Kostur wrote: On 2017-08-08 12:38 PM, Steven Schveighoffer wrote: On 8/8/17 2:56 PM, ag0aep6g wrote: On 08/08/2017 08:34 PM, Johan Engelen wrote: How would you express the function interface intent that a reference to a class may not be null? For a function "void

Re: Express "Class argument may not be null" ?

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/17 3:59 PM, Johan Engelen wrote: On Tuesday, 8 August 2017 at 19:38:19 UTC, Steven Schveighoffer wrote: Note that C++ also can do this, so I'm not sure the & is accomplishing the correct goal: void foo(Klass&); int main() { Klass *k = NULL; foo(*k); } In C++, it is clear

Re: Efficiently streaming data to associative array

2017-08-09 Thread Guillaume Chatelet via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 10:00:14 UTC, kerdemdemir wrote: As a total beginner I am feeling a bit not comfortable with basic operations in AA. First even I am very happy we have pointers but using pointers in a common operation like this IMHO makes the language a bit not safe. Second

Re: Efficiently streaming data to associative array

2017-08-09 Thread kerdemdemir via Digitalmars-d-learn
I haven't yet dug into formattedRead but thx for letting me know : ) I was mostly speaking about the pattern with the AA. I guess the best I can do is a templated function to hide the ugliness. ref Value GetWithDefault(Value)(ref Value[string] map, const (char[]) key) { auto pValue = key

Re: Is it's possible to make modular pug template in vibed?

2017-08-09 Thread Suliman via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 15:54:29 UTC, Steven Schveighoffer wrote: On 8/8/17 10:52 AM, Suliman wrote: your examples generate me: DLANG.ru (c) DLANG 2017 That's the template without the

Re: readText with added null-terminator that enables sentinel-based search

2017-08-09 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 08 Aug 2017 20:48:39 + schrieb Nordlöw : > Has anybody written a wrapper around `std.file.readText` (or > similar) that appends a final zero-byte terminator in order to > realize sentinel-based search in textual parsers. What do you mean by similar? There are

KissRPC for dlang ver release.(Ultra high performance RPC)

2017-08-09 Thread jasonsalex via Digitalmars-d-learn
kiss-rpc-flatbuffer features: Lightweight and easy to use. There are two ways to support IDL and manually write protocols. Analog function call, more in line with the RPC remote call logic, simple, transparent. Easy to change, easy to use, existing code can be used directly The data format

Re: Why does stringof not like functions with arguments?

2017-08-09 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 01:39:07 UTC, Jason Brady wrote: Why does the following code error out with: app.d(12,10): Error: function app.FunctionWithArguments (uint i) is not callable using argument types () Like Olivier said, stringof expects a valid expression. There are a few other

Re: Why does stringof not like functions with arguments?

2017-08-09 Thread Olivier FAURE via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 01:39:07 UTC, Jason Brady wrote: Why does the following code error out with: app.d(12,10): Error: function app.FunctionWithArguments (uint i) is not callable using argument types () Code: import std.stdio; void FunctionWithoutArguments() { } void

Re: D on AArch64 CPU

2017-08-09 Thread Johannes Pfau via Digitalmars-d-learn
Am Sun, 14 May 2017 15:05:08 + schrieb Richard Delorme : > I recently bought the infamous Raspberry pi 3, which has got a > cortex-a53 4 cores 1.2 Ghz CPU (Broadcom). After installing on it > a 64 bit OS (a non official fedora 25), I was wondering if it was >