Re: Directory recursive walking

2021-01-14 Thread drug via Digitalmars-d-learn
On 1/14/21 7:06 PM, dog2002 wrote: On Thursday, 14 January 2021 at 16:01:43 UTC, drug wrote: On 1/14/21 6:55 PM, drug wrote: But this method consumes a huge amount of memory (up to 4 GB and more). Is there a more appropriate way to walk directories recursively that does not consume a lot of

Re: Directory recursive walking

2021-01-14 Thread drug via Digitalmars-d-learn
On 1/14/21 7:30 PM, dog2002 wrote: On Thursday, 14 January 2021 at 16:18:28 UTC, drug wrote: On 1/14/21 7:06 PM, dog2002 wrote: On Thursday, 14 January 2021 at 16:01:43 UTC, drug wrote: [...] Yes. I forgot to add it in the original post. Does using `ref` changed anything? Try following: ``

Re: Directory recursive walking

2021-01-14 Thread drug via Digitalmars-d-learn
On 1/14/21 7:06 PM, dog2002 wrote: On Thursday, 14 January 2021 at 16:01:43 UTC, drug wrote: On 1/14/21 6:55 PM, drug wrote: But this method consumes a huge amount of memory (up to 4 GB and more). Is there a more appropriate way to walk directories recursively that does not consume a lot of

Re: Convert double to long if lossless

2021-01-19 Thread drug via Digitalmars-d-learn
On 1/19/21 4:48 PM, Per Nordlöw wrote: On Tuesday, 19 January 2021 at 13:36:58 UTC, Steven Schveighoffer wrote: Use a cast instead. const lvalue = cast(long)value; Ahh, good point. Followd by a compare of the original value I presume. don't forget to check by std.math.isFinite before casti

Re: Convert double to long if lossless

2021-01-19 Thread drug via Digitalmars-d-learn
On 1/19/21 5:04 PM, drug wrote: On 1/19/21 4:48 PM, Per Nordlöw wrote: On Tuesday, 19 January 2021 at 13:36:58 UTC, Steven Schveighoffer wrote: Use a cast instead. const lvalue = cast(long)value; Ahh, good point. Followd by a compare of the original value I presume. don't forget to check

Re: Convert double to long if lossless

2021-01-19 Thread drug via Digitalmars-d-learn
On 1/19/21 6:50 PM, Ali Çehreli wrote: On 1/19/21 6:04 AM, drug wrote: > Another (low level) way is to shift mantissa left by exponent value. Luckily, we already have a helper in Phobos:   https://dlang.org/phobos/std_bitmanip.html#FloatRep Ali That makes life simpler, thanks for sharing

Re: Convert double to long if lossless

2021-01-20 Thread drug via Digitalmars-d-learn
On 1/19/21 9:28 PM, Per Nordlöw wrote: On Tuesday, 19 January 2021 at 16:14:17 UTC, drug wrote:    https://dlang.org/phobos/std_bitmanip.html#FloatRep Doesn't this pattern already cover all possible cases of `value` needed? void f(double value) {     auto lvalue = cast(long)value;     if (l

Using mir to work with matrices

2021-01-26 Thread drug via Digitalmars-d-learn
It is not easy to understand what mir library one should use to work with matrices. mir-glas turns out unsupported now and I try to use mir-blas. I need to reimplement my Kalman filter version to use more high dimension matrix than 4x4 plus Kronecker product. Is mir-blas recommended to work wit

Re: Using mir to work with matrices

2021-01-29 Thread drug via Digitalmars-d-learn
On 1/29/21 4:50 PM, 9il wrote: On Tuesday, 26 January 2021 at 14:43:08 UTC, drug wrote: It is not easy to understand what mir library one should use to work with matrices. mir-glas turns out unsupported now and I try to use mir-blas. I need to reimplement my Kalman filter version to use more h

Re: Using mir to work with matrices

2021-02-01 Thread drug via Digitalmars-d-learn
On 1/29/21 8:20 PM, 9il wrote: On Friday, 29 January 2021 at 15:35:49 UTC, drug wrote: Between is there a plan to implement some sort of static slice where the lengths of the dimensions are known in compile time? Compiler help is very useful. No. BLAS/LAPACK API's can't use compile-time infor

