Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 24 November 2022 at 03:49:16 UTC, []() {}() wrote: I broke a forum rule by critically analysing your blog? Wow. Criticize my blog posts all you want. Just stop please stop derailing threads. I'm going to delete further off topic posts in this thread.

Re: Is defining get/set methods for every field overkill?

2022-11-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 November 2022 at 23:35:59 UTC, thebluepandabear wrote: Please stop, we get it... I'm not a moderator so I cannot enforce rules but there is NO need to continue this debate here. This software 'religiousness' is too much. I am a moderator and I can enforce the rules. So

Re: Actual lifetime of static array slices?

2022-11-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 02:49:55 UTC, Mike Parker wrote: It's not the scope that matters here. It's the stack. Memory allocated in the inner scope uses the function stack, so it's all valid until the function exits. And that was just so, so wrong. Of course destructors get called

Re: Actual lifetime of static array slices?

2022-11-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 November 2022 at 02:26:41 UTC, Elfstone wrote: I failed to find any documentation, except dynamic array slices will be taken care of by GC, but I assume it's not the case with static arrays. A slice is a view on the existing memory owned by the original array. No allocations

Re: Using glibc headers with ImportC

2022-11-13 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 November 2022 at 09:15:39 UTC, qua wrote: I agree it was unexpected that it didn't, at least for newcomers. Almost everyone is a newcomer when it comes to ImportC.

Re: ImportC linking issue

2022-11-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 November 2022 at 10:02:12 UTC, confuzzled wrote: On Saturday, 12 November 2022 at 08:43:13 UTC, Mike Parker wrote: On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote: The linker doesn't care if the libraries are C or D, and the compiler is only involved in that

Re: ImportC linking issue

2022-11-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 November 2022 at 02:45:52 UTC, confuzzled wrote: It seems that every time I resolve one of these undefined symbols issues, the compiler finds more. So I keep copying lib files from locations that are a path, to my working directory and linking them to my script. Is that the

Re: dmd as a library

2022-11-07 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 06:21:11 UTC, vushu wrote: So I do feel, that I am in need for some learning materials or guidance. You might find Lucian Danescu's DConf '22 presentation helpful: https://youtu.be/JYkb3PjIn4c

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 November 2022 at 06:02:13 UTC, Mike Parker wrote: are in C++. D enforces the distinction that C++ ...that C++ programmers often follow by convention.

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 November 2022 at 05:41:06 UTC, Siarhei Siamashka wrote: Thanks for the link and also thanks for confirming that you have no clue what's going on. I think that what actually That's not necessary. He does know what's going on and pointed you to the correct place. The second

Re: Importing modules under DUB on Windows

2022-10-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 October 2022 at 16:40:20 UTC, DLearner wrote: I'm not getting on with DUB. Maybe fewer people use it under Windows, so Windows constructs don't get exercised so much. Is there a non-DUB way of arranging that `import arsd.terminal;` will use that module as held on GitHub?

Re: dub ldc2 static linking

2022-10-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 28 October 2022 at 01:37:50 UTC, Mike Parker wrote: This has nothing to do with dub and is not a D issue specifically. Enter your error message in Google and you'll get a long list of results. Maybe one of them can help you. Or do what kinke suggests :-)

Re: dub ldc2 static linking

2022-10-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote: curl.d:(.text._D3std3net4curl7CurlAPI7loadAPIFZPv+0xd): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking and many other warnings like this.

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 03:10:29 UTC, Mike Parker wrote: It's right there in the summary of the Final Review of the DIP that I linked above: https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1038.md#final-review I meant to say the summary of the formal assessment. One of

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 01:34:54 UTC, mw wrote: On Wednesday, 19 October 2022 at 01:30:23 UTC, H. S. Teoh wrote: On Wed, Oct 19, 2022 at 01:15:37AM +, Adam D Ruppe via it only applies to types, not to functions. Wat... so what's the use of it then? So it's not possible to

Re: How do I correctly install packages for use with Visual Studio?

2022-10-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote: I'm confused at what/where exactly D expect files to be for them to considered "installed". D doesn't expect them to be anywhere. By default, the compiler will search relative to the current working directory, on any paths

