Re: Discuss: Classes are well supported in D, with Design by Contracts. Shouldn't we take advantage of that?

2025-09-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 13 September 2025 at 00:43:38 UTC, Brother Bill wrote: I'm not clear about why 'class'es are on the 'avoid' list. D has excellent support for Single inheritance, Interfaces, Design by Contract (DbC), GC, etc. I'm aware that there is a small run time cost for selecting the right vi

Re: Variables of struct and class types are called objects - discuss

2025-08-03 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 3 August 2025 at 15:31:34 UTC, Paul Backus wrote: The second one comes from C, where "object" refers to any value stored in memory. This kind of "object" is defined in the ["Object Model" section][2] of the language specification, and is mostly of interest to those writing low-lev

Re: Variables of struct and class types are called objects - discuss

2025-08-03 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 3 August 2025 at 11:11:43 UTC, Brother Bill wrote: In Programming in D book, page 247, it is written: Variables of struct and class types are called objects. This struck me as odd and confusing. I have always been taught that objects are instances of classes. That is, new MyClass

Re: How to use D on M2 macOS?

2025-07-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:25:57 UTC, Albert wrote: Thanks, how do I get the beta/nightly version? Only one I see is 0.23.1 from 2021. Thanks It's an option in the code-d extension settings.

Re: string from C function

2025-05-07 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 7 May 2025 at 22:47:35 UTC, Andy Valencia wrote: So about fromStringz... ```d import std.string : fromStringz; import core.stdc.time : ctime; void main() { string s = fromStringz(ctime(null)); } ``` Like that? tst44.d(6): Error: cannot implicitly convert expression `fromSt

Re: string from C function

2025-05-07 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 7 May 2025 at 22:28:32 UTC, Dejan Lekic wrote: https://dlang.org/library/std/string/from_stringz.html Given that `fromStringz` returns a slice of the original string, you can use `std.conv.to` to do it with an allocation when needed: `to!string(str)`.

Re: bindbc, SDL

2025-04-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 March 2025 at 14:10:21 UTC, Richard (Rikki) Andrew Cattermole wrote: The bindbc family of packages, usually can link against a shared library both during compilation (statically), or during runtime (dynamically). The import library serves no purpose if you are linking dynami

Re: Using bindbc-sdl with D

2025-04-04 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 26 March 2025 at 17:34:14 UTC, Claus D. Volko wrote: Could anybody please tell me what I have to do in order to get this to work? I don't know what's causing your linker errors related to bindbc-common, but I suggest you start over. Delete all of the BindBC stuff you "co

Re: How do you get basic hello world app with Derelict-GLFW to build?

2025-04-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 April 2025 at 04:44:38 UTC, Daniel Donnelly, Jr. wrote: == Build: 3 succeeded, 3 failed, 0 up-to-date, 0 skipped == == Build completed at 6:10 PM and took 14.375 seconds == ``` The code: ``` import derelict.glfw3; void main() { DerelictGLF

Re: derelict-gl3 + derelict-glfw3 + derelict-util (version?) - need instructions on handling basic package version dependency conflicts

2025-04-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 April 2025 at 04:41:14 UTC, Daniel Donnelly, Jr. wrote: When trying all 3 of these libraries together (just adding them with e.g. `derelict-gl3` so latest version) I get: ``` C:\Users\fruit\OneDrive\Desktop\MathProjects\DerelictTest\derelicttest2>dub generate visuald Error Unres

Re: How do I call a context objects destructor or some type of exit() function automatically upon exiting a with {} scope?

2025-04-01 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 April 2025 at 16:54:50 UTC, Daniel Donnelly, Jr. wrote: I thought the destructor might automatically be called after with (new Context()) {} but it's not. Is there some sort of entry/exit functions like in Python? You've used `new`, which means it's allocated with the GC. In th

Re: bindbc, SDL

2025-03-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 March 2025 at 06:17:28 UTC, Claus D. Volko wrote: Well, well. Now my code builds but it seems that the call of SDL_Init fails. I wonder if SDL3.lib is okay since I built it myself using Visual Studio. Maybe there is some prebuilt version available somewhere? What do you mean

Re: I don't understand why dependencies are not imported.

2025-03-09 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 9 March 2025 at 12:01:41 UTC, Enamisu wrote: Thank you very much, it really works. It's a pity that I'll have to use a Windows virtual machine, it's not convenient. Well, if you're trying to do Windows programming, it's to be expected that you'll either need to be on Windows or c

Re: I don't understand why dependencies are not imported.

