Re: struct parameterless constructor

2025-08-04 Thread Alex Bryan via Digitalmars-d-learn
On Monday, 4 August 2025 at 20:02:48 UTC, Brother Bill wrote: I feel like I am going into the hornet's nest with this discussion. I have created a struct with some members, and want to have a parameterless constructor that sets the member values at run time. I have seen things like @disable

Re: Build fully static library by the compiler?

2024-08-09 Thread Alex Bryan via Digitalmars-d-learn
On Friday, 9 August 2024 at 02:34:03 UTC, Denis Feklushkin wrote: We can build static library directly from the compiler: $ ldc2 --lib app.d produces app.a file with app.o inside of it. Are there simple way to make a static library that also includes necessary standard D libraries (i.e., phob

Re: How to make project with main application and cli application in the same folder?

2024-04-25 Thread alex via Digitalmars-d-learn
On Sunday, 21 April 2024 at 16:41:08 UTC, Mike Parker wrote: On Sunday, 21 April 2024 at 08:44:38 UTC, alex wrote: Hi guys. Trying to play with vibe-d and want to create separate web app, and cli app which can add admin users. When I just keep both files app.d and cli.d in source folder, I get

How to make project with main application and cli application in the same folder?

2024-04-21 Thread alex via Digitalmars-d-learn
Hi guys. Trying to play with vibe-d and want to create separate web app, and cli app which can add admin users. When I just keep both files app.d and cli.d in source folder, I get an error that I can't have more then 1 main function. I already asked chatGPT, and it replied that I need to use

Re: How to set include paths of a c source in dub when using importc

2024-04-16 Thread Alex Bryan via Digitalmars-d-learn
If you're not using gdc exclusively, you'll want to take a look at this: https://github.com/dlang/dub/pull/2818

Re: Multiple destructors

2023-05-26 Thread Alex Biscotti via Digitalmars-d-learn
On Friday, 26 May 2023 at 09:49:21 UTC, Ernesto Castellotti wrote: Currently the spec says "If the name of a declaration in a mixin is the same as a declaration in the surrounding scope, the surrounding declaration overrides the mixin one", I understand why this occurs with the current implemen

Re: Multiple destructors

2023-05-26 Thread Alex Biscotti via Digitalmars-d-learn
On Friday, 26 May 2023 at 09:24:29 UTC, Ernesto Castellotti wrote: On Friday, 26 May 2023 at 09:17:34 UTC, Alex Biscotti wrote: On Friday, 26 May 2023 at 09:11:47 UTC, Ernesto Castellotti wrote: On Friday, 26 May 2023 at 09:07:07 UTC, Alex Biscotti wrote: Hello everyone! While researching the

Re: Multiple destructors

2023-05-26 Thread Alex Biscotti via Digitalmars-d-learn
On Friday, 26 May 2023 at 09:11:47 UTC, Ernesto Castellotti wrote: On Friday, 26 May 2023 at 09:07:07 UTC, Alex Biscotti wrote: Hello everyone! While researching the phobos library, I discovered that a class can have multiple destructors if the destructors are added via mixin injection

Multiple destructors

2023-05-26 Thread Alex Biscotti via Digitalmars-d-learn
Hello everyone! While researching the phobos library, I discovered that a class can have multiple destructors if the destructors are added via mixin injection. Accordingly, the question is whether a description of such feature should be added to the documentation, since the current description

Re: regex matching but not capturing

2023-04-06 Thread Alex Bryan via Digitalmars-d-learn
On Thursday, 6 April 2023 at 15:52:16 UTC, Paul wrote: My regex is matching but doesnt seem to be capturing. You may recognize this from the AOC challenges. file contains... **Valve AA has flow rate=0; tunnels lead to valves DD, II, BB** **Valve BB has flow rate=13; tunnels lead to valves CC,

MMFile usage

2022-08-03 Thread Alex Burton via Digitalmars-d-learn
data. Or I have to .dup the data, causing memory allocation in addition to the paging to get the data in the first place. Is this special memory not managed by the GC ? Do I need to keep all the MmFile references around to avoid segfaults ? Alex

Re: Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread Alex Bryan via Digitalmars-d-learn
On Sunday, 12 September 2021 at 02:49:48 UTC, jfondren wrote: On Sunday, 12 September 2021 at 02:44:36 UTC, Alex Bryan wrote: `T[] dynArr` can be passed (by reference) to a function that takes `ref T[] data` but `T[10] data` cannot? Why not? ```d void add1(ref int[] nums) { nums ~= 1

Re: Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread Alex Bryan via Digitalmars-d-learn
On Sunday, 12 September 2021 at 01:48:07 UTC, H. S. Teoh wrote: On Sun, Sep 12, 2021 at 01:08:17AM +, Alex Bryan via Digitalmars-d-learn wrote: I am having trouble discovering what the proper (or at least a proper) way is to write a function that can take either a static or dynamic array

Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread Alex Bryan via Digitalmars-d-learn
I am having trouble discovering what the proper (or at least a proper) way is to write a function that can take either a static or dynamic array as a parameter. My current implementation consists of 2 overloaded functions (one takes a dynamic array, the other takes a static array) with 99% copy

How to connect to SQLITE?

2020-11-28 Thread Alex NL via Digitalmars-d-learn
Is there libs for SQLITE? How to use it? thanks.

Re: Type sniffing at runtime

2020-05-15 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 y

Re: need help to get member function const address

2020-03-18 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 funct

Re: range algorithms on container class

2020-01-14 Thread Alex Burton via Digitalmars-d-learn
On Thursday, 9 January 2020 at 10:26:07 UTC, Jonathan M Davis wrote: On Wednesday, January 8, 2020 10:56:20 PM MST rikki cattermole via Digitalmars-d-learn wrote: Slicing via the opSlice operator overload is a convention, not a requirement. It's not a requirement, but it's more than a conventi

range algorithms on container class

2020-01-08 Thread Alex Burton via Digitalmars-d-learn
I am writing a specialised container class, and want to make it work like a normal array with range functions. After some struggle, I look at the code for std.container.array and see this comment : When using `Array` with range-based functions like those in `std.algorithm`, * `Array` must be

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 fir

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] = [&f1, &f2] } What I got: Error: non-constant expression '&f1' 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 t

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 couldn't

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 &this.onProcessCb of type extern (C) bool delegate(const(short*) a, ulong b, void* c) to extern (C) bool functi

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-01 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 lo

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() { getT!(typeof(

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 ins

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 hav

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 non-abstract

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. https://dlang.org/sp

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 be

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 anythin

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 an

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 th

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
. It would be good if there was a way of either void initialing it so that the first memset is avoided or a way of replacing the init value with a different one. Thanks, Alex

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 i

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. https://dlang.org/library/std/algorithm/searching/fi

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(); t

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 "iterator

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 dete

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 write

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 write

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 intrin

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, lookup

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. Ju

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) ... X.a

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 s

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)) arr.each!(el

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 but

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 realiz

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 = st

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

2019-05-17 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 n

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 co

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 goin

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

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 di

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 ho

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 fo

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 p

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 id

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 "i

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* /*delegate

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 imp

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 = trouble

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. Th

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 `a.fo

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 `a.fo

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 corr

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 `a.fo

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 he

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 th

  1   2   3   4   5   6   7   8   9   >