Re: How do I correctly install packages for use with Visual Studio?

2022-10-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote: Building x64\Debug\chip8.exe... chip8.d(4): Error: unable to read module `raylib` chip8.d(4):Expected 'raylib.d' or 'raylib\package.d' in one of the following import paths: import path[0] =

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 October 2022 at 22:17:52 UTC, H. S. Teoh wrote: Given that this particular trap crops up regularly, perhaps some sort of warning ought to be added. Once the @nodiscard DIP is accepted & implemented this should be easy to do. Seems like you're behind the times! The DIP was

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 October 2022 at 21:51:54 UTC, WhatMeWorry wrote: I lost about a half an hour troubleshooting some code of mine which as it turned out to be resolved with just one line. // paths.remove(i); // compiles fine but does nothing paths = paths.remove(i); // works - what I

Re: Visual D doesn't work, now Visual Studio Code / D doesn't work!!!! ....

2022-10-02 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 2 October 2022 at 11:00:06 UTC, Daniel Donnell, Jr wrote: I thought I set everything up correctly, and now: ``` Exception thrown at 0x7FF7D6E2E230 in metamath-d.exe: 0xC096: Privileged instruction. Unable to open natvis file

Re: D installer

2022-10-02 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 2 October 2022 at 11:33:47 UTC, Imperatorn wrote: I only have Visual Studio 2022. Will the installer be updated to support that or am I missing some components? ![Installer](https://i.ibb.co/sCZRFRf/installer.jpg) You should be fine. Select the bottom option since you already

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:15:11 UTC, Mike Parker wrote: Pointers to non-static member functions always produce a delegate. Otherwise, you wouldn't be able to access the class instance's members. Reference: https://dlang.org/spec/function.html#closures

Re: Why I get delegate when passing address of function?

2022-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2022 at 09:02:31 UTC, Injeckt wrote: I have a one class and two modificators, where in "public" function I'm calling CreateThread with address of the ClientThread function which stored in same class, but in "private" modificator. And i get this error: Error: cannot

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: To elaborate on why you need the above... But I get these bugs: WndProc is a function, and you can't pass a function as a runtime function parameter, only pointers to functions. The first two errors tell you exactly what the

Re: How I can pass the WndProc as a parameter?

2022-09-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote: And after all, I call it: KK_CreateWindowClass(WndProc); `KK_CreateWindowClass();`

Re: How include header file?

2022-09-07 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 20:23:03 UTC, Injeckt wrote: Convert it to D: extern(C) const(char)* inet_ntop(int af, const(void)* src, char* dst, socklen_t size); Win32 API functions need to be `extern(Windows)`. You probably also need: alias socklen_t = ...;

Re: How to link a msvcr120.dll in an inverse recursive way after a Windows .exe binary deployment

2022-09-05 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 6 September 2022 at 04:36:55 UTC, ShadoLight wrote: True. In that case just distribute the DLL (taken from the DMD bin folder) alongside the HelloWorld EXE so that both reside in the same folder on the target computer. The proper way to do this is to ship the correct version of

Re: This code completely breaks the compiler:

2022-08-18 Thread Mike Parker via Digitalmars-d-learn
On Friday, 19 August 2022 at 04:25:25 UTC, Ruby The Roobster wrote: So that's why it compiled. Still, I believe that stuff like this ought to be detected at compile time, as supposed to in a unittest or, if someone forgot to write the tests, in production. If the template is never

Re: char* pointers between C and D

2022-07-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 July 2022 at 09:04:29 UTC, pascal111 wrote: I have small C program that uses a pointer to change the start address of a string, and when I tried to do the same code but with D, the D code printed the address of the string after I increased it one step instead of printing the

Re: dlang bug - accessing module variable from method segfaults only when using module reference directly

2022-07-01 Thread Mike Parker via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:44:20 UTC, Chris Katko wrote: It appears module access to a class is broken until the constructor finishes. No, it has nothing to do with the module. It's the reference itself. Until the constructor returns, the reference through which you're constructing the

Re: dlang bug - accessing module variable from method segfaults only when using module reference directly

2022-07-01 Thread Mike Parker via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:20:15 UTC, Mike Parker wrote: r. And that also looks like the source of your original segfault. You've got a circular reference going on in the constructors. In other words, you're constructing a global world instance, which in turn constructs an elf instance,

Re: dlang bug - accessing module variable from method segfaults only when using module reference directly

2022-07-01 Thread Mike Parker via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:01:30 UTC, Chris Katko wrote: Forgot the last line. That's important because world MUST exist by time elf is called... because world... created and called elf. So it's not a memory issue, but some sort of linkage issue. world is null because the constructor

Re: Static Initialization of Structs syntax

2022-06-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 June 2022 at 11:19:59 UTC, Antonio wrote: I see now: DIP 1033 will solve this (i.e., using named arguments in struct constructor... similar to how dart/flutter works) That would be DIP 1030: https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md Max

Re: Convering strings containing number

2022-06-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 04:26:44 UTC, Salih Dincer wrote: Hi, I've been interested in conversion possibilities for a while. I tried to convert a string containing numbers but with no success in single digits. The only solution I found is to subtract 48 from the result: ```d import

