Re: Type sniffing at runtime

2020-05-16 Thread Alex via Digitalmars-d-learn
On Saturday, 16 May 2020 at 05:22:49 UTC, n0den1te wrote: [...] For example, like this: ´´´ import std; alias types = AliasSeq!( bool, byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real, char, wchar, dchar ); void main() { static foreach(type; types) {

Re: Option and Result [was Integration tests]

2020-04-21 Thread Alex via Digitalmars-d-learn
On Tuesday, 21 April 2020 at 16:30:15 UTC, Russel Winder wrote: On Mon, 2020-04-20 at 20:19 +, aliak via Digitalmars-d-learn wrote: […] [0]: https://github.com/aliak00/optional Rust has Option and Result, and most languages are rapidly introducing at least Option if not Result – and

Re: need help to get member function const address

2020-03-19 Thread Alex via Digitalmars-d-learn
On Thursday, 19 March 2020 at 04:30:32 UTC, Calvin P wrote: I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static

Re: What type does byGrapheme() return?

2020-01-06 Thread Alex via Digitalmars-d-learn
On Monday, 6 January 2020 at 08:39:19 UTC, Robert M. Münch wrote: On 2020-01-05 04:18:34 +, H. S. Teoh said: At a minimum, I think we should file a bug report to investigate whether Grapheme.opSlice can be implemented differently, such that we avoid this obscure referential behaviour that

Re: Multi-threaded sorting of text file

2020-01-04 Thread Alex via Digitalmars-d-learn
On Saturday, 4 January 2020 at 07:51:49 UTC, MGW wrote: Need help: There' s a large text file (hundreds of thousands of lines). The structure is as follows: 2345|wedwededwedwedwe .. 872625|rfrferwewweww . 23|rergrferfefer It is necessary to sort this file by the

Re: array of functions/delegates

2019-12-24 Thread Alex via Digitalmars-d-learn
On Tuesday, 24 December 2019 at 07:37:02 UTC, Rumbu wrote: I am trying to create an array of functions inside a struct. struct S { void f1() {} void f2() {} alias Func = void function(); immutable Func[2] = [, ] } What I got: Error: non-constant expression '' Tried also with

Re: Intersection of two sets

2019-12-03 Thread Alex via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 13:43:26 UTC, Jan Hönig wrote: It seems i don't google the right keywords. What i want to do: I have two sets. (I didn't find how to do sets, so i have two associative boolean arrays `bool[]`). And i want to join them, via an intersection. I know how to code

Re: Simple casting?

2019-11-25 Thread Alex via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 05:17:54 UTC, Taylor R Hillegeist wrote: On Tuesday, 26 November 2019 at 05:05:48 UTC, Taylor R Hillegeist wrote: I'm attempting to do a segment group. details: alias ProbePoint[3]=triple; triple[] irqSortedSet = UniqueTriples.keys

Re: Splitting a stream of data on based on data change.

2019-11-21 Thread Alex via Digitalmars-d-learn
On Thursday, 21 November 2019 at 21:36:08 UTC, Taylor R Hillegeist wrote: I was looking through the standard library for a good way to split a range into several ranges based on value changes in the stream: AAABB would be split on the AB transition into: AAA BB I just

Re: Unable to pass a D function member to a C callback

2019-11-02 Thread Alex via Digitalmars-d-learn
On Saturday, 2 November 2019 at 17:49:09 UTC, Luh wrote: Hello, When trying to pass a D function to the C callback, the compiler says: 'Error: cannot implicitly convert expression of type extern (C) bool delegate(const(short*) a, ulong b, void* c) to extern (C) bool

Re: Dynamic Arrays as Stack and/or Queue

2019-10-07 Thread Alex via Digitalmars-d-learn
On Monday, 7 October 2019 at 19:38:50 UTC, mipri wrote: On Monday, 7 October 2019 at 19:16:31 UTC, IGotD- wrote: On Monday, 7 October 2019 at 17:36:09 UTC, Ferhat Kurtulmuş wrote: I'm not talking about memory deletion. I'm talking about push, pop, enqueue, and dequeue behavior. I'd assume in

Re: how to determine if a function exists in a class?

2019-10-02 Thread Alex via Digitalmars-d-learn
On Wednesday, 2 October 2019 at 06:06:20 UTC, TodNaz wrote: Hello everyone! I have a question: how to determine if a function exists in a class? Is this possible with @pointer tagging? Do you mean, like in examples of https://dlang.org/library/std/traits/has_member.html ?

Re: Looking for a Simple Doubly Linked List Implementation

2019-09-21 Thread Alex via Digitalmars-d-learn
On Friday, 20 September 2019 at 20:26:03 UTC, Ron Tarrant wrote: Hi guys, I've been banging my head on the screen with this one for the last week or so. For whatever reason, I'm having major problems understanding how to implement a doubly-linked list in D. I don't know if it's because I'm

Re: need this for name of type string

2019-09-10 Thread Alex via Digitalmars-d-learn
On Tuesday, 10 September 2019 at 10:32:29 UTC, Andre Pany wrote: Hi, following coding is throwing compiler error: need this for name of type string The error disappears if I delete method0. My gut feeling is, this is a compiler bug? --- class C { static this() {

Re: What the abstrac final class mean?

2019-08-12 Thread Alex via Digitalmars-d-learn
On Monday, 12 August 2019 at 08:54:56 UTC, lili wrote: Hi: Why need defined an abstract final class? see https://github.com/Rikarin/Trinix/blob/master/Kernel/arch/amd64/gdt.d From what I saw, all members are static. So, this is a kind of utility class, which is not supposed to be

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread Alex via Digitalmars-d-learn
On Sunday, 11 August 2019 at 20:32:14 UTC, John Colvin wrote: As I see this, everything you wrote is correct. :) But you compared abstractness with interface usage, initially. So... I would say, interfaces are more like the abstract method case without any function body. But then, you will

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread Alex via Digitalmars-d-learn
On Sunday, 11 August 2019 at 16:05:20 UTC, John Colvin wrote: I'm trying to narrow down exactly what patterns work with each and how they overlap. What I was trying to get at with the abstract method thing is that abstract class C { void foo(); } is an abstract class with a

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread Alex via Digitalmars-d-learn
On Sunday, 11 August 2019 at 13:09:43 UTC, John Colvin wrote: Ok. What would go wrong (in D) if I just replaced every interface with an abstract class? I think there's some confusion here, because B.foo is not abstract. abstract on a class is not inherited by its methods.

Re: Passing nested template function

2019-08-10 Thread Alex via Digitalmars-d-learn
On Saturday, 10 August 2019 at 17:45:43 UTC, Prateek Nayak wrote: A nested function can be passed to another function evident from this example: https://run.dlang.io/is/6waRkB However if the nested function is a template function, it raises an error https://run.dlang.io/is/PQhkwl The error

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread Alex via Digitalmars-d-learn
On Saturday, 10 August 2019 at 14:29:03 UTC, John Colvin wrote: On Saturday, 10 August 2019 at 10:11:15 UTC, Alex wrote: On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread Alex via Digitalmars-d-learn
On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract class? (Other than multiple inheritance). I'm such a noob at

Re: Is it possible to execute a function inside .d script that has no main function?

2019-07-11 Thread Alex via Digitalmars-d-learn
On Thursday, 11 July 2019 at 09:43:55 UTC, BoQsc wrote: Here I have a file named: module.d import std.stdio : writeln; void interestingFunction(){ writeln("Testing"); } There is no main() function since, I want to import this module, into another .d file. ( If I try to import

Re: For loop with separator

2019-07-04 Thread Alex via Digitalmars-d-learn
On Thursday, 4 July 2019 at 17:00:33 UTC, Q. Schroll wrote: Probably you've come over this problem once in a while, too. You have a repeating solution, so you use a for(each) loop. Sometimes, there is an action to be performed between the end of one iteration and the beginning of the next, if

Re: create and initialise array

2019-06-20 Thread Alex via Digitalmars-d-learn
Thanks Matheus, thats what i needed. I added a PR to mention this function in the language documentation about arrays.

create and initialise array

2019-06-19 Thread Alex via Digitalmars-d-learn
Is there a way of creating and initialising a dynamic array ? for example I am doing this: auto arr = new float[]; arr[] = 0.0f; Profiling indicates that the compiler (gdc) is spending significant time memsetting the whole array to something (nan ?) before I immediately memset it to 0.0f.

Re: Delegate / Error: cannot implicitly convert expression...

2019-06-15 Thread Alex via Digitalmars-d-learn
On Saturday, 15 June 2019 at 16:34:22 UTC, Robert M. Münch wrote: On 2019-06-15 16:19:23 +, Anonymouse said: By design, I think: "delegate and function objects cannot be mixed. But the standard function std.functional.toDelegate converts a function to a delegate." Your example compiles

Re: Elegant way to test if members of array A are present in array B?

2019-06-11 Thread Alex via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 17:12:17 UTC, Robert M. Münch wrote: Is there a simple and elegant way to do this? Or is just using a foreach(...) with canFind() the best way? There is also find_among, but the performance is the same, I assume.

Re: How to create a template class using foreach delegate to filter objects in a member function call?

2019-06-01 Thread Alex via Digitalmars-d-learn
On Saturday, 1 June 2019 at 14:24:11 UTC, Robert M. Münch wrote: The myFilter struct is the implementation which myClass.put() should use to iterate over all objects. Which ones? The E-objects, or the objects contained in myClass, which you don't want to know about? All things being only

Re: How to create a template class using foreach delegate to filter objects in a member function call?

2019-05-31 Thread Alex via Digitalmars-d-learn
On Friday, 31 May 2019 at 16:24:28 UTC, Robert M. Münch wrote: The code is just to show the problem and not meant to compile. I couldn't get anything to compile... That's ok, but could you provide an example anyway? Is it like this? ´´´ void main(){ auto target = new myClass!int();

Re: How to create a template class using foreach delegate to filter objects in a member function call?

2019-05-31 Thread Alex via Digitalmars-d-learn
On Thursday, 30 May 2019 at 18:34:31 UTC, Robert M. Münch wrote: I have myClass and I want to add a way where I can provide a delegate to iterate over myClass.objects when a member function put(...) of myClass is called. The idea is that a user of myClass can provide something like an

Re: Performance of tables slower than built in?

2019-05-24 Thread Alex via Digitalmars-d-learn
On Friday, 24 May 2019 at 13:57:30 UTC, Ola Fosheim Grøstad wrote: On Friday, 24 May 2019 at 12:24:02 UTC, Alex wrote: If it truly is a 27x faster then then that is very relevant and knowing why is important. Of course, a lot of that might simply be due to LDC and I wasn't able to determine

Re: Performance of tables slower than built in?

2019-05-24 Thread Alex via Digitalmars-d-learn
On Friday, 24 May 2019 at 11:45:46 UTC, Ola Fosheim Grøstad wrote: On Friday, 24 May 2019 at 08:33:34 UTC, Ola Fosheim Grøstad wrote: On Thursday, 23 May 2019 at 21:47:45 UTC, Alex wrote: Either way, sin it's still twice as fast. Also, in the code the sinTab version is missing the writeln so

Re: Performance of tables slower than built in?

2019-05-24 Thread Alex via Digitalmars-d-learn
On Friday, 24 May 2019 at 11:57:44 UTC, Alex wrote: On Friday, 24 May 2019 at 08:13:00 UTC, Basilez B. wrote: On Thursday, 23 May 2019 at 10:16:42 UTC, Alex wrote: On Wednesday, 22 May 2019 at 08:25:58 UTC, Basile B. wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to

Re: Performance of tables slower than built in?

2019-05-24 Thread Alex via Digitalmars-d-learn
On Friday, 24 May 2019 at 11:45:46 UTC, Ola Fosheim Grøstad wrote: On Friday, 24 May 2019 at 08:33:34 UTC, Ola Fosheim Grøstad wrote: On Thursday, 23 May 2019 at 21:47:45 UTC, Alex wrote: Either way, sin it's still twice as fast. Also, in the code the sinTab version is missing the writeln so

Re: Performance of tables slower than built in?

2019-05-24 Thread Alex via Digitalmars-d-learn
On Friday, 24 May 2019 at 08:13:00 UTC, Basilez B. wrote: On Thursday, 23 May 2019 at 10:16:42 UTC, Alex wrote: On Wednesday, 22 May 2019 at 08:25:58 UTC, Basile B. wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines

Re: Performance of tables slower than built in?

2019-05-23 Thread Alex via Digitalmars-d-learn
On Thursday, 23 May 2019 at 18:57:03 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some code by using tables... but it seems it's slower than the function itself?!? Not when

Re: Performance of tables slower than built in?

2019-05-23 Thread Alex via Digitalmars-d-learn
On Thursday, 23 May 2019 at 19:17:40 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: xxx = 0; sw.reset(); sw.start(); for(double i = 0; i < 1000; i++) xxx += sin(PI*i); t = sw.peek().msecs; writeln(t);

Re: Performance of tables slower than built in?

2019-05-23 Thread Alex via Digitalmars-d-learn
On Thursday, 23 May 2019 at 15:20:22 UTC, Timon Gehr wrote: On 23.05.19 12:21, Alex wrote: On Wednesday, 22 May 2019 at 00:55:37 UTC, Adam D. Ruppe wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some

Re: Performance of tables slower than built in?

2019-05-23 Thread Alex via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 00:55:37 UTC, Adam D. Ruppe wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some code by using tables... but it seems it's slower than the function itself?!? There's

Re: Performance of tables slower than built in?

2019-05-23 Thread Alex via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 08:25:58 UTC, Basile B. wrote: On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote: I am trying to create some fast sin, sinc, and exponential routines to speed up some code by using tables... but it seems it's slower than the function itself?!? [...] Hi,

Re: Why function does not work with delegate

2019-05-23 Thread Alex via Digitalmars-d-learn
On Wednesday, 22 May 2019 at 23:54:47 UTC, Adam D. Ruppe wrote: On Wednesday, 22 May 2019 at 22:33:52 UTC, Alex wrote: auto x = (GdkEventButton* e, Widget w) ... X.addOnButtonPress(x); Why is x not a delegate? Because you didn't ask for one and it didn't have to be. Just add the

Why function does not work with delegate

2019-05-22 Thread Alex via Digitalmars-d-learn
In gtkD one can use a lambda directly: X.addOnButtonPress((GdkEventButton* e, Widget w) ... but if I try move the lambda in to a variable so I can use it with multiple handlers, I get an error: // x is a function and does not work auto x = (GdkEventButton* e, Widget w) ...

Re: release build with debug information?

2019-05-21 Thread Alex via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 09:48:34 UTC, Robert M. Münch wrote: Is it possible to compile a release build with debug information? There is a "release-debug" version in case you are using dub. Not sure, if there is enough debug info for you.

Impose structure on array

2019-05-20 Thread Alex via Digitalmars-d-learn
given some array, is there some way to easily impose structure on that array at runtime? void* data; auto x = cast(byte[A,B,C])data; X is then an AxBxC matrix. I'm having to compute the index myself and it just seems unnecessary. A and B are not known at compile time though. Obviously it

Re: Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Alex via Digitalmars-d-learn
On Sunday, 19 May 2019 at 16:17:17 UTC, Andrew Edwards wrote: ´´´ import std; void main() { int[][] M = [[1,2,3],[1,2,3],[1,2,3]]; M.recursiveMultiplier(4); writeln(M); } void recursiveMultiplier(T, V)(T arr, V val) @nogc { static if(isArray!(ElementType!T))

Re: Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Alex via Digitalmars-d-learn
On Sunday, 19 May 2019 at 06:34:18 UTC, Andrew Edwards wrote: Sooo... I'm trying to learn this stuff so that I can fully grasp the content of Jens Mueller's 2019 DConf talk and its applications in financial sector (forex and options/futures trading). Unfortunately, I'm doing so using python

Re: Creating Anonymous structs

2019-05-18 Thread Alex via Digitalmars-d-learn
On Saturday, 18 May 2019 at 20:53:50 UTC, Alex wrote: On Saturday, 18 May 2019 at 20:03:14 UTC, Adam D. Ruppe wrote: On Saturday, 18 May 2019 at 15:59:05 UTC, Alex wrote: Structs combine data, I have a use case where I do not want to litter the scope with variables and would like to put them

Re: Creating Anonymous structs

2019-05-18 Thread Alex via Digitalmars-d-learn
On Saturday, 18 May 2019 at 20:03:14 UTC, Adam D. Ruppe wrote: On Saturday, 18 May 2019 at 15:59:05 UTC, Alex wrote: Structs combine data, I have a use case where I do not want to litter the scope with variables and would like to put them in a struct but the variable will only be used once.

Re: Creating Anonymous structs

2019-05-18 Thread Alex via Digitalmars-d-learn
Also, I realize one could use Voldemort types, e.g., something like auto x = (){ struct X { int x; } return X(); } but this is so verbose as to not really be any better(although it does accomplish hiding the struct, I'm not so concerned with hiding the struct as I am code brevity. I do

Creating Anonymous structs

2019-05-18 Thread Alex via Digitalmars-d-learn
Structs combine data, I have a use case where I do not want to litter the scope with variables and would like to put them in a struct but the variable will only be used once. struct X { int x; double y; } X x; Seems redundant to have to do this, rather, it would be nice to do auto x =

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-18 Thread Alex via Digitalmars-d-learn
On Friday, 17 May 2019 at 18:02:04 UTC, kdevel wrote: On Thursday, 16 May 2019 at 20:31:23 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 20:17:37 UTC, Steven Schveighoffer [...] hnsecs is more confusing than nanoseconds. People know what a nanosecond is, a hecto-nano-second is

Re: Blog Post #0036 - File Dialog - Open a Single File

2019-05-17 Thread Alex via Digitalmars-d-learn
On Friday, 17 May 2019 at 09:24:59 UTC, Ron Tarrant wrote: The second post this week continues the series on Dialogs. This one is about opening files and can be found here: http://gtkdcoding.com/2019/05/17/0036-file-open-dialogs.html So, I'm using gtkD and eventually I'll have the need to use

Re: disabling and enabling console output

2019-05-16 Thread Alex via Digitalmars-d-learn
On Thursday, 16 May 2019 at 17:49:24 UTC, Adam D. Ruppe wrote: On Thursday, 16 May 2019 at 14:53:14 UTC, Alex wrote: I have some code that disables the console because some other code puts junk on it that I don't want to see s stupid question but can't you just edit the other code to not

Re: disabling and enabling console output

2019-05-16 Thread Alex via Digitalmars-d-learn
On Thursday, 16 May 2019 at 17:19:13 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 17:18:01 UTC, Alex wrote: adding int dup(int) @trusted; int dup2(int, int) @trusted; int close(int) @trusted; int open(in char*, int, ...) @trusted; Be sure to make

Re: disabling and enabling console output

2019-05-16 Thread Alex via Digitalmars-d-learn
On Thursday, 16 May 2019 at 17:07:39 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 17:05:01 UTC, Alex wrote: One thing you could try is going one level lower, and using dup() to save the stream to another fd, close() to close the stdout one, and dup2() to restore the saved fd over

Re: disabling and enabling console output

2019-05-16 Thread Alex via Digitalmars-d-learn
On Thursday, 16 May 2019 at 15:21:48 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 14:53:14 UTC, Alex wrote: I have some code that disables the console because some other code puts junk on it that I don't want to see... then I enable it. One thing you could try is going one

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-16 Thread Alex via Digitalmars-d-learn
On Thursday, 16 May 2019 at 15:27:33 UTC, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 15:19:03 UTC, Alex wrote: 1 - 17 ms, 553 ╬╝s, and 1 hnsec WTH!! is there any way to just get a normal u rather than some fancy useless asci hieroglyphic? Why don't we have a fancy M? and an h?

1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-16 Thread Alex via Digitalmars-d-learn
1 - 17 ms, 553 ╬╝s, and 1 hnsec WTH!! is there any way to just get a normal u rather than some fancy useless asci hieroglyphic? Why don't we have a fancy M? and an h? What's an hnsec anyways?

disabling and enabling console output

2019-05-16 Thread Alex via Digitalmars-d-learn
I have some code that disables the console because some other code puts junk on it that I don't want to see... then I enable it. stdout.close(); stderr.close(); ... stdout.open("CON", "w"); stderr.open("CON", "w"); It works but when the routine that uses this is called twice, it completely

Re: GtkD slows down visual D keyboard

2019-05-15 Thread Alex via Digitalmars-d-learn
A hack: On Tue, 14 May 2019 19:44:01 +0200, Mike Wey wrote: On 14-05-2019 05:10, Alex X wrote: Any news on this? https://forum.dlang.org/thread/bznpylcjostbrrwzh...@forum.dlang.org It's severely cramping my style ;/ Unfortunately no. // The following code bypasses GTK windows hooking

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-08 Thread Alex via Digitalmars-d-learn
On Wednesday, 8 May 2019 at 11:53:34 UTC, Russel Winder wrote: On Mon, 2019-05-06 at 15:53 +, John Colvin via Digitalmars-d-learn wrote: […] pretty please show people it with UFCS: recurrence!((a, n) => a[n-1] + a[n-2])(zero, one) .dropExactly(n) .front Any particular reason

Re: alias this and struct allocation

2019-05-06 Thread Alex via Digitalmars-d-learn
On Monday, 6 May 2019 at 14:48:56 UTC, faissaloo wrote: I've been having some memory issues (referenced objects turning to nulls for no apparent reason) and I was wondering if I've misunderstood how allocation works when instantiating a struct that uses alias this: import std.stdio;

Re: Mixin can't access library symbols?

2019-05-04 Thread Alex via Digitalmars-d-learn
On Friday, 3 May 2019 at 17:55:19 UTC, faissaloo wrote: On Friday, 3 May 2019 at 17:51:39 UTC, Adam D. Ruppe wrote: On Friday, 3 May 2019 at 17:48:50 UTC, faissaloo wrote: How can I get a mixin to implicitly include the symbols from its surrounding context? Is this possible? What's your big

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-02 Thread Alex via Digitalmars-d-learn
On Thursday, 2 May 2019 at 07:11:37 UTC, Robert M. Münch wrote: On 2019-05-01 19:13:54 +, Alex said: Doesn't work because this seems to kick in some D releated run-time stuff which lead to unresolved externals during linking: error LNK2001: Nicht aufgelöstes externes Symbol

Re: GtkD slows down visual D keyboard

2019-05-01 Thread Alex via Digitalmars-d-learn
On Friday, 26 April 2019 at 14:50:17 UTC, Mike Wey wrote: On 26-04-2019 10:31, Amex wrote: When debugging under visual D, the keyboard response is slowed down to the extreme. This is a Gtk issue I believe. It only has to do with the keyboard. For example, if I hit F10 to step, it takes the

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Alex via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 14:59:48 UTC, Robert M. Münch wrote: On 2019-05-01 14:23:37 +, Alex said: However, to rebuild the same structure, auto ref parameters may be appropriate. https://dlang.org/spec/template.html#auto-ref-parameters That would need me to change myfunc which is not

Re: What's best practice to use compound literals with structs and C-APIs?

2019-05-01 Thread Alex via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 12:47:22 UTC, Robert M. Münch wrote: I use some C library that uses structs and many functions that use pointer to structs as arguments: struct A {...}; myfunc(A *myA); In C you can do this to get a lvalue: myfunc(&(A){...}); In D this doesn't work and I get an

Determime actual modules used

2019-04-28 Thread Alex via Digitalmars-d-learn
I need to determine the actual modules that are used in the project, not just imported but ones that actually are referenced. Any utility exists to do this?

Re: Call delegate from C++

2019-04-25 Thread Alex via Digitalmars-d-learn
On Wednesday, 24 April 2019 at 16:20:17 UTC, Nicholas Wilson wrote: How do you pass a delegate to a c++ function to be called by it? The function to pass the delegate to is: extern (C++) int fakeEntrypoint( extern(C++) void function(void* /*delegate's context*/) func, void*

Re: alias fails to compile

2019-04-22 Thread Alex via Digitalmars-d-learn
On Monday, 22 April 2019 at 08:02:06 UTC, Arun Chandrasekaran wrote: What am I doing wrong here? struct A { union B { int bb; } B b; alias aa = b.bb; } void main() { A a = A(); // a.b.bb = 4; // works a.aa = 4; // fails } https://run.dlang.io/is/kXaVy2

Re: Inherit enum members

2019-04-21 Thread Alex via Digitalmars-d-learn
On Sunday, 21 April 2019 at 20:58:19 UTC, Andrey wrote: Hello, I have got 2 enums. How to inherit one enum from another? enum Key : string { K1 = "qwerty", K2 = "asdfgh" } enum ExtendedKey : Key { E1 = "q1", E2 = "w2", E3 = "e3" } Result: onlineapp.d(27): Error: cannot

Re: How to debug long-lived D program memory usage?

2019-04-19 Thread Alex via Digitalmars-d-learn
On Friday, 19 April 2019 at 03:27:04 UTC, Adam D. Ruppe wrote: On Friday, 19 April 2019 at 02:58:34 UTC, Alex wrote: Curious, what are these programs? A terminal emulator gui (like xterm), a detachable terminal emulator (like gnu screen), a slack client, an irc client, and a bunch of http

Re: How to debug long-lived D program memory usage?

2019-04-18 Thread Alex via Digitalmars-d-learn
On Wednesday, 17 April 2019 at 16:27:02 UTC, Adam D. Ruppe wrote: D programs are a vital part of my home computer infrastructure. I run some 60 D processes at almost any time and have recently been running out of memory. Each individual process eats ~30-100 MB, but that times 60 =

Re: Subtyping of an enum

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 20:36:09 UTC, Anton Fediushin wrote: On Monday, 15 April 2019 at 14:20:57 UTC, Alex wrote: On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote: Hello! I am currently trying to add a custom `toString` method to an enum so that: 1. Enum members would still

Re: Transparent cast from class to member pointer?

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 15:07:10 UTC, Robert M. Münch wrote: On 2019-04-15 08:19:57 +, Ali ‡ehreli Bingo, I didn't know that I can do an 'alias this' using a function and not only a type... pretty cool. So, with several of these I can setup implicit conversions to different types.

Re: Subtyping of an enum

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote: Hello! I am currently trying to add a custom `toString` method to an enum so that: 1. Enum members would still have numeric values and can be easily compared (things like `enum a { foo = "FOO", bar = "BAR”}` won't do, I want

Re: Subtyping of an enum

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote: Hello! I am currently trying to add a custom `toString` method to an enum so that: 1. Enum members would still have numeric values and can be easily compared (things like `enum a { foo = "FOO", bar = "BAR”}` won't do, I want

Re: Subtyping of an enum

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 13:38:33 UTC, Anton Fediushin wrote: This does work unless I want to use it like this: ``` fun(Enum.foo); --- Error: function fun(Enum e) is not callable using argument types (internal) cannot pass argument foo of type internal to parameter Enum e ``` This is

Re: Subtyping of an enum

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 10:15:50 UTC, Anton Fediushin wrote: On Monday, 15 April 2019 at 10:00:36 UTC, Alex wrote: Enum.internal is private to make it inaccessible from any other place. All I want is a way to have an enum that I could extend with my own methods. Something to make the

Re: Subtyping of an enum

2019-04-15 Thread Alex via Digitalmars-d-learn
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote: Hello! I am currently trying to add a custom `toString` method to an enum so that: 1. Enum members would still have numeric values and can be easily compared (things like `enum a { foo = "FOO", bar = "BAR”}` won't do, I want

Re: bug in compiles?

2019-04-12 Thread Alex via Digitalmars-d-learn
On Friday, 12 April 2019 at 09:43:01 UTC, Jacob Carlborg wrote: On 2019-04-11 20:13, Alex wrote: The following code works when I comment out the static if //static if (__traits(compiles, __traits(getAttributes, T)))    static foreach(a;  __traits(getAttributes, T)) Attributes ~= There

Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn
On Friday, 12 April 2019 at 00:02:36 UTC, Seb wrote: On Thursday, 11 April 2019 at 23:55:18 UTC, Alex wrote: to judge people objectively. This isn't a nursery school and we are not 3 year olds... Exactly. So start behaving like a grown-up and professional. When you ask someone for help on

Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn
On Thursday, 11 April 2019 at 23:04:46 UTC, Mike Parker wrote: On Thursday, 11 April 2019 at 22:41:32 UTC, Alex wrote: Seriously? Do you think you have ESP? Your code isn't even close to was talking about ;/ Here is is updated that shows the error. You seem to fail to understand that it

Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn
On Thursday, 11 April 2019 at 19:42:05 UTC, Steven Schveighoffer wrote: On 4/11/19 2:13 PM, Alex wrote: The following code works when I comment out the static if //static if (__traits(compiles, __traits(getAttributes, T)))    static foreach(a;  __traits(getAttributes, T)) Attributes ~=

Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn
On Thursday, 11 April 2019 at 20:49:45 UTC, bauss wrote: On Thursday, 11 April 2019 at 18:13:48 UTC, Alex wrote: The following code works when I comment out the static if //static if (__traits(compiles, __traits(getAttributes, T))) static foreach(a; __traits(getAttributes, T)) Attributes

bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn
The following code works when I comment out the static if //static if (__traits(compiles, __traits(getAttributes, T))) static foreach(a; __traits(getAttributes, T)) Attributes ~= There seems to be absolutely no reason why this code would fail with the static if but pass without it but in

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-10 Thread Alex via Digitalmars-d-learn
On Tuesday, 9 April 2019 at 21:00:55 UTC, H. S. Teoh wrote: On Tue, Apr 09, 2019 at 08:49:17PM +, Alex via Digitalmars-d-learn wrote: On Tuesday, 9 April 2019 at 18:56:58 UTC, H. S. Teoh wrote: [...] My point has been and is that there is a better way that is more natural. I make

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-10 Thread Alex via Digitalmars-d-learn
On Wednesday, 10 April 2019 at 02:19:42 UTC, Adam D. Ruppe wrote: On Tuesday, 9 April 2019 at 20:45:18 UTC, Alex wrote: On Tuesday, 9 April 2019 at 18:33:21 UTC, Seb wrote: Have you considered writing a DIP? No, because I expect it won't even be considered. You won't pass review if you

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-10 Thread Alex via Digitalmars-d-learn
On Wednesday, 10 April 2019 at 14:06:53 UTC, Adam D. Ruppe wrote: On Wednesday, 10 April 2019 at 10:18:35 UTC, H. S. Teoh wrote: [...] There's a little bit weird about it, but it makes sense. I used to find it hard to even remember how it works, but then I had to describe it for the book

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-09 Thread Alex via Digitalmars-d-learn
On Tuesday, 9 April 2019 at 18:56:58 UTC, H. S. Teoh wrote: On Tue, Apr 09, 2019 at 06:33:21PM +, Seb via Digitalmars-d-learn wrote: On Tuesday, 9 April 2019 at 16:30:53 UTC, Alex wrote: > On Tuesday, 9 April 2019 at 14:59:03 UTC, Adam D. Ruppe > wrote: > > [...] > I didn't say the

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-09 Thread Alex via Digitalmars-d-learn
On Tuesday, 9 April 2019 at 18:33:21 UTC, Seb wrote: On Tuesday, 9 April 2019 at 16:30:53 UTC, Alex wrote: On Tuesday, 9 April 2019 at 14:59:03 UTC, Adam D. Ruppe wrote: [...] I didn't say the language. The point with the language is that it could have built in semantics to do reflection in a

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-09 Thread Alex via Digitalmars-d-learn
On Tuesday, 9 April 2019 at 14:59:03 UTC, Adam D. Ruppe wrote: On Tuesday, 9 April 2019 at 14:42:38 UTC, Alex wrote: It basically proves my point that there are issues with D. The language is fine in this case, it is a bug in the library. I didn't say the language. The point with the

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-09 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 21:52:59 UTC, Adam D. Ruppe wrote: On Saturday, 6 April 2019 at 12:20:28 UTC, Alex wrote: Error: variable `std.traits.ParameterDefaults!(foo).Get!1u.Get` only parameters or stack based variables can be `inout` so i think that is a bug in the phobos library see:

Re: const of AliasSeq is silently ignored

2019-04-09 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 19:56:50 UTC, Yuxuan Shui wrote: In this example: const(AliasSeq!(int, int)) a; pragma(msg, typeof(a)); // (int, int) This kind of make sense, since AliasSeq is not a "single" type. But silently dropping const seems bad, the compiler should probably report

Re: Templates - What's Up with the template keyword?

2019-04-09 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:23:28 UTC, Ron Tarrant wrote: I'm digging into templates in an attempt to understand the signals-n-slots replacement for the observer pattern, but I've got a question I can't seem to find an answer for and an example for which I'm unable to solve the error.

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-08 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:26:28 UTC, Adam D. Ruppe wrote: On Sunday, 7 April 2019 at 17:42:58 UTC, Alex wrote: That is blatantly wrong. The code works EXACTLY the same way with and without using stringof. In some cases, yeah. In the general case, no. Your import hack* is only there

Re: What Does @ Mean?

2019-04-08 Thread Alex via Digitalmars-d-learn
On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: This is frustrating and makes me feel like a complete newb. Worse, it's impossible to search for. Ever try Googling a single character? The D documentation also doesn't seem to explain the meaning of this or any other token. Sure,

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-07 Thread Alex via Digitalmars-d-learn
On Sunday, 7 April 2019 at 15:35:46 UTC, FeepingCreature wrote: On Sunday, 7 April 2019 at 03:47:25 UTC, Alex wrote: rules are meant to be broken. No they're not! Almost by definition not! More comprehensively, if you break a rule you take responsibility for the outcome. You wanna use

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-07 Thread Alex via Digitalmars-d-learn
On Sunday, 7 April 2019 at 15:26:47 UTC, Adam D. Ruppe wrote: On Sunday, 7 April 2019 at 03:47:25 UTC, Alex wrote: What you need to tell me is why using .stringof is bad. You have simply conjured up a rule and are stating it but not giving any reason why it is not a good idea to follow when,

Re: CTFE & code generators based on PEG grammars?

2019-04-07 Thread Alex via Digitalmars-d-learn
On Sunday, 7 April 2019 at 06:39:05 UTC, zabruk wrote: On Sunday, 7 April 2019 at 03:32:45 UTC, Alex wrote: just execute them at CT if possible(and the possibility simply is if the inputs are known at CT). imho, Bastiaan Veelo want to say about citate above: not just "if possible", but "only

  1   2   3   4   5   6   >