Re: Profiling

2021-02-09 Thread drug via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote: I was trying to profile a d program. So I ran: dub build --build=profile. I then ran the program and it produced trace.log and trace.def. I then ran d-profile-viewer and got the following error: std.conv.ConvException@/home/jg/dlang/ldc-1

Re: Profiling

2021-02-10 Thread drug via Digitalmars-d-learn
On 2/10/21 2:52 PM, JG wrote: On Tuesday, 9 February 2021 at 18:33:16 UTC, drug wrote: On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote: I was trying to profile a d program. So I ran: dub build --build=profile. I then ran the program and it produced trace.log and trace.def. I then ran d-p

Re: Can't call splitter with range struct

2021-03-16 Thread drug via Digitalmars-d-learn
On 3/16/21 1:58 AM, David Skluzacek wrote: > > Error: template std.algorithm.iteration.splitter cannot deduce function from argument types !()(GZippedFile, string), candidates are: > /usr/include/dlang/dmd/std/algorithm/iteration.d(4678): splitter(alias pred = "a == b", Range, Separator)(Range r

Re: How to parse JSON in D?

2021-03-29 Thread drug via Digitalmars-d-learn
I use asdf https://code.dlang.org/packages/asdf Also vibe-d https://code.dlang.org/packages/vibe-d has vibe-d:data subpackage

[OT]

2021-04-02 Thread drug via Digitalmars-d-learn
02.04.2021 15:06, Ali Çehreli пишет: For those who prefer a video description with some accent :) here is how What about accent - I'm curious what would you say about this old Russian sketch about English and its dialects (in English, no facebook account required): https://www.facebook.co

Re: Iteratable single linked list of floats.

