Re: Druntime undefined references

2020-11-02 Thread drug via Digitalmars-d-learn
On 11/2/20 1:50 PM, Severin Teona wrote: Hi guys! I build the druntime for an ARM Cortex-M based microcontroller and I trying to create an application and link it with the druntime. I am also using TockOS[1], which does not implement POSIX thread calls and other OS-dependent implementations.

Re: Skipping or Stepping Through an Array?

2020-10-21 Thread drug via Digitalmars-d-learn
There are two other way: ```D import std; void main() { int[] a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]; // using foreach foreach (i; 0..a.length) write(a[i], ", "); writeln; // using stride writeln(stride(a, 2)); } ```

Re: GC-less string formatting

2020-10-20 Thread drug via Digitalmars-d-learn
On 10/20/20 9:42 AM, Per Nordlöw wrote: If I want GC-free string formatting and outputting to stdout/stderr what packages should I prefer at code.dlang.org? Probably https://code.dlang.org/packages/nogc

Re: question on dub and postgresql

2020-10-05 Thread drug via Digitalmars-d-learn
On 10/5/20 12:05 PM, Alaindevos wrote: On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote: On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: Can I say python has pip, ruby has bundle and D has dub. Meaning they perform

Re: help: cannot build profdump, dub error (bug): Enforcement failed

2020-09-29 Thread drug via Digitalmars-d-learn
On 9/29/20 4:38 PM, drug wrote: It reproduces. As a workaround you can use ``` dub run profdump ``` this command works as expected, I guess it is a bug of dub Do not execute this command in cloned `profdump` repository - it will fail too. It works if is called from other places, for example

Re: help: cannot build profdump, dub error (bug): Enforcement failed

2020-09-29 Thread drug via Digitalmars-d-learn
On 9/29/20 3:41 PM, mw wrote: I remember I used to able to build this package: https://github.com/AntonMeep/profdump but now, I cannot. Since that package haven't changed for 2 years, maybe it's a dub bug? System information $ uname -a Linux  4.15.0-117-generic #118-Ubuntu SMP Fri Sep 4

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread drug via Digitalmars-d-learn
On 9/18/20 4:30 PM, drug wrote: Can't you put a var on the stack? ``` auto instance = create(); instance     .do_lazy()     .do_something(); ``` Ah, I totally missed your point. Now I see you can't...

Re: Why is dtor called for lazy parameter?

2020-09-18 Thread drug via Digitalmars-d-learn
Can't you put a var on the stack? ``` auto instance = create(); instance .do_lazy() .do_something(); ```

Re: UDA inheritance

2020-09-10 Thread drug via Digitalmars-d-learn
On 9/10/20 4:06 PM, Joseph Rushton Wakeling wrote: Hello folks, Is there any way to define UDAs such that they automatically inherit other UDA definitions? For example, suppose I define:     enum BaseUDA { A, B } Is there a way to define `AnotherUDA` such that if `hasUDA!(T, AnotherUDA)`

Re: Where can I find the DEFINITION of vibe IOMode ??

2020-09-05 Thread drug via Digitalmars-d-learn
05.09.2020 23:19, Andy Balba пишет: https://github.com/vibe-d/eventcore/blob/a027c233c2542de8372bbff25d0a4804f32a094e/source/eventcore/driver.d#L1087 @drug: thank you..I'm now left with resolving @blocking you are welcome! Probably this?

Re: Where can I find the DEFINITION of vibe IOMode ??

2020-09-05 Thread drug via Digitalmars-d-learn
05.09.2020 22:17, Andy Balba пишет: Where do I fine where IOMode is defined..  as in the last line of ... module vibe.core.stream; import vibe.internal.traits : checkInterfaceConformance, validateInterfaceConformance; import vibe.internal.interfaceproxy; import core.time; import

Re: Install multiple executables with DUB

2020-09-04 Thread drug via Digitalmars-d-learn
On 9/4/20 10:27 AM, glis-glis wrote: On Thursday, 3 September 2020 at 14:34:48 UTC, Jacob Carlborg wrote: Oh, multiple binaries, I missed that. You can try to add multiple configurations [1]. Or if you have executables depending on only one source file, you can use single-file packages [2].

Re: Problem with gfm.math.matrix (some gamedevs out there ?)