Re: ImportC: unresolved external symbol

2022-06-14 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 14:32:50 UTC, ryuukk_ wrote: ``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub init) DMD: v2.100.0-dirty This works from the command line:

Re: Can I create a package with friendly modules

2022-06-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2022 at 23:29:29 UTC, forkit wrote: I don't get it. How does this enable one module to access the private parts of another module? It doesn't. But what you were describing in your post is package-level access. By keeping it the cross-module access in a subpackage,

Re: Can I create a package with friendly modules

2022-06-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 12 June 2022 at 05:05:46 UTC, forkit wrote: Is it possible to create a package.d, consisting of (for example), two modules, where each module can access private declarations within each other. In essence, declaring 'a module level friendship', or a kind of 'extended module' if you

Re: Why allow initializers of non-static members that allocate?

2022-06-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2022 at 10:37:30 UTC, Bastiaan Veelo wrote: So that’s why I used “why” in the title of this thread, which I haven’t seen an answer to yet. What is the practical case where that warning would be annoying? When would you actually want this behaviour? After actually

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 June 2022 at 01:14:06 UTC, matheus wrote: So, in the case of "int[] arr = new int[](5)", an array of length 5 of type int will be instantiated and its address will be shared among whoever instantiates "S" and be pointed and accessed through arr. In the second case, "int[2]

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2022 at 14:56:24 UTC, Steven Schveighoffer wrote: Discovered circa 2009: https://issues.dlang.org/show_bug.cgi?id=2947 It should be illegal to declare a field this way that has mutable references without being `shared`. End of story. -Steve The docs do say that: The

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2022 at 07:46:36 UTC, Mike Parker wrote: I think this is a case where having a warning that's on by default, and which can be explicitly disabled, is useful. "Blah blah .init blah blah. See link-to-something-in-docs. Is this what you intended?" And it *is* documented:

Re: Why allow initializers of non-static members that allocate?

2022-06-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 June 2022 at 07:35:17 UTC, Bastiaan Veelo wrote: Is there a use case where this makes sense? I would have much appreciated the compiler slapping me on the fingers, but it doesn't. I understand that it is safe and that the compiler can allow this, but why would anyone want that?

Re: C-like static array size inference - how?

2022-06-07 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2022 at 00:43:24 UTC, Ali Çehreli wrote: Do I remember correctly that there were syntax proposals that used $ or _? int[$] arr = [ 1, 2 ]; int[_] arr = [ 1, 2 ]; But I can't find past discussions about that.

Re: dlang compilers & licenses.

2022-06-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 June 2022 at 14:13:08 UTC, Alain De Vos wrote: Do DMD , GDC , LDC have the same or different licenses in use ? DMD https://github.com/dlang/dmd/blob/master/LICENSE.txt LDC https://github.com/ldc-developers/ldc/blob/master/LICENSE GDC

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:24:51 UTC, Mike Parker wrote: And so, `[0]` is the same as `&(*ts.ptr + 0)`, or simply `ts.ptr`. That should be the same as `&(*(ts.ptr + 0))`!

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:14:40 UTC, Mike Parker wrote: More specifically, it points to the starting address of the allocated block of memory. I posted too soon. Given an instance `ts` of type `T[]`, array accesses essentially are this: ```d ts[0] == *(ts.ptr + 0); ts[1] == *(ts.ptr +

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 05:04:03 UTC, Salih Dincer wrote: Hi, Do I misunderstand? A dynamic array is allocated memory according to the `nextpow2()` algorithm(-1 lapse); strings, on the other hand, don't behave like this... ```d string str = "0123456789ABCDEF"; char[] chr = str.dup;