2021-04-21 Thread drug via Digitalmars-d-learn
21.04.2021 16:19, Alain De Vos пишет: import std.stdio; void main(){ struct List {     struct Node {     float f;     Node *next;     }     Node * root=null;     bool empty() const {return !root;}     void popFront() {root=root.next;}     f

Re: Question about property & method access scope.

2021-05-11 Thread drug via Digitalmars-d-learn
11.05.2021 12:10, Vinod K Chandran пишет: Hi all, I am practising D with a win api GUI hobby project. I have a Window class and it resides in module window.d My WndProc function resides in another module named wnd_proc_module.d Inside my WndProc, I get the Window class like this. ```d Window win

Re: Is inc function part of the library ?

2021-05-13 Thread drug via Digitalmars-d-learn
13.05.2021 16:30, Alain De Vos пишет: Shouldn't the compiler error it is not pure ? Or have I a wrong understanding of pure or the compiler. The function is pure. If you call it several times passing the same argument it will return the same result. https://run.dlang.io/is/futqjP

Re: gtkd ,drawingarea, capture mouse pressed

2021-05-21 Thread drug via Digitalmars-d-learn
21.05.2021 15:39, Alain De Vos пишет: I'll have a look at that website. With this code I capture the mouse press event ``` this() { addEvents(GdkEventMask.BUTTON_PRESS_MASK); addOnDraw(&drawCallback); addOnButtonPress(&onButtonPress); } ``` ``` public bool onButtonPress(Event event, Widget wid

Re: Format

2021-05-21 Thread drug via Digitalmars-d-learn
21.05.2021 16:45, newbie пишет: I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you sink is obsolete now, use W(riter) ```D import std.range : isOutputRange; vo

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-02 Thread drug via Digitalmars-d-learn
02.06.2021 00:47, Ola Fosheim Grøstad пишет: Note: Many simple GUI toolkits are horribly inefficient as they let each object render themselves.  An efficient GUI engine will have to replicate some of the browser complexity... I tried retained and immediate GUI, both fail (imho) for my use case

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-02 Thread drug via Digitalmars-d-learn
02.06.2021 12:50, Ola Fosheim Grøstad пишет: Depends on the data, I guess, if they are all visible at once then you basically have to very carefully write your own GPU render stage for that view and carefully cache things that does not move by rendering them to buffers (in GPU memory). Usuall

Re: Any 3D Game or Engine with examples/demos which just work (compile&run) out of the box on linux ?

2021-06-07 Thread drug via Digitalmars-d-learn
07.06.2021 17:02, Prokop Hapala пишет: Basically I'm desperate do find anything which encapsulates OpenGL calls into some nice D-lang classes Did you try gfm? specifically its 7th version - [gfm7](https://github.com/drug007/gfm7)? It has nice [classes](https://github.com/drug007/gfm7/tree/mas

Re: How to disable assigning a value to a property?

2021-07-06 Thread drug via Digitalmars-d-learn
06.07.2021 13:06, Jack Applegame пишет: Code: ```d import std.stdio; struct Field {     void opAssign(int a) {     writefln("Field.opAssign(%s)", a);     } } struct Register {     Field clock(int a) {     writefln("Register.clock(%s)", a);     return Field();     } } void m

Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn
08.07.2021 16:51, Виталий Фадеев пишет: Hi! I searching trivial simple D/OpenGL working in 2021 year example. It may be triangle. It may be based on any library: SDL, GLFW, Derelict, etc. Can you help me ? https://github.com/drug007/gfm7/tree/master/examples/simpleshader it's not trivial t

Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn
08.07.2021 17:20, Виталий Фадеев пишет: vital@unknown:~/src/dtest/working-example/gfm7/examples/simpleshader$ dub run Fetching bindbc-opengl 0.15.0 (getting selected version)... Fetching colorize 1.0.5 (getting selected version)... Fetching gfm 8.0.6 (getting selected version)... Fetching bind

Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn
08.07.2021 18:46, Виталий Фадеев пишет: On Thursday, 8 July 2021 at 15:30:07 UTC, drug wrote: 08.07.2021 17:20, Виталий Фадеев пишет: [...] I failed to reproduce that. What platform you use and what is the compiler version? drug, Linux, Ubuntu, x64 # uname -a Linux unknown 5.11.0-22-generi

Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn
08.07.2021 19:11, Виталий Фадеев пишет: I fix source code, as drug say. I've fixed the issue upstream, shortly gfm7 v1.1.2 will be available.

Re: Initializing a complex dynamic array (with real part from one array, and imaginary from other array)?

2021-07-21 Thread drug via Digitalmars-d-learn
I wouldn't state it is the best way but you can try something like that: ```D import std.complex; import std.range : zip; import std.algorithm : equal, map; import std.array : array; void main(){ auto N=2; double[] x,y; x.length = N; y.length = N; x[0] = 1.1; x[1] = 2.2;

Re: Performance issue with fiber

2021-07-28 Thread drug via Digitalmars-d-learn
28.07.2021 17:39, Mathias LANG пишет: On Wednesday, 21 July 2021 at 22:51:38 UTC, hanabi1224 wrote: Hi, I'm new to D lang and encounter some performance issues with fiber, not sure if there's something obviously wrong with my code. I took a quick look, and the first problem I saw was that you

Re: I do not understand copy constructors

2021-08-12 Thread drug via Digitalmars-d-learn
12.08.2021 12:36, Learner пишет: > It seems that there is no easy way to transition from a postblit to a copy constructor, no? You just need both const and mutable copy ctors to replace inout one: ```D struct A { int[] data; this(ref return scope A rhs) { data = rhs.data.dup; }

Re: I do not understand copy constructors

2021-08-12 Thread drug via Digitalmars-d-learn
12.08.2021 14:07, drug пишет: 12.08.2021 12:36, Learner пишет:  > It seems that there is no easy way to transition from a postblit to a copy constructor, no? You just need both const and mutable copy ctors to replace inout one: ```D struct A {     int[] data;     this(ref return scope A

Re: I do not understand copy constructors

2021-08-12 Thread drug via Digitalmars-d-learn
12.08.2021 14:32, Paul Backus пишет: This is not true. Qualifying the ctor as `inout` works fine: https://run.dlang.io/is/Kpzp5M The problem in this example is that `.dup` always returns a mutable array, even if the array being copied is `inout`. The solution is to cast the copy back to the

Re: How to get element type of a slice?

2021-08-17 Thread drug via Digitalmars-d-learn
17.08.2021 15:21, Ferhat Kurtulmuş пишет: Hello folks, Hope everyone is doing fine. Considering the following code, in the first condition, I am extracting the type Point from the slice Point[]. I searched in the std.traits, and could not find a neater solution something like ElementTypeOf!T.

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread drug via Digitalmars-d-learn
10.09.2021 12:27, eugene пишет: //import std.container.dlist; // dmd (v2.097.2) import std.container: DList; // gdc (4.9.2) It is off-topic a bit but I think none can compare gdc 4.9.2 to dmd 2.097.2 because gdc has older version than dmd. I would compare gdc to appropriate dmd version, it

Re: What is the proper way to outline static-if-conditions ?

2021-10-10 Thread drug via Digitalmars-d-learn
You just need to check if T is a pointer: ```D import std; alias DA = int[]; alias SA = int[3]; alias PSA = SA*; alias PDA = DA*; version(all) enum isPointedStaticArray(T) = isPointer!T && isStaticArray!(PointerTarget!T); else enum isPointedStaticArray(T) = isPointer!T && is(PointerTarget!T

Re: What is the proper way to outline static-if-conditions ?

2021-10-10 Thread drug via Digitalmars-d-learn
On 10.10.2021 18:01, Elmar wrote: Well, I just wondered why your code would compile and mine wouldn't. The `version(all)` variant will not compile on my computer with `rdmd` because `PointerTarget` only allows pointers. It depends on compiler version. This variant is compiled on version 2.0

Re: I need some help for my DCV update

2021-11-26 Thread drug via Digitalmars-d-learn
On 26.11.2021 12:16, Ferhat Kurtulmuş wrote: I am working on the DCV to make it compilable with the recent versions of LDC, mir libraries, and stuff. I have not yet simply forked it to work on it. I am including modules one by one for my convenience instead. Hope, I am close to the end. Here is

Re: A debug class has started

2021-12-13 Thread drug via Digitalmars-d-learn
On 13.12.2021 13:49, forkit wrote: On Monday, 13 December 2021 at 09:49:05 UTC, forkit wrote: char* w = cast(char*)str.toStringz; // this seems to be the solution class has ended ;-) That's because `str` is initialized by a literal and you can not change it by definition. When you cal

Re: A debug class has started

2021-12-13 Thread drug via Digitalmars-d-learn
On 13.12.2021 14:26, ag0aep6g wrote: On 13.12.21 12:09, drug wrote: That's because `str` is initialized by a literal and you can not change it by definition. When you call `toStringz` it duplicates that literal (adding terminating zero at the end) and the duplicate is mutable. I would recommen

Re: How to make a generic function to take a class or struct by reference?

2022-03-27 Thread drug via Digitalmars-d-learn
Auto ref? ```D int* getX(T)(auto ref T t) { ... ```

Re: Idiomatic way to add examples to dub package

2018-04-27 Thread drug via Digitalmars-d-learn
26.04.2018 21:16, FreeSlave пишет: Most dub packages are libraries and should provide runnable examples. What's the current idiomatic way to add examples? I used sub-packages with dependency on the library and "*" as version and running them as dub run :examplename Now I've noticed vibed uses a

Re: Idiomatic way to add examples to dub package

2018-04-27 Thread drug via Digitalmars-d-learn
27.04.2018 13:58, Laurent Tréguier пишет: This is the way Rust packages handle their Cargo.lock file, if I'm not mistaken, and it seems reasonable to me Exactly

Re: Finding the last executed line by checking dmd core

2018-05-03 Thread drug via Digitalmars-d-learn
On 03.05.2018 22:45, kerdemdemir wrote: After a big refactor my code crushes I have no idea where. I am only getting : Program exited with code -11 And a core file. I used to use gdb for c++ coredumps. With what program&option I can check dmd core file? Erdemdem The same programs and opti

could someone test support for Asian languages in nanogui port?

2018-05-04 Thread drug via Digitalmars-d-learn
I port nanogui, but besides porting I'd like to improve it using great capabilities of D language provides. One of them is utf support, so I added support for Asian languages to nanogui.TextBox. But I'm not sure I've did it well and so I'd like to ask someone to test it using the following: ``

Re: could someone test support for Asian languages in nanogui port?

2018-05-06 Thread drug via Digitalmars-d-learn
On 06.05.2018 06:10, Binghoo Dang wrote: hi, I'm a Chinese, and I just have done the test. I also copied some Japanese text from Dlang twitter channel and added some Chinese wide punctuation Char. And It's all seems displayed correctly. The resulting screenshot is here: https://pasteboard.

`recursive template expansion` error msg isn't informative

2018-05-07 Thread drug via Digitalmars-d-learn
I get the error like: ``` ./foo/bar/baz/builder.d(57,23): Error: template instance `staticMap!(DebugTypeMapper, BaseDebuggerTypes)` recursive template expansion ``` That's all. It doesn's print instantiations stack so I can't track back the reason. Could someone give an advice how to struggle

Re: could someone test support for Asian languages in nanogui port?

2018-05-08 Thread drug via Digitalmars-d-learn
08.05.2018 11:11, Kagamin пишет: On Sunday, 6 May 2018 at 11:18:17 UTC, drug wrote: Could you describe the problem in more details? SDL probably selects the first font that has the characters, which in his case is a font of comic sans design, instead of a font configured for gui. It's not

Re: `recursive template expansion` error msg isn't informative

2018-05-08 Thread drug via Digitalmars-d-learn
07.05.2018 17:22, Timoses пишет: On Monday, 7 May 2018 at 10:28:14 UTC, drug wrote: I get the error like: ``` ./foo/bar/baz/builder.d(57,23): Error: template instance `staticMap!(DebugTypeMapper, BaseDebuggerTypes)` recursive template expansion ``` That's all. It doesn's print instantiations

Re: "Start a Minimal web server" example do not work.

2018-05-08 Thread drug via Digitalmars-d-learn
08.05.2018 16:23, BoQsc пишет: On Tuesday, 8 May 2018 at 13:04:12 UTC, Seb wrote: On Tuesday, 8 May 2018 at 12:37:42 UTC, BoQsc wrote: On Tuesday, 8 May 2018 at 12:19:14 UTC, Adam D. Ruppe wrote: On Tuesday, 8 May 2018 at 12:13:56 UTC, BoQsc wrote: [...] This one needs to be compiled+run wi

Re: Splitting up large dirty file

2018-05-16 Thread drug via Digitalmars-d-learn
16.05.2018 10:06, Dennis пишет: Here's a version that only outputs the first chunk: ``` import std.stdio; import std.range; import std.algorithm; import std.file; import std.exception; void main(string[] args) { enforce(args.length == 2, "Pass one filename as argument"); auto lineChun

Re: delegates and functions

2018-06-09 Thread drug via Digitalmars-d-learn
On 09.06.2018 23:39, OlegZ wrote: On Saturday, 9 June 2018 at 20:03:15 UTC, OlegZ wrote: auto hz = (string s) => { writeln( s ); return cast( int )s.length; } How I should to write lambda of type "int delegate( string )? I found one way: auto hz = delegate int( string s ) { writeln( s ); ret

Re: delegates and functions

2018-06-10 Thread drug via Digitalmars-d-learn
On 10.06.2018 12:21, OlegZ wrote: On Saturday, 9 June 2018 at 22:28:22 UTC, Ali Çehreli wrote: There is some explanation at the following page, of how the lambda syntax is related to the full syntax:   http://ddili.org/ders/d.en/lambda.html#ix_lambda.=%3E copy rect from article as image http

Re: delegates and functions

2018-06-10 Thread drug via Digitalmars-d-learn
On 10.06.2018 20:58, SrMordred wrote: a => { return 2*a; }   /\  \   /   ||   \ /   ||    \   /   || \ /   ||  \   /  This is   \ /  function   \  This is definition of delegate  definition  \ so you have a function that returns delegate. ``` it's like a => a

Why is it hard to make Qt bindings?

2018-07-05 Thread drug via Digitalmars-d-learn
There were several attempts to make Qt binding for dlang, but either they has failed or has been stalled. It would be nice to collect that experience. Considering 2.081 supports C++ special member (not all but majority) isn't it time to make another attempt or the problem is more complex? Coul

Re: Is it feasible to slowly rewrite a C++ codebase in D?

2018-07-17 Thread drug via Digitalmars-d-learn
16.07.2018 17:32, bachmeier пишет: On Friday, 13 July 2018 at 19:53:45 UTC, Laeeth Isharc wrote: On Wednesday, 20 June 2018 at 18:47:10 UTC, Jordi Gutiérrez Hermoso wrote: What are your ideas? If you would like to expose C function and type declarations to D, you could take a look at DPP,

Re: Fast OpenGL-based visualization engine mainly for animated two-dimensional graphs

2018-08-24 Thread drug via Digitalmars-d-learn
24.08.2018 16:32, Per Nordlöw пишет: Is anybody working on a D-based really fast OpenGL-based visualization engine that supports tessellation of 2d primitives on the GPU? For instance, if I want to animate a huge amount of circles (in a 2d-graph) and I would like to only have to send an array

Re: Fast OpenGL-based visualization engine mainly for animated two-dimensional graphs

2018-08-24 Thread drug via Digitalmars-d-learn
24.08.2018 17:38, Per Nordlöw пишет: On Friday, 24 August 2018 at 14:34:46 UTC, Per Nordlöw wrote: On Friday, 24 August 2018 at 14:03:08 UTC, drug wrote: imgui, but now I'm replacing it by nuklear. Is nuklear a software project that can be found somewhere? Ahh, I presume you mean - https:/

Re: Static foreach internal variable

2018-08-30 Thread drug via Digitalmars-d-learn
30.08.2018 11:19, Andrey пишет: Hello, is it possible to declare an internal variable in "static foreach" and on each iteration assign something to it? Example: static foreach(arg; SomeAliasSeq) {    internal = arg[0].converted;    // a shortcut for expression "arg[0].converted"    static i

Re: C++ GLM(OpenGL Mathematics) D Equivalent.

2018-09-04 Thread drug via Digitalmars-d-learn
On 04.09.2018 22:23, SrMordred wrote: Most C++ game related projects uses GLM as they default math/vector lib (even if not using opengl). In D we have (that I found): gfm.math  - https://github.com/d-gamedev-team/gfm dlib.math - https://github.com/gecko0307/dlib Gl3n  - https://github.com/

Re: thread phobos and creating threads

2018-09-08 Thread drug via Digitalmars-d-learn
On 08.09.2018 20:59, Marcin wrote: void main() { snipped } This? https://run.dlang.io/is/SHyCXA

Re: Is it's correct to say that ALL types that can grow are place on heap?

2018-09-11 Thread drug via Digitalmars-d-learn
11.09.2018 13:11, Timoses пишет: Is this why it is said that passing parameters by value can be more efficient? Cause for a ref parameter it would require passing the address which would require to be allocated? Aww, I really would love some insights into function parameter passing. Why is

Re: Is it's correct to say that ALL types that can grow are place on heap?

2018-09-12 Thread drug via Digitalmars-d-learn
12.09.2018 15:14, Timoses пишет: On Tuesday, 11 September 2018 at 12:07:14 UTC, drug wrote: If data size is less or equal to total size of available registers (that can be used to pass values) than passing by value is more efficient. Passing data with size less than register size by reference

Compile time sequences

2018-10-03 Thread drug via Digitalmars-d-learn
According to https://dlang.org/articles/ctarguments.html compile time sequences "...allow a programmer to operate on types, symbols and values..." Phobos has `isType`/`isTypeTuple` traits, also `isExpressions` where expression may contain both values and symbols, but has no traits like `isSymbol

Re: Compile time sequences

2018-10-03 Thread drug via Digitalmars-d-learn
On 03.10.2018 20:22, Paul Backus wrote: In my experience doing metaprogramming in D, it's best to make your static if/template constraint tests as narrow and specific as possible. For example, if you want to know whether you can call a function with a particular argument, you don't need to mu

Re: Compile time sequences

2018-10-04 Thread drug via Digitalmars-d-learn
I was incorrect with description of the problem. The problem is that there is no simple way to distinct types and symbols if symbols are private. Because private symbol is not accessible you can not get any info on it, including is it type or symbol or value. And you can not get protection for

Re: Compile time sequences

2018-10-04 Thread drug via Digitalmars-d-learn
04.10.2018 14:44, drug пишет: I was incorrect with description of the problem. The problem is that there is no simple way to distinct types and symbols if symbols are private. Because private symbol is not accessible you can not get any info on it, including is it type or symbol or value. And y

Re: Is there a way to use std.regex at compile-time?

2018-10-16 Thread drug via Digitalmars-d-learn
16.10.2018 17:47, cosinus пишет: On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote: Is there a way to use std.regex at compile-time? I would like to `mixin()` the result of this function: ```D string generateVertexStruct() {     auto reVertex = ctRegex!(`in\s+(?P\w+)\s+(?P\w+)\s*;`)

Re: Pegged: spaces

2018-10-26 Thread drug via Digitalmars-d-learn
25.10.2018 23:34, Michelle Long пишет: Ignores spaces: <- Doesn't: < Concatenates results: <~ Thank you for sharing your results!

Re: updated mir interface

2018-11-07 Thread drug via Digitalmars-d-learn
On 07.11.2018 22:09, Alex wrote: Ok... sorry for being penetrant, but there is still something strange. Having dependencies as you had, ´´´ import mir.random.algorithm; import mir.algorithm.iteration; import mir.ndslice; import mir.random; void fun(size_t s){} void main() { size_t[] arr;

Re: new returning the same memory....

2018-11-08 Thread drug via Digitalmars-d-learn
08.11.2018 14:48, Codifies пишет: On Thursday, 8 November 2018 at 11:46:44 UTC, Codifies wrote: when creating a new instance of a class aclass a = new aclass(); I was under the impression that this created a new chunk of memory on the heap... however I'm trying to create this class instance

Re: How do I use null in a struct?

2018-11-10 Thread drug via Digitalmars-d-learn
On 10.11.2018 22:42, Václav Kozák wrote: I'm making a Rest API with vibe.d and I have a struct User. Sometimes I need to return only a few of the fields. So for example: return User(1, null, "John", null, null, ...); If I do this, an error occurs: cannot implicitly convert expression null of ty

Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/IygU5D AllMembers states that struct S contains "this" member, but hasMember negates it. Is it bug or misusing?

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread drug via Digitalmars-d-learn
On 18.11.2018 0:09, Adam D. Ruppe wrote: On Saturday, 17 November 2018 at 20:54:24 UTC, drug wrote: https://run.dlang.io/is/IygU5D AllMembers states that struct S contains "this" member, but hasMember negates it. Is it bug or misusing? I'm not sure what it is supposed to do, but since this i

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread drug via Digitalmars-d-learn
On 18.11.2018 1:26, Adam D. Ruppe wrote: That's because the compiler passes it a hidden pointer to refer to the context outside. The compiler could perhaps be smarter about it, and see if those methods actually refer to the context, but it seems to simply say if the method is there, it might

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-18 Thread drug via Digitalmars-d-learn
On 18.11.2018 5:37, Stanislav Blinov wrote: It's only "hidden" in that there's no symbol to access it. But you can still access it via .tupleof, and it still of course affects the ABI (i.e. S.sizeof is always at least pointer size when S is nested). If you want to iterate fields, .tupleof is a

[Pegged] making parsing error informative

2018-11-25 Thread drug via Digitalmars-d-learn
I have the following grammar https://run.dlang.io/is/gRTGm3 If user types `ubyte1` instead of `ubyte` the whole string parsing fails and error message says string is wrong from the start. How can I get more informative message like "unknown type ubyte1" or at least error position points to `uby

How to convert `std.datetime.Duration` to seconds of floating point type?

2019-02-19 Thread drug via Digitalmars-d-learn
Now I do it this way (https://run.dlang.io/is/8kVibT): ``` auto some_duration = dur!"msecs"(500); auto seconds = some_duration.total!"hnsecs" / 10_000_000.0; assert(seconds.approxEqual(0.5)); ``` is there better way to do it? Thanks in advance

Re: How to convert `std.datetime.Duration` to seconds of floating point type?

2019-02-19 Thread drug via Digitalmars-d-learn
On 19.02.2019 18:07, Dennis wrote: On Tuesday, 19 February 2019 at 14:34:09 UTC, drug wrote: Now I do it this way (https://run.dlang.io/is/8kVibT): ``` auto some_duration = dur!"msecs"(500); auto seconds = some_duration.total!"hnsecs" / 10_000_000.0; assert(seconds.approxEqual(0.5));

Re: Best practices of using const

2019-02-19 Thread drug via Digitalmars-d-learn
On 19.02.2019 19:19, Kagamin wrote: On Tuesday, 19 February 2019 at 15:30:22 UTC, Atila Neves wrote: I keep hearing how const is nigh unusable in D, and except for ranges I litter my code with const everywhere, pretty much just as often as I used in C++. I once spent a good amount of effort t

Re: How to convert `std.datetime.Duration` to seconds of floating point type?

2019-02-19 Thread drug via Digitalmars-d-learn
On 19.02.2019 19:35, Alex wrote: On Tuesday, 19 February 2019 at 16:26:33 UTC, drug wrote: Well, I understand that using floating point values to represent time internally is a bad idea and I totally agree. But some convenient API to convert Duration to floating point and vice versa would be

Re: How to convert `std.datetime.Duration` to seconds of floating point type?

2019-02-19 Thread drug via Digitalmars-d-learn
19.02.2019 19:55, Alex пишет: On Tuesday, 19 February 2019 at 16:44:23 UTC, drug wrote: On 19.02.2019 19:35, Alex wrote: On Tuesday, 19 February 2019 at 16:26:33 UTC, drug wrote: Well, I understand that using floating point values to represent time internally is a bad idea and I totally agre

Re: Best practices of using const

2019-02-20 Thread drug via Digitalmars-d-learn
On 20.02.2019 11:05, Kagamin wrote: On Tuesday, 19 February 2019 at 16:38:17 UTC, drug wrote: The same I can say about properties - for example I use them in meta programming to detect what to serialize/process - I skip methods but serialize properties and for me this is a nice language feature

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)

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 ulong

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 DataP

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 opSlice

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 f

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: 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: 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` i

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: 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 = SDL_Load

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: 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: https://run.dlang.io/is/ATj

rank of range

2017-07-01 Thread drug via Digitalmars-d-learn
Hello! Is there a convenient way to get rank of range a.k.a. count of dimensions in compile time? Like: static assert( rankOf!(uint[]) == 1); static assert( rankOf!(uint[][][]) == 3);

Re: rank of range

2017-07-01 Thread drug via Digitalmars-d-learn
01.07.2017 20:33, Ali Çehreli пишет: On 07/01/2017 10:05 AM, drug wrote: Hello! Is there a convenient way to get rank of range a.k.a. count of dimensions in compile time? Like: static assert( rankOf!(uint[]) == 1); static assert( rankOf!(uint[][][]) == 3); I'm not aware of one but this seems

Re: D, Game Development, GLSL, Math

2017-07-01 Thread drug via Digitalmars-d-learn
01.07.2017 22:07, Void-995 пишет: (Void-995) Hi, everyone. I'm pretty excited with what have D to offer for game development, especially meta programming, traits, object.factory, signals and bunch of other neat things that may save a lot of time. Also, i saw support for vector data types and si

Re: weird error message

2017-07-02 Thread drug via Digitalmars-d-learn
02.07.2017 04:06, Ali Çehreli пишет: On 07/01/2017 04:56 PM, crimaniak wrote: > about very long error messages generated in some > cases. Please submit a bug report. The compiler may be able to abbreviate certain types. For example, in this case most of the error message text is values of a

Re: std.string.format call from varyargs

2017-07-02 Thread drug via Digitalmars-d-learn
02.07.2017 09:52, H. S. Teoh via Digitalmars-d-learn пишет: On Sun, Jul 02, 2017 at 12:49:30AM +, LeqxLeqx via Digitalmars-d-learn wrote: Hello! How does one go about invoking a templated-variatic function such as std.string.format with an array of objects? For example: string stringMyTh

<    1   2   3   4   >