2020-09-03 Thread drug via Digitalmars-d-learn
On 9/3/20 3:36 PM, Thomas wrote: Hi! I am following some examples in C++ about how OpenGL is working. There are great tutorials out there and most of it works also with D. For my code I am using gfm.math.matrix (Version 8.0.3) to be able to calculate the mouse position in a 3d world. Now I

Re: Unable to open filename passed as command line argument

2020-09-03 Thread drug via Digitalmars-d-learn
On 9/3/20 1:47 PM, Curious wrote: Given the following: =a== void main(string[] args) {     FILE* fp = fopen(args[1].ptr, "r");     if (!fp) throw new Exception("fopen"); } =b== void main(string[] args) {     FILE* fp = fopen(args[1].dup.ptr, "r");     if (!fp) throw new

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread drug via Digitalmars-d-learn
On 7/21/20 2:44 PM, Ecstatic Coder wrote: Ah thanks for telling me :) The loaded byte array in the union type was indeed the same as the saved one, so I immediately thought it was crashing because of some hidden pointer for timezone or something which was then pointing to garbage at

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread drug via Digitalmars-d-learn
On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime from the snapshot file to compare it with the current file

Re: Storing a reference to the calling object

2020-05-23 Thread drug via Digitalmars-d-learn
23.05.2020 12:27, Tim пишет: class Sprite{     /// Postional components of the sprite     int* x, y;     SDL_Surface* image_surface;     auto parent;     this(const char* path, auto parent){     writeln(*x);     this.parent = parent;     }     void update(){     // Copy

Re: Getting FieldNameTuple including all base-classes.

2020-05-20 Thread drug via Digitalmars-d-learn
On 5/20/20 12:03 PM, realhet wrote: On Wednesday, 20 May 2020 at 01:18:24 UTC, Paul Backus wrote: On Tuesday, 19 May 2020 at 23:15:45 UTC, realhet wrote: I think what you want is `std.meta.staticMap`. Something like this: alias FieldNameTuple2(T) = staticMap!(FieldNameTuple,

Re: How to get rid of "nothrow" ?

2020-05-18 Thread drug via Digitalmars-d-learn
On 5/18/20 11:47 PM, Vinod K Chandran wrote: On Sunday, 17 May 2020 at 19:37:05 UTC, drug wrote: 17.05.2020 17:35, Vinod K Chandran пишет: It worked. Thanks :) I have one more question. Which is better, to include all the switch cases inside a single try catch or write separate try catch

Re: How to get rid of "nothrow" ?

2020-05-17 Thread drug via Digitalmars-d-learn
17.05.2020 17:35, Vinod K Chandran пишет: It worked. Thanks :) I have one more question. Which is better, to include all the switch cases inside a single try catch or write separate try catch for each switch cases ? all the switch cases inside a single try catch is better

Re: Error running concurrent process and storing results in array

2020-05-07 Thread drug via Digitalmars-d-learn
07.05.2020 17:49, data pulverizer пишет: On Thursday, 7 May 2020 at 02:06:32 UTC, data pulverizer wrote: On Wednesday, 6 May 2020 at 10:23:17 UTC, data pulverizer wrote: D:  ~ 1.5 seconds This is going to sound absurd but can we do even better? If none of the optimizations we have so

Re: Error running concurrent process and storing results in array

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 13:23, data pulverizer пишет: On Wednesday, 6 May 2020 at 08:28:41 UTC, drug wrote: What is current D time? ... Current Times: D:  ~ 1.5 seconds Chapel: ~ 9 seconds Julia:  ~ 35 seconds Oh, I'm impressed. I thought that D time has been decreased by 1.5 seconds but it is

Re: Error running concurrent process and storing results in array

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 16:57, Steven Schveighoffer пишет: ``` foreach(i; 0..n) // instead of for(long i = 0; i < n;) ``` I guess that `proc` delegate cant capture `i` var of `foreach` loop so the range violation doesn't happen. foreach over a range of integers is lowered to an equivalent for loop, so

Re: How to port C++ std::is_reference to D ?

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 12:07, wjoe пишет: Hello, I'm choking on a piece of C++ I have no idea about how to translate to D.   template     typename std::enable_if< std::is_const::value == true, void>::type* = nullptr>     constexpr const char *modifier() const {     return "[in] ";     }  

Re: Error running concurrent process and storing results in array

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 11:18, data pulverizer пишет: CPU usage now revs up almost has time to touch 100% before the process is finished! Interestingly using `--boundscheck=off` without `--ffast-math` gives a timing of around 4 seconds and, whereas using `--ffast-math` without `--boundscheck=off` made no