2025-03-09 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 8 March 2025 at 22:21:45 UTC, Enamisu wrote: I have errors when working with the `core.sys.windows.winnt` library. I use dub to compile the program. I don't understand why dependencies are not imported. Please help me understand the cause of the error. ``` enamisu@pc:~/Project

Re: Selective import seems to be importing more than just specified symbol

2025-01-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 January 2025 at 02:07:46 UTC, WhatMeWorry wrote: rdmd -main -unittest redblacktree.d This error is returned: honeycomb.d(11): Error: unable to read module `sdl` honeycomb.d(11):Expected 'bindbc\sdl.d' or 'bindbc\sdl\package.d' in one of the following import paths: im

Re: Proper way to raise awareness of a bug

2024-10-29 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 29 October 2024 at 16:59:48 UTC, Chris Piker wrote: Hi D There is a bug listed in the Bugzilla tracking tool that affected me the other day, [15526](https://issues.dlang.org/show_bug.cgi?id=15526). It's not a big problem, just an unexpected issue and seems easy to fix... by some

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

2024-04-21 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 21 April 2024 at 08:44:38 UTC, alex wrote: Hi guys. Trying to play with vibe-d and want to create separate web app, and cli app which can add admin users. When I just keep both files app.d and cli.d in source folder, I get an error that I can't have more then 1 main function. You

Re: Best way to use large C library in D as of 2024

2024-03-30 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 March 2024 at 05:01:32 UTC, harakim wrote: @D Language Foundation - This is a HUGE selling point. I had to use cups the other day and I just copied some code from a d file and linked the library. It was so easy I was suspicious but it worked. Using C from D is pretty much as

Re: DIP 1036e not on the DIPs list?

2024-02-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 23 February 2024 at 23:30:26 UTC, kdevel wrote: The DIP 1036e is not listed in https://github.com/dlang/DIPs/tree/master/DIPs is this intentional? The DIP process has been closed for a while now. Atila did write a proposal for Adam's implementation, and I'll add it to the repo

Re: pragma lib doesn't support static libraries?

2023-07-29 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 30 July 2023 at 05:28:32 UTC, ryuukk_ wrote: I should have explained exactly what i am doing.. Looks like it doesn't work when i compile in 2 step - compile with: ``dmd -c of=bin/game.o`` - link with: ``dmd bin/game.o`` When doing it this way, then it doesn't work However, when com

Re: Designated initializers to function argument

2023-07-28 Thread Mike Parker via Digitalmars-d-learn
On Friday, 28 July 2023 at 21:07:47 UTC, bachmeier wrote: On Friday, 28 July 2023 at 17:07:37 UTC, IchorDev wrote: No shit, it felt like an eternity. But it's still not in the spec...? I'd expect it to appear in the spec after there's a real release. This is the first I've heard of it bei

Re: GDC Compilation wtih Directory Present

2023-06-15 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 June 2023 at 06:38:17 UTC, Murloc wrote: Thanks! That works well. I thought that `module pack.file1` is implicitly there by default :') The compiler will use the file name as a default module name if you don't provide one, but that's *just* the module name. It doesn't take in

Re: GetInterfaceInfo function of win32 api

2023-06-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 June 2023 at 07:01:44 UTC, Benny wrote: I got something! thank you. now I need to understand how can I get the properties of the GetInterfaceInfo ``` import core.sys.windows.iphlpapi; import std.stdio; import core.stdc.stdlib; void main() { uint* i; i =

Re: GetInterfaceInfo function of win32 api

2023-06-07 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 June 2023 at 05:52:43 UTC, Benny wrote: ``` ``` app.obj : error LNK2019: unresolved external symbol GetInterfaceInfo referenced in function _Dmain app.exe : fatal error LNK1120: 1 unresolved externals Error: linker exited with status 1120 ``` That's a linker error telling you

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:29:35 UTC, Richard (Rikki) Andrew Cattermole wrote: On 06/06/2023 2:25 AM, Mike Parker wrote: On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you prob

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test The docs say it should work: https://dlang.org/spec/betterc.html#unittests So eith

Re: How does D’s ‘import’ work?

2023-06-03 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 3 June 2023 at 09:04:35 UTC, Dom DiSc wrote: You can replace your whole makefile by calling the compiler with -I (not always, but if you don't do funny things in your makefile). That would be `-i`. - This ability of the D compiler was just recently discovered (after -I was imp

Re: How static link dll msvcr120.dll?

2023-06-01 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 1 June 2023 at 15:05:40 UTC, Marcone wrote: I linked msvcr120.lib, but the executable still ask for msvcr120.dll not found. msvcr120.lib is a "link library", not a static library. On other systems, you pass shared libraries directly to the linker and it will pull the informati

Re: A Programmer's Dilema: juggling with C, BetterC, D, Macros and Cross Compiling, etc.

2023-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 May 2023 at 09:17:14 UTC, Eric P626 wrote: This is a false dilemma: D has full C compatibility. From what I understand, D can use C, but C cannot use D? It's like C++: C++ can call C but C cannot call C++. 50% or more of my code will be put in re-usabled libraries. If I want pe

Re: A Programmer's Dilema: juggling with C, BetterC, D, Macros and Cross Compiling, etc.

2023-05-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 May 2023 at 09:35:59 UTC, Dukc wrote: hard. Seems the C-linked functions in [core.runtime](https://dlang.org/phobos/core_runtime.html#.Runtime.initialize) ought to do the trick. If you're referring to `rt_init` and `rt_term` are the `extern(C)` functions in `core.runtime`. It's no

Re: Making a D library for a C executable

2023-04-27 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 27 April 2023 at 20:32:24 UTC, Jan Allersma wrote: ``` Apparently foo isn't found from the CPP source file. Anyone some ideas on how to solve this? :) That's a compilation error, not a linker problem. You need to tell the compiler about the function with a prototype: ```C++ #i

Re: Cannot get this C++ example migrated to D

2023-04-16 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 April 2023 at 07:46:53 UTC, Skippy wrote: I wish D had value type classes as well. I like the distinction between class and struct in D. It encourages you to think harder about how you intend to use your types. In C++, there may as well only be one or the other; the distincti

Re: Cannot get this C++ example migrated to D

2023-04-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 April 2023 at 05:58:39 UTC, Skippy wrote: These lines aren't necessary: // ?? int counter; // ?? static this() { counter = test.objCnt; } `t1` is default-initialized, so it's null. test t1, t2 = new test(); Ditto for t3. Classes are reference objects, not value obje

Re: Unresolvable dependencies to package

2023-04-14 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 April 2023 at 00:42:17 UTC, Mike Parker wrote: I also suggest you visit the issues page for bindbc-imgui and file an issue there: I meant to delete this line. I've filed the issue: https://github.com/BindBC/bindbc-imgui/issues/1

Re: Unresolvable dependencies to package

2023-04-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 April 2023 at 20:30:56 UTC, el machine code wrote: so my question why am i'm getting this error and how do i fix this? The two listed packages depend on bindbc-sdl, and they do so in a way that is incompatible with each other. On your end, you can edit `dub.selections.json` in

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-09 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 9 April 2023 at 09:54:26 UTC, Ki Rill wrote: Why can't it find these libraries? I tell where to look for them: ```D version(Windows) { import bindbc.loader; setCustomLoaderSearchPath("libs"); // tried using absolute path as well } ``` That is strange... I've tried your

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-08 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 8 April 2023 at 11:31:40 UTC, Ki Rill wrote: How do I set up a D and SFML project using the `bindbc-sfml` package? I tried following the instructions, it builds successfully, but fails to load the SFML library at runtime. In particular, `loadSFML, loadSFMLGraphics, loadSFMLXXX`

Re: #define-like behavior

2023-03-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 05:47:35 UTC, Jeremy wrote: Hi, in C and C++ you can use #define to substitute a value in place of an identifier while preprocessing. If you initialize a new string and don't change its value after that, will the compiler substitute the string identifier with its va

Re: Code organization, dub, etc.

2023-03-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 March 2023 at 13:20:21 UTC, Joe wrote: Yeah, it seems like it's *only* for libraries (and a few single-exe utilities). Looking at code.dlang.org, under "Stand-alone applications/Server software", the top rated item is "handy-httpd" which according to its dub.json builds a libra

Re: Directly compiling a D program with other libraries

2023-03-13 Thread Mike Parker via Digitalmars-d-learn
On Monday, 13 March 2023 at 05:05:27 UTC, Jeremy wrote: Hello, I am new to this forum and to D. I am trying to compile a basic D program with libraries (`requests` which requires `cachetools` and `automem`) without using dub. I have never used dub before, only a compiler. The folders contain

Re: @nogc and Phobos

2023-03-11 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 11 March 2023 at 12:04:25 UTC, bomat wrote: So my question is: Is Phobos essentially incompatible to `@nogc`? Or is there a trick for mixing GC code with non-GC code that I don't know? I'm assuming the second, for if the first was true I'd say that D would be pretty much useless

Re: How to build a static lib properly?

2023-03-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 March 2023 at 02:09:23 UTC, ryuukk_ wrote: dub should build a static library for the project i build, that includes each library it uses that are referenced as "library" since the default is "staticLibrary" according to rikki What you're asking for is a different use case. `st

Re: How to build a static lib properly?

2023-03-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 March 2023 at 01:52:06 UTC, ryuukk_ wrote: 6B71D90\dparse.lib -g ``` Are you saying dub doesn't build a static dcd.lib? What to do to make it so i get a static dcd.lib file that contains all the code it needs? This comfort me in my desire to no longer use dub ever This is not

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-19 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 February 2023 at 06:26:34 UTC, FeepingCreature wrote: There have now been three pages produced by three people all agreeing with each other. At what point does it start being spam? Yes, it's all just noise now. Let's end it here. Further posts in this thread will be deleted

Re: Dub is not finding the dynamic link library MSVCR120.dll...

2023-02-19 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 February 2023 at 21:05:33 UTC, WhatMeWorry wrote: and is abending with an error saying exactly this. How do I specify the path to this library? Can I use one of the environment variables in sc.ini, one of the Windows env variables, or one of the dub options? Btw, I'm bypassi

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 16 February 2023 at 02:26:44 UTC, Mike Parker wrote: Wrong. I'm arguing things: Geez. "I'm arguing 2 things:"

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 20:10:31 UTC, ProtectAndHide wrote: What Mike is arguing, is that I don't need a 'data hiding' mechanism for a user-defined type, because that is already provided to me by the 'data hiding' mechanism of the module. That is his argument. My argument is tha

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 09:51:41 UTC, zjh wrote: What if two classes in the module that are several meters apart make `mistakes` that change the privite variable of `another class`? No one can guarantee that after `a few months`, even if you are the author, you will not make mist

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 08:56:00 UTC, Mike Parker wrote: If private were restricted to the class/struct, it would add anything more for encapsulation in D. I meant to say, it "wouldn't add more".

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 07:23:39 UTC, thebluepandabear wrote: Why is the unit of encapsulation the module though? Makes no sense. What is the purpose of encapsulation? To keep the implementation details hidden behind the public API, such that changing the implementation doesn't

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 01:16:00 UTC, thebluepandabear wrote: I think what you could say is that D lacks _encapsulation_ which is also an OOP concept. So D is partially OOP but not fully OOP due to there being no encapsulation in the language. D does not lack encapsulation, it's

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:36:36 UTC, thebluepandabear wrote: I haven't been programming for a long time, but most of the other languages I used had such a namespace feature. Kotlin has something called an `object` which is essentially a namespace and it is great. The benefits of addi

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-22 Thread Mike Parker via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:11:17 UTC, thebluepandabear wrote: Sorry don't like that solution specifically. That's because it is a procedural implementation, not an OOP-style one. I don't know how much of the D community writes procedurally but I'm personally an OOP-type of guy. A cl

Re: (Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 January 2023 at 05:17:59 UTC, thebluepandabear wrote: (Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived` in

Re: Compile time vs run time -- what is the difference?

2022-12-27 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 December 2022 at 02:31:45 UTC, thebluepandabear wrote: In Java and some other languages, during compile time the code gets executed into Java bytecode. This also happens for C#. I don't know if there is an equivalent 'intermediate' language for D that your code gets transl

Re: Is there such concept of a list in D?

2022-12-19 Thread Mike Parker via Digitalmars-d-learn
On Monday, 19 December 2022 at 22:22:11 UTC, thebluepandabear wrote: No worries, hopefully a mod will explain why. I don't like when posts get removed for no reason :| I received a report of a possible troll in the forums. Looking at the posts collectively, I agreed, so deleted all of them.

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 yes

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 whe

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 ar

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 yo

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 n

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-02 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-02 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 para

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? (DUB

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

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 mark

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 confi

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] = C:\D\dmd2\windows\bin\..\..\src\pho

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 acce

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 erroneou

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 'c:\Users\fruit\.vscode\extensions\webfreak.code-d

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 hav

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 pas

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 pro

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(&WndProc);`

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 = ...; https://githu

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 instanti

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 strin

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 i

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

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 didn'

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 Haughton

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 s

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

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 stopp

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] ar

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 d

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: S

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? D

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. https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP

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 https://github.com/D-Programming-GDC/gcc/blo

  1   2   3   4   5   6   7   8   9   10   >