Re: Odd construct idea. Splitting arguments inside a parameter list.

2022-05-23 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 May 2022 at 08:34:21 UTC, Chris Katko wrote: D I'm curious if you can pass a struct of values (a 'tuple'?) with the right subfields, as if those fields occupied a function signature. (As I write this and try to explain it, it probably sounds impossible.) Right now you

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 14:54:31 UTC, Christopher Katko wrote: So wait, that means if I have a module with extra stuff like D colors.d auto red = // grey and then in my other file D auto white = grey(1.0); It won't use CTFE? Why is there a local module requirement? I'm

Re: UI Library

2022-05-20 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 07:05:21 UTC, Tejas wrote: Maybe gtkd? https://code.dlang.org/packages/gtk-d And some corresponding tutorials: https://gtkdcoding.com/

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread Mike Parker via Digitalmars-d-learn
On Friday, 20 May 2022 at 00:12:44 UTC, Chris Katko wrote: Yeah that occurred to me as I was falling asleep. Though, do I have to a specify ```D static auto myColor = grey(0.5); ``` to ensure it's done at compile time? It's not the end of the world, but ideally, these are static / hardcoded

Re: Question on shapes

2022-05-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 05:08:30 UTC, matheus wrote: In D there would be a better way to do such thing? Nothing really specific to D, but for one or two properties, you might just add them as function parameters with default values: ```d void draw(float scale = 1.0f); ``` If you have

Re: Why are structs and classes so different?

2022-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 May 2022 at 20:05:05 UTC, Kevin Bailey wrote: One question is, how should we pass objects - by value or by reference? In C++, you can do either, of course, but you take your chances if you pass by value - both in safety AND PERFORMANCE. The bottom line is that no one passes by

Re: Why are structs and classes so different?

2022-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:26:40 UTC, Kevin Bailey wrote: I'm trying to understand why it is this way. I assume that there's some benefit for designing it this way. I'm hoping that it's not simply accidental, historical or easier for the compiler writer. There's a problem that arises with

Re: Parameters of overloaded templated function

2022-05-10 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 12:12:13 UTC, Tejas wrote: Using aliases as parameters doesn't work(and the DIP that wanted to have this behaviour was de facto rejected) https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1023.md No, it wasn't rejected. The author decided it needed

Re: How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 00:50:09 UTC, Vinod K Chandran wrote: I want to convert this `pszUserString` to a string. How to do it. Thanks in advance. ```d import std.conv : to; string s = to!string(pszUserString); ```

Re: How to use destroy and free.

2022-05-04 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 05:37:49 UTC, forkit wrote: That's not at all what I said. You don't have to care about *when* memory is deallocated, meaning you don't have to manage it yourself. In any case, I disagree that caring about when memory gets deallocted means you shouldn't be using

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 04:52:05 UTC, forkit wrote: It is certainly *not* about you not having to care anymore (about memory management). That's not at all what I said. You don't have to care about *when* memory is deallocated, meaning you don't have to manage it yourself.

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 14:57:46 UTC, Alain De Vos wrote: Note, It's not i'm against GC. But my preference is to use builtin types and libraries if possible, But at the same time be able to be sure memory is given free when a variable is going out of scope. It seems not easy to combine the

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote: Error: array literal in @nogc function test.myfun may cause a GC allocation @nogc void myfun(){ scope int[] i=[1,2,3]; }//myfun May is a fuzzy word... It means if the compiler is free to allocate on the stack if possible.

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 2 May 2022 at 00:54:40 UTC, Elfstone wrote: Thanks. This breaks a lot of things. I don't know the reason behind the postponing, but who would expect one can't declare a parameter with an alias if it's a template?! Speaking of inconsistency. At the bottom of the DIP you can find a

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-01 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 1 May 2022 at 12:39:08 UTC, Elfstone wrote: Great, I'm using the constraint, until it's fixed. Will it be fixed though? The DIP that Tejas linked is from 2020!!! The DIP was postponed. I can contact the author to see if he intends to pick it up again. If not, anyone interested