Re: Error running concurrent process and storing results in array

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 10:42, data pulverizer пишет: On Wednesday, 6 May 2020 at 07:27:19 UTC, data pulverizer wrote: On Wednesday, 6 May 2020 at 06:54:07 UTC, drug wrote: Thing are really interesting. So there is a space to improve performance in 2.5 times :-) Yes, `array` is smart enough and if you call

Re: Error running concurrent process and storing results in array

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 09:43, data pulverizer пишет: On Wednesday, 6 May 2020 at 05:50:23 UTC, drug wrote: General advice - try to avoid using `array` and `new` in hot code. Memory allocating is slow in general, except if you use carefully crafted custom memory allocators. And that can easily be the

Re: Error running concurrent process and storing results in array

2020-05-06 Thread drug via Digitalmars-d-learn
06.05.2020 09:24, data pulverizer пишет: On Wednesday, 6 May 2020 at 05:44:47 UTC, drug wrote: proc is already a delegate, so is a pointer to the delegate, just pass a `proc` itself Thanks done that but getting a range violation on z which was not there before. ```

Re: Error running concurrent process and storing results in array

2020-05-05 Thread drug via Digitalmars-d-learn
06.05.2020 07:52, data pulverizer пишет: On Wednesday, 6 May 2020 at 04:04:14 UTC, Mathias LANG wrote: On Wednesday, 6 May 2020 at 03:41:11 UTC, data pulverizer wrote: Yes, that's exactly what I want the actual computation I'm running is much more expensive and much larger. It shouldn't matter

Re: Error running concurrent process and storing results in array

2020-05-05 Thread drug via Digitalmars-d-learn
06.05.2020 07:25, data pulverizer пишет: On Wednesday, 6 May 2020 at 03:56:04 UTC, Ali Çehreli wrote: On 5/5/20 8:41 PM, data pulverizer wrote:> On Wednesday, 6 May 2020 at 03:33:12 UTC, Mathias LANG wrote: >> On Wednesday, 6 May 2020 at 03:25:41 UTC, data pulverizer wrote: > Is there

Re: Error running concurrent process and storing results in array

2020-05-05 Thread drug via Digitalmars-d-learn
06.05.2020 06:25, data pulverizer пишет: ``` onlineapp.d(14): Error: template std.concurrency.spawn cannot deduce function from argument types !()(void delegate(double x, double y, long i, shared(double[]) z) pure nothrow @nogc @safe, double, double, long, shared(double[])), candidates are:

Re: sort a string

2020-05-01 Thread drug via Digitalmars-d-learn
01.05.2020 18:04, notna пишет: hmmm, whích results in:  Error: cannot use [] operator on expression of type dchar try this: ```D import std; void main() { string word = "Привет"; dchar[] line3 = to!(dchar[])(word.dup) // make a copy to get a range of mutable char

Re: sort a string

2020-05-01 Thread drug via Digitalmars-d-learn
01.05.2020 15:29, Steven Schveighoffer пишет: Don't do this, use to!(dchar[]) as you have above. This will create incorrect dchars for non-ascii text. -Steve Argh, as always you're right. Funny that I never did that and sadly that I posted wrong code. Thank you, Steven, for correction of

Re: sort a string

2020-05-01 Thread drug via Digitalmars-d-learn
01.05.2020 10:38, Chris Katko пишет: I'm making anagrams. According to the nextPermutation() docs, I need to 'sort by less' to get all permutations. ... Except the doc page doesn't mention how to do that, nor does std.algorithm.sort show how to sort a string. ... and the google results on the

Re: Help, what is the code mean?

2020-04-27 Thread drug via Digitalmars-d-learn
27.04.2020 18:28, data pulverizer пишет: I'm probably not the first person to say this but. Isn't @trusted an odd label to give unsafe functions and open to abuse by unscrupulous programmers? It almost says "nothing to see, this here piece of code is a-ok". Shouldn't it be explicitly labelled

Re: Idiomatic way to write a range that tracks how much it consumes

2020-04-26 Thread drug via Digitalmars-d-learn
27.04.2020 06:38, Jon Degenhardt пишет: Is there a better way to write this? --Jon I don't know a better way, I think you enlist all possible ways - get a value using either `front` or special range member. I prefer the second variant, I don't think it is less consistent with range

Re: GtkD - how to list 0..100K strings

2020-04-26 Thread drug via Digitalmars-d-learn
26.04.2020 11:06, mark пишет: snipped Sorry for offtopic, imho both Qt and Gtk are too complex in case of virtual list/tree view. I think the reason is they are retained mode gui. I gave up to use them for that and develop custom virtual tree view that is easy in use and currently capable

Re: Integration testing, unit-threaded, and threads

2020-04-23 Thread drug via Digitalmars-d-learn
23.04.2020 14:01, Russel Winder пишет: Hi, I need to start a process before the tests run, and terminate it after the tests run. A module with a shared static constructor and shared static destructor sounds like the way of doing this since the constructor is run before main and the destructor

Re: Integration testing, unit-threaded, and threads

2020-04-23 Thread drug via Digitalmars-d-learn
23.04.2020 14:41, drug пишет: terminate it after in `` terminate it after in `shutdown()`

[dmd] Types and ScopeDsymbol

2020-04-01 Thread drug via Digitalmars-d-learn
Is it true that user defined types are resolved to ScopeDsymbol and basic types aren't?

Re: assert expression in release mode

2020-03-23 Thread drug via Digitalmars-d-learn
On 3/23/20 2:14 PM, Steven Schveighoffer wrote: E.g. https://dlang.org/dmd-osx.html#switch-release There are also other switches like -boundscheck and -check. It’s possible you have some library or project that is causing the behavior. -Steve Thank you, Steve. In my case I guess it was

assert expression in release mode

2020-03-23 Thread drug via Digitalmars-d-learn
Before I lived in assurance that asserts are actual only in debug mode and in release mode they are nothing (except `assert(0)`). But today my whole life is going sour because I stumbled upon assert in release mode and of course that assert is failing. This doc

Re: What is the wrong with my C++ interfacing

2020-03-16 Thread drug via Digitalmars-d-learn
On 3/16/20 12:24 PM, Ferhat Kurtulmuş wrote: Ok, here is a solution. I opened my lib (yielded by my auxilary cpp) using 7zip. There are two files containing symbol names, 1.txt and 2.txt. I searched for names of member functions. They were not there because c++ compiler does not compile

Re: What is the wrong with my C++ interfacing

2020-03-16 Thread drug via Digitalmars-d-learn
On 3/16/20 10:11 AM, Ferhat Kurtulmuş wrote: On Sunday, 15 March 2020 at 22:25:27 UTC, Arine wrote: On Sunday, 15 March 2020 at 21:27:32 UTC, Ferhat Kurtulmuş extern(C++, cv){ extern(C++, class) struct Size_(_Tp){     @disable this(); ~this() { }     final _Tp area() const;     final

Re: What is the wrong with my C++ interfacing

2020-03-15 Thread drug via Digitalmars-d-learn
15.03.2020 23:53, Ferhat Kurtulmuş пишет: I doubt it because in https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d cpp code: Derived *createInstance(int i) d code: extern (C++){     ...     Derived createInstance(int i); } Ah, really, you use classes on D side.

Re: What is the wrong with my C++ interfacing

2020-03-15 Thread drug via Digitalmars-d-learn
15.03.2020 23:25, Ferhat Kurtulmuş пишет: On Sunday, 15 March 2020 at 20:21:57 UTC, drug wrote: 15.03.2020 22:39, Ferhat Kurtulmuş пишет: What is the D version of `createSizeIntWH`? In C++ it returns a pointer but in D version it returns an instance. extern(C++){     cv.Size_!int

Re: What is the wrong with my C++ interfacing

2020-03-15 Thread drug via Digitalmars-d-learn
15.03.2020 22:39, Ferhat Kurtulmuş пишет: The original C++ class https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/types.hpp#L315: template class Size_ { public:     typedef _Tp value_type;     //! default constructor     Size_();     Size_(_Tp _width, _Tp

Re: 2d graphic and multimedia

2020-03-12 Thread drug via Digitalmars-d-learn
On 3/12/20 7:33 AM, Noor Wachid wrote: I usually go with SFML (C++) library to write simple visualization. Is there any similiar library in D? https://code.dlang.org/packages/dsfml

betterC main() linkage

2020-03-07 Thread drug via Digitalmars-d-learn
the specification says that in betterC mode the main function should have extern(C) linkage. Accidentally I found that dmd does not demand it in contrast to ldc. Is it bug of dmd or the specification can be relaxed?

Re: use of struct vs class

2020-03-07 Thread drug via Digitalmars-d-learn
07.03.2020 15:58, Steven Schveighoffer пишет: Hm... I'd say: 1. Don't use a pointer for the element. Just use the struct directly. Using a pointer is bad because it's now going to compare pointers, and not the element data. Not only that, but RBNodes are stored as heap-allocated structs, so

Re: Trying to understand a simple piece of code: dmd barray

2020-03-07 Thread drug via Digitalmars-d-learn
07.03.2020 15:05, Dibyendu Majumdar пишет: Hi, I am trying to understand https://github.com/dlang/dmd/blob/master/src/dmd/backend/barray.d. Two questions: 1. What does this mean and why is it needed? line 95: alias array this; This means that `array` can be used instead of `this` 2. The

Re: use of struct vs class

2020-03-07 Thread drug via Digitalmars-d-learn
07.03.2020 13:58, mark пишет: change #1:     if (line.empty) {     if (deb != null && deb.valid)     debs.insert(deb);     else // report incomplete     deb = null;     continue;   

Re: use of struct vs class

2020-03-07 Thread drug via Digitalmars-d-learn
07.03.2020 13:20, mark пишет: I have this struct (with details omitted [ snip ] Should Deb be a class rather than a struct? Do you consider using pointers in AA: ``` Deb*[string] debForName; ```

Re: Safe cast

2020-03-06 Thread drug via Digitalmars-d-learn
It's too complex On 3/6/20 3:45 PM, Виталий Фадеев wrote: On Friday, 6 March 2020 at 12:35:29 UTC, Виталий Фадеев wrote: Searching info for object casting with checking class type at runtime. Like this: class A {     // } class B {     int bVar; } unittest {     A a = new A();     A x =

Re: converting to/from char[]/string

2020-03-05 Thread drug via Digitalmars-d-learn
On 3/5/20 2:03 PM, mark wrote: I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt The main public function's signature is: char[] stem(char[] p, int i, int j) But I work entirely in terms of strings (containing

Re: What does assigning void mean?

2020-03-05 Thread drug via Digitalmars-d-learn
On 3/5/20 10:47 AM, mark wrote: In Adam Ruppe's D Cookbook there're these lines in a ref counting example: RefCountedObject o = void; // What does this mean/do? o.data = new Implementation(); o.data.refcount = 1; I don't understand the first line; could someone explain please? In D all vars

Re: Call method if declared only

2020-02-28 Thread drug via Digitalmars-d-learn
On 2/28/20 12:25 PM, Виталий Фадеев wrote: Now I reading Template doc for up skill... I recommend this nice tutorial https://github.com/PhilippeSigaud/D-templates-tutorial

Re: preset counter variable in a for loop --> 'has no effect' Error

2020-02-28 Thread drug via Digitalmars-d-learn
On 2/28/20 11:48 AM, Namal wrote: Hello, I don't understand why this simple code causes a compiler error.. import std.stdio; void main(){  int b = 0;  for (b; b<3; b++){    writeln(b);  } } $Error: b has no effect Same works perfectly fine in C++ #include int main(){  int i = 0;

is(typeof(...)) vs __traits(compiles, ...)

2020-02-21 Thread drug via Digitalmars-d-learn
Currently this code does not compiles: ``` unittest { class MyClass { T opCall(T)(T p) { return p; } } import std.container.array : Array; Array!MyClass arr; } ``` but if you comment out `opCall` in MyClass this code compiles. This is

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread Drug via Digitalmars-d-learn
On Saturday, 8 February 2020 at 23:37:56 UTC, realhet wrote: Hello, class A{ int i = 42; } Is there a way to get that 42? (Input is the class A and the name of the field 'i') A.i.init returns 0, so it doesn't care about the class. classinfo.m_init can be an option, but maybe there's a

Re: Deprecation message from phobos compiling a vibe.d app.

2020-01-30 Thread drug via Digitalmars-d-learn
On 1/30/20 2:50 PM, Martin Tschierschke wrote: When building my small vibe.d app I am getting this messages twice: /usr/include/dmd/phobos/std/range/primitives.d(174,38): Deprecation: alias byKeyValue this is deprecated - Iterate over .byKeyValue instead.

Re: Call of C function breaks memoty layout

2020-01-24 Thread drug via Digitalmars-d-learn
On 1/24/20 4:37 PM, Andrey wrote: Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I

Re: sdl 2 - text is not displayed correctly

2020-01-15 Thread drug via Digitalmars-d-learn
On 1/15/20 6:26 PM, TodNaz wrote: Hello! Maybe someone came across ... I use sdl 2 derelcit, and wanted to draw text (not English, but Russian, for example). And when called in TTF_RenderUTF8_Blended, the text is drawn with incorrect characters (with these: ""). And with wstribg and

Re: Tour: unneeded import

2020-01-13 Thread drug via Digitalmars-d-learn
On 1/13/20 3:11 PM, drug wrote: On 1/13/20 2:45 PM, mark wrote: In the D tour example shown here https://tour.dlang.org/tour/en/basics/ranges there is the following import: import std.range : drop, generate, take; But generate is not used so I think it ought to be deleted to avoid confusion.

Re: Tour: unneeded import

2020-01-13 Thread drug via Digitalmars-d-learn
On 1/13/20 2:45 PM, mark wrote: In the D tour example shown here https://tour.dlang.org/tour/en/basics/ranges there is the following import: import std.range : drop, generate, take; But generate is not used so I think it ought to be deleted to avoid confusion. done -

Re: Algebraic and implicit conversions

2020-01-06 Thread drug via Digitalmars-d-learn
06.01.2020 22:48, Steven Schveighoffer пишет: I think his question is, why shouldn't this work? e.g., this works: Ah, indeed. Sorry for noise.

Re: Algebraic and implicit conversions

2020-01-06 Thread drug via Digitalmars-d-learn
06.01.2020 20:08, Per Nordlöw пишет: alias A = Algebraic!(long, string);     A x;     x = 42; That's because you try to assign int, not long. This works: alias A = Algebraic!(long, string); A x; x = 42L;

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-22 Thread drug via Digitalmars-d-learn
On 12/23/19 10:16 AM, Soulsbane wrote: On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: There are lots of editors/IDE's that support D language: https://wiki.dlang.org/Editors What kind of editor/IDE are you using and which one do you like the most? VSCode with this extension:

Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread drug via Digitalmars-d-learn
On 12/11/19 6:52 PM, Pavel Shkadzko wrote: It works like this, yes. However, by default it builds a "library" while I want to run "evaluator" as a script which uses other scripts by calling their functions. Doing: dub --compiler=ldc2 --single evaluator.d // throws an error

Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread drug via Digitalmars-d-learn
On 12/11/19 2:18 PM, Pavel Shkadzko wrote: I have the following project structure. my_proj/     script_1/runme_1.d     script_2/runme_2.d     evaluator.d The project has a library dependency: "dependencies": {     "mir": "~>3.2.0", }, The "evaluator.d" script contains some general

Re: Confusion Concerning Numerical Equation

2019-11-16 Thread drug via Digitalmars-d-learn
16.11.2019 13:01, Avery Stupidman пишет: Hello, I have a function "angle" that returns the angle (in degrees) of a right triangle given the length of the its lengths as type "real". It works, but when trying to test the equality of the angle with the seemingly identical value, I'm informed

[DTrace probe] is there a [portable] way to add section to elf executable?

2019-10-23 Thread drug via Digitalmars-d-learn
I'd like to add (and modify) section to ELF executable to implement DTrace probes. DTrace does it in probe assembly: ``` __asm__ __volatile__ ( "990: nop .pushsection .note.stapsdt,\"?\",\"note\" .balign 4 .4byte 992f-991f, 994f-993f, 3 991: .asciz

Re: struct Foo may not define both a rvalue constructor and a copy constructor

2019-10-16 Thread drug via Digitalmars-d-learn
On 10/16/19 6:40 PM, rikki cattermole wrote: On 17/10/2019 4:29 AM, drug wrote: struct Foo { this(ref const(Foo) other) {} this(const(Foo) other) {} } I'm trying to update dmd version and starting from 2.086 my code doesn't compile due to the error above. What is the reason of that?

struct Foo may not define both a rvalue constructor and a copy constructor

2019-10-16 Thread drug via Digitalmars-d-learn
struct Foo { this(ref const(Foo) other) {} this(const(Foo) other) {} } I'm trying to update dmd version and starting from 2.086 my code doesn't compile due to the error above. What is the reason of that? Is it temporarily situation?

Re: C#'s 'is' equivalent in D

2019-10-10 Thread drug via Digitalmars-d-learn
On 10/10/19 6:47 PM, Just Dave wrote: In C# you can do something like:     if (obj is Person)     {     var person = obj as Person;     // do stuff with person...     } where you can check the type of an object prior to casting. Does D have a similar mechanism? It's so widely

Re: Packaging and Distributing Dlang Applications with GtkD Dependency?

2019-09-28 Thread drug via Digitalmars-d-learn
28.09.2019 5:15, Hossain Adnan пишет: On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant wrote: Hi y'all, I've been Googling how to do this, but coming up with nothing definitive. Are there any articles for how to do this for: Linux? For Linux there are 3 new options: 1.

Re: Inspecting __traits(isDeprecated) and deprecation warnings

2019-09-26 Thread drug via Digitalmars-d-learn
On 9/25/19 11:35 PM, Boris Carvajal wrote: On Wednesday, 25 September 2019 at 14:20:00 UTC, Anonymouse wrote: I added some deprecations in my project and am going through my templates trying to silence the warnings that suddenly popped up. This template works, but it triggers deprecation

Re: getting rid of immutable (or const)

2019-09-05 Thread drug via Digitalmars-d-learn
05.09.2019 17:31, berni пишет: On Thursday, 5 September 2019 at 13:27:55 UTC, drug wrote: [...]when you put it into an AA you modify old value Why?!? :-o When putting it into an AA it will be copied to a different place in memory, but the value is still the same, it's not modified. Sorry,

Re: getting rid of immutable (or const)

2019-09-05 Thread drug via Digitalmars-d-learn
05.09.2019 15:46, berni пишет: On Thursday, 5 September 2019 at 12:15:51 UTC, drug wrote: One solution could be using either pointer to `const(Point)` or class here (to avoid pointer using) https://run.dlang.io/is/rfKKAJ OK. This are two solutions and although I'll probably not going to use

Re: getting rid of immutable (or const)

2019-09-05 Thread drug via Digitalmars-d-learn
05.09.2019 14:28, berni пишет: On Thursday, 5 September 2019 at 11:22:15 UTC, drug wrote: 05.09.2019 14:17, berni пишет: Point[long] q; q[1] = Point(3); Leads to: test.d(7): Error: cannot modify struct q[1L] Point with immutable members But why do you try to modify immutable data? What

Re: getting rid of immutable (or const)

2019-09-05 Thread drug via Digitalmars-d-learn
05.09.2019 14:17, berni пишет: Point[long] q; q[1] = Point(3); Leads to: test.d(7): Error: cannot modify struct q[1L] Point with immutable members But why do you try to modify immutable data? What is your point? Could you describe you use case?

Re: How to get name of my application (project)

2019-08-03 Thread drug via Digitalmars-d-learn
03.08.2019 12:26, Andrey пишет: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? You can get it using $DUB_PACKAGE from Environment variables (https://dub.pm/package-format-sdl), for example using

Re: How to contact people on the forum

2019-07-24 Thread drug via Digitalmars-d-learn
24.07.2019 18:51, Greatsam4sure пишет: Good day everyone. I am thinking,  if there is a  way to contact any person on dlang forums through mail or any other means. How do I get their email from their forum post? I use thunderbird to read the forum and every post contains email of its author,

Re: Return the complete number

2019-07-24 Thread drug via Digitalmars-d-learn
24.07.2019 18:45, Greatsam4sure пишет: int main(){  double mum = 0;  Write("enter a number: ")  readf(" %s\n",);  Writeln(num); } How do I return the complete number the user enter since I don't since the user can enter numbers of various length with dmd approximating it. I will

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
22.07.2019 17:19, drug пишет: 22.07.2019 16:26, Guillaume Piolat пишет: Typical floating point operations in single-precision like a simple (a * b) + c will provide a -140dB difference if order is changed. It's likely the order of operations is not the same in your program, so the least

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
22.07.2019 16:26, Guillaume Piolat пишет: Typical floating point operations in single-precision like a simple (a * b) + c will provide a -140dB difference if order is changed. It's likely the order of operations is not the same in your program, so the least significant digit should be

Re: accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
22.07.2019 15:53, rikki cattermole пишет: https://godbolt.org/z/EtZLG0 hmm, in short - this is my local problem?

accuracy of floating point calculations: d vs cpp

2019-07-22 Thread drug via Digitalmars-d-learn
I have almost identical (I believe it at least) implementation (D and C++) of the same algorithm that uses Kalman filtering. These implementations though show different results (least significant digits). Before I start investigating I would like to ask if this issue (different results of

Re: Using output-range overloads of SysTime.toISO{Ext}String with formatting code

2019-07-07 Thread drug via Digitalmars-d-learn
07.07.2019 17:49, Joseph Rushton Wakeling пишет: it's possible to do something like `writefln!"%s"(now.toISOExtString)` and have it automatically use the output range overload rather than allocating a new string instance. This is exactly how it is intended to work:

Re: Create empty SList or DList.

2019-06-26 Thread drug via Digitalmars-d-learn
26.06.2019 20:39, bauss пишет: auto stack = SList!int(0); stack.removeFront(); Then something that just allowed you to do: auto stack = SList!int; this compiles: ``` auto stack = SList!int(); ```

Re: The problem with the conversion.

2019-06-19 Thread drug via Digitalmars-d-learn
19.06.2019 17:52, Den_d_y пишет: void load (const (char *) path) {     SDL_Surface ab = SDL_LoadBMP (path);     a = SDL_CreateTextureFromSurface (ab);     SDL_FreeSurface (ab); } try the following: ``` void load (string path) { import std.string : toStringz; SDL_Surface ab =

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread drug via Digitalmars-d-learn
01.06.2019 15:55, drug пишет: Is there a type-safe way to do this? If this were a class, I'd try std.typecons.Rebindable. Ah, sorry))

Re: How to create an overwriteable struct that is always const?

2019-06-01 Thread drug via Digitalmars-d-learn
01.06.2019 15:51, David Zhang пишет: Say I have a struct `S`:     struct S {     /*const*/ char* pointer;     ... other members ...     this(/*const*/ char* p, ... others ...) {     pointer = p;     ...     }     } What I want, is to be able to use `S`

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

2019-05-17 Thread drug via Digitalmars-d-learn
On 17.05.2019 14:39, Ron Tarrant wrote: On Friday, 17 May 2019 at 11:12:41 UTC, Alex wrote: ListStore and TreeStore and how they interact with TreeView and ComboBox via TreeIter, TreeSelection, etc., etc. That's taking most of my time ATM. That would be really nice! My use case is a large list

Re: Creating a RedBlackTree

2019-05-15 Thread drug via Digitalmars-d-learn
On 15.05.2019 16:08, Bogdan wrote: I don't have any experience with using templates. Is it possible to create a RB tree containing structs, where the nodes are ordered by one struct member? ``` import std.stdio; import std.container; enum KeyID: uint { KEY_A, KEY_S, KEY_D,    

Re: Operator Overloading with multiple return types

2019-03-15 Thread drug via Digitalmars-d-learn
16.03.2019 1:30, eXodiquas пишет: On Friday, 15 March 2019 at 21:46:50 UTC, Ali Çehreli wrote: On 03/15/2019 02:43 PM, Sebastiaan Koppe wrote: On Friday, 15 March 2019 at 21:35:12 UTC, eXodiquas wrote: Is there any way to achive this behaivour with D2? Yep. Just make the return type in the

Re: InsertBefore in DList of structs

2019-03-05 Thread drug via Digitalmars-d-learn
On 05.03.2019 2:01, r-const-dev wrote: Thanks, seems that using dataPoints[] makes dataPoints usable as an range. How can I learn more about [] operator? I'm not sure I understand how is this documented in DList. dataPoints is an aggregate type variable, not a range and slice operator

Re: InsertBefore in DList of structs

2019-03-04 Thread drug via Digitalmars-d-learn
On 04.03.2019 13:03, drug wrote: insertStable needs DList.Range, not Until!... one. You can do something like this https://run.dlang.io/is/A2vZjW Oops, it was wrong example, I'd recommend this way - https://run.dlang.io/is/ugPL8j ``` import std.algorithm, std.container, std.stdio; struct

Re: InsertBefore in DList of structs

2019-03-04 Thread drug via Digitalmars-d-learn
On 04.03.2019 11:14, r-const-dev wrote: I have a DList of structs, DataPoint, ordered by a struct field, time. I'm trying to insert a new entry preserving order, so I'm trying to use `until` to find the insertion point and `insertBefore` with the result. struct DataPoint {     immutable

Re: Disable dub from checking internet before building

2019-02-24 Thread drug via Digitalmars-d-learn
On 25.02.2019 1:51, 0x wrote: How to disable dub from checking internet before building, it's slowing down build whenever it does this. `--skip-registry=all` let you avoid checking of all dependencies (https://dub.pm/commandline)

  1   2   3   4   >