Re: How do I get the screen resolution?

2022-04-28 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 28 April 2022 at 11:35:46 UTC, Mike Parker wrote: go through the same system APIs. For example, on Windows you can use two calls to `GetSystemMetrics` (one for the width, one for the height). (https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics)

Re: How do I get the screen resolution?

2022-04-28 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 28 April 2022 at 11:22:15 UTC, Alexander Zhirov wrote: Are there any methods to get the screen resolution? On C/C++ from under X11, it is not possible to do this on the command line via SSH, since the display is not defined. And is it possible to do this somehow by means of D,

Re: std.typecons Typedef initializers?

2022-04-25 Thread Mike Parker via Digitalmars-d-learn
On Monday, 25 April 2022 at 08:54:52 UTC, Chris Katko wrote: D struct pair { float x,y; } alias sPair = Typedef!pair; // pair of xy in screen space coordinates alias vPair = Typedef!pair; // pair of xy in viewport space coordinates //etc How do you initialize a typedef'd struct? ``d

Re: Variables & kind of memory

2022-04-23 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 23 April 2022 at 05:01:51 UTC, Alain De Vos wrote: On Saturday, 23 April 2022 at 04:52:39 UTC, Alain De Vos wrote: On Saturday, 23 April 2022 at 03:41:17 UTC, Alain De Vos wrote: I wrote a simple test program: ``` import std.stdio:writefln; [...] BBB: is probably the

Re: Variables & kind of memory

2022-04-23 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 23 April 2022 at 03:41:17 UTC, Alain De Vos wrote: int [] GLV=[1,2]; int [2] GLF=[1,2]; static int [] GSLV=[1,2]; static int [2] GSLF=[1,2]; FYI, `static` has no effect at module scope.

Re: DUB issues

2022-04-19 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 08:58:02 UTC, bauss wrote: On Monday, 18 April 2022 at 13:41:04 UTC, Mike Parker wrote: On Monday, 18 April 2022 at 05:27:32 UTC, Danny Arends wrote: Any ideas how to get into contact/fix this issue ? I've emailed Sönke and pointed him to this thread. Wouldn't

Re: DUB issues

2022-04-18 Thread Mike Parker via Digitalmars-d-learn
On Monday, 18 April 2022 at 05:27:32 UTC, Danny Arends wrote: Any ideas how to get into contact/fix this issue ? I've emailed Sönke and pointed him to this thread.

Re: Nested function requires forward declaration?

2022-04-14 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 14 April 2022 at 08:55:25 UTC, Chris Katko wrote: I imagine this is a really odd edge case but it's piqued my interest. Consider this: ```d void main() { void foo() { initRuntimeState(i); } foo(); if(!modifyRutimeState()) return; int i = getRandomValue(); i =

Re: Conversion from ANSI 1252 to unicode

2022-04-07 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 7 April 2022 at 07:24:03 UTC, Johann wrote: Hi all, anybody knows if there are functions (preferably) in Phobos, that translate from unicode to other encodings and vice versa? Johann https://dlang.org/phobos/std_encoding.html

Re: How to use an existing D package in Visual D?

2022-04-05 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 09:26:54 UTC, realhet wrote: Hello, I have all my D packages in the c:\D\libs\ directory. I added this path to the PropertyPages/Compiler/Additional Import Paths field. In the project source file I imported a module from my package using "import het.utils;" Also

Re: I like dlang but i don't like dub

2022-03-22 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 14:44:59 UTC, Marcone wrote: Why is dmd unable to import modules installed by dub using the import command like it does with the Phobos library? He can't send these modules to Linker? Needing to be passed to dmd via command line. I think it could be all automatic.

Re: static init c struct with array filed

2022-03-16 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). Any time you see a '[]' in C, the

Re: How do I create a package?

2022-03-02 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 2 March 2022 at 16:38:58 UTC, M wrote: There doesn't seem to be any docs on how to actually create packages. Is there a description anywhere? In case you're talking about a language-level package and not a dub package, just create a directory in your source tree with the name

Re: Colors in Raylib

2022-03-01 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 13:15:09 UTC, meta wrote: enum Color { GRAY } void setColor(Color color); setColor(GRAY); Then that defeats the purpose of having named enums.

Re: Cannot Call Super-Class Overloaded Function If Class has Function Override?

2022-03-01 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 09:10:46 UTC, Vijay Nayar wrote: I'm a bit surprised at this behavior though. Do you happen to know why it is considered bad to take into account the overloads of a super-class when resolving a call in a derived-class? https://dlang.org/articles/hijack.html

Re: opCast in class prevents destroy

2022-03-01 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 07:16:11 UTC, bauss wrote: Right now if you want to add an additional cast then you have to implement ALL the default behaviors and then add your custom cast. It's two template functions like the OP used: one for T to catch everything, and one specialization.

Re: opCast in class prevents destroy

2022-02-28 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 04:59:49 UTC, Mike Parker wrote: You could also specialize on `void*`, as that's the type that was failing to compile I meant "instead", not also.

Re: opCast in class prevents destroy

2022-02-28 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 04:29:56 UTC, cc wrote: ```d struct A {} class B { A opCast(T : A)() { return A(); } } void main() { auto b = new B(); destroy(b); } ``` fails with ``` dmd2\windows\bin\..\..\src\druntime\import\object.d(4209): Error:

Re: Colors in Raylib

2022-02-28 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 02:42:52 UTC, Steven Schveighoffer wrote: On 2/28/22 6:48 AM, Salih Dincer wrote: In general, the raylib enumerations are overly verbose for D, e.g. `KeyboardKey.KEY_X`, instead of just `KeyboardKey.X`. I'd love to provide "better enums". In Derelict, I

Re: https://run.dlang.io/ vs All dmd compilers (2.060 - latest)

2022-02-28 Thread Mike Parker via Digitalmars-d-learn
On Monday, 28 February 2022 at 17:44:57 UTC, Matheus wrote: On Monday, 28 February 2022 at 02:31:57 UTC, Mike Parker wrote: ... Hey Parker, I think my IP still under surveillance, everytime I post I get: "Your message has been saved, and will be posted after being approved by a

Re: Colors in Raylib

2022-02-28 Thread Mike Parker via Digitalmars-d-learn
On Monday, 28 February 2022 at 11:48:59 UTC, Salih Dincer wrote: Hi All, Is there a namespace I should implement in Raylib? For example, I cannot compile without writing Colors at the beginning of the colors: ```Colors.GRAY``` SDB@79 Assuming you mean the raylib-d binding, it implements

Re: https://run.dlang.io/ vs All dmd compilers (2.060 - latest)

2022-02-27 Thread Mike Parker via Digitalmars-d-learn
On Monday, 28 February 2022 at 01:51:52 UTC, meta wrote: Is the source of 'run.dlang.io' available somewhere? The link to the github repository is at the top of the run.dlang.io page: https://github.com/dlang-tour/core Issues should be reported there.

Re: Why writeln can't be converted to nothrow with just catching of StdioException

2022-02-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 February 2022 at 11:07:55 UTC, Basile B. wrote: Yeah there must be another one then. Something actionnable is the documentation. This has nothing to do with which exceptions types a function throws. The compiler doesn't dig into that. You have to catch `Exception`. ```D

Re: Why writeln can't be converted to nothrow with just catching of StdioException

2022-02-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 February 2022 at 11:11:28 UTC, partypooper wrote: So with such behavior there is no reason at all to make make function nothrow, if it uses throw functions in its body? I'm not sure what you mean. If a function throws an exception, it can't be nothrow. And as much as I

Re: Why writeln can't be converted to nothrow with just catching of StdioException

2022-02-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote: Do I completely not understand what is `nothrow` or why I can't make function nothrow with just catching StdioException? D does not have checked exceptions like Java, so the compiler doesn't have anyway to verify that any

Re: Offline D documentation/tutorial

2022-02-12 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 13 February 2022 at 00:16:02 UTC, LorenDB wrote: Is there a way to download tour.dlang.org, the D spec, and/or the Phobos spec as an offline HTML site? I like the ability of cppreference.com to be saved as an offline HTML archive and I'd like to have that for D as well. If you’ve

Re: ImportC: Should this compile?

2021-12-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 December 2021 at 03:27:50 UTC, Tejas wrote: Oh wow, the executable gets named `stuff` if that's the first file passed... always thought it would name it the same name as that file which contained `main` If the name of the file with `main` were used, you'd have to have a

Re: ImportC: Should this compile?

2021-12-18 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 18 December 2021 at 22:31:38 UTC, bachmeier wrote: I've been trying to get the stb header library to compile. There's a single remaining failure: ``` typedef struct { unsigned char c[4]; } stb_easy_font_color; stb_easy_font_color c = { 255,255,255,255 }; // use structure

Re: Passing a derived class where base class is defined as ref parameter

2021-12-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 December 2021 at 22:06:45 UTC, chopchop wrote: If I remove the ref, it works as expected, that is to say I can give a derived class as parameter. I have an idea why it does not work, but I think a c++ reference would work, ie incr(A& console) would accept a B as parameter. What

Re: A pass() identity range?

2021-12-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 December 2021 at 15:03:47 UTC, D Lark wrote: Because it does not seem like that from the tone of responses I have gotten: I did my due diligence, I believe, before posting my original reply to the old question. I had looked at the docs and also searched the forum. There is no

Re: How to deploy single exe application (?)

2021-11-28 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 28 November 2021 at 22:45:29 UTC, Willem wrote: // load sdl string uuid = randomUUID().toString(); string filename = format("SDL2-%s.dll", uuid); string depacked = buildPath(tempDir(), filename); std.file.write(depacked, sdlBytes); DerelictSDL2.load(depacked);

Re: Are templated functions always re-constructed?

2021-11-16 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 16 November 2021 at 21:14:50 UTC, rempas wrote: Let's say that I have the following function: ``` void add(T)(T val, T val2) { return val + val2; } // Classic example, lol ``` Now let's say that I call the function passing an `int` parameter. The function will get built with an

Re: D modules

2021-11-13 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 13 November 2021 at 22:52:55 UTC, pascal111 wrote: When I'm searching for "toUpper" and "toLower" functions that string type uses, I confused when I reached the module "std.string". In the first section of its page "https://dlang.org/phobos/std_string.html; I didn't found

Re: Average function using Variadic Functions method

2021-11-02 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 2 November 2021 at 16:35:40 UTC, pascal111 wrote: "input..." seems nice, where can I get more information about it? "Typesafe variadic functions" https://dlang.org/spec/function.html#typesafe_variadic_functions

Re: Why do we have Dmain?

2021-10-22 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 October 2021 at 05:54:21 UTC, Kirill wrote: I am not a compiler expert, but I genuinely would like to know why we have Dmain. I've been looking at the generated assembly code recently and noticed the _Dmain function. I didn't notice it before. Then there is main, where Dmain is

Re: problem with alias this and Tuple

2021-10-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 October 2021 at 15:55:40 UTC, Johann Lermer wrote: Thanks, understood. But isn't this a deficiency in the library that should be fixed? The problem extends to more than just `toHash`. Take a look at this DConf 2019 presentation by Eduard Staniloiu on ProtoObject (as proposed

Re: Managing malloced memory

2021-10-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 October 2021 at 10:53:15 UTC, anon wrote: S makeS(int x) { return S(x); // no destructor called here. } void main() { foo(S(1)); // no destructor called for this rvalue auto s = makeS(1); // destructor for s called here. foo(makeS(1)); // only one destructor called

Re: Traits in a template enum

2021-10-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 October 2021 at 12:56:30 UTC, Some Guy wrote: But I did not understand what you meant by "enums hold values, not types". Aren't types values at compile time? Types can be template arguments, if that's what you mean, but they aren't values.

  1   2   3   4   5   6   7   8   9   10   >