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.

Re: Dynamically binding to D code using extern(D)

2021-09-30 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 30 September 2021 at 22:30:30 UTC, jfondren wrote: 3. dynamic linking (option 2), performed arbitrarily at runtime, by your program. If linking fails, you can do whatever you want about that. That's actually "dynamic loading". https://en.wikipedia.org/wiki/Dynamic_loading

Re: Using D "rocket" logo in outside presentation

2021-09-28 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 September 2021 at 04:24:13 UTC, Chris Piker wrote: Hi D I'm to give a presentation to a combined NASA/ESA group in a few hours and would like to include a copy of the D "rocket" logo when mentioning new server side tools that I've written in D. Is such use of this

Re: Loading assimp

2021-09-28 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote: I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one

Re: Modules ... "import" vs. "compilation" ... what is the real process here?

2021-09-27 Thread Mike Parker via Digitalmars-d-learn
On Monday, 27 September 2021 at 17:38:29 UTC, james.p.leblanc wrote: Dear D-ers, I have trouble understanding "module imports" vs. "module compilations". A module is implemented in a source file. Though we often use the term "module" to refer to both, it may help to think in terms of

Re: MobI? Really?

2021-09-21 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 September 2021 at 16:14:52 UTC, Chris_D wrote: Thanks for the replies. jfondren: Sorry, but I am talking about documentation. For me, online web pages don't qualify; they are in the cloud, unreal, with no substance. Does anyone really read 300 pages online, in a web browser?

Re: How to simply parse and print the XML with dxml?

2021-09-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 September 2021 at 07:50:29 UTC, tastyminerals wrote: As for the dxml, I believe adding a small quick start example would be very beneficial for the newcomers. Especially, ppl like me who are not aware of the XML parser types and just need to extract text from an XML file.

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

2021-09-10 Thread Mike Parker via Digitalmars-d-learn
On Friday, 10 September 2021 at 11:20:10 UTC, eugene wrote: same picture with gdc 8.4.0 - one thread, no pthread_create() behind the scenes. GDC is stuck on a much older version of D. Iain has backported some bugfixes and optimizations, but featurewise it's mostly D 2.076. This is because

Re: Forum posting question ... how post a thread question with color syntax highlighting ??

2021-09-06 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 September 2021 at 13:23:21 UTC, Steven Schveighoffer wrote: I will note though, that some people use the mechanism for links that puts the link at the bottom of the post, and this can be annoying when you reply, if you don't include the link definition, it doesn't render

Re: Forum posting question ... how post a thread question with color syntax highlighting ??

2021-09-05 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 5 September 2021 at 23:24:16 UTC, someone wrote: Slightly off-topic but ... while-we-are-the-subject: I usually post with markdown enabled and enclose code within ```d Sometimes, I notice that replies to my posts came without markdown, and until now, I assumed not everyone likes

Re: Dustmite and linking error

2021-09-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 September 2021 at 08:19:53 UTC, JG wrote: As a small comment regarding dub. I can't help wondering if it really the best idea for each configuration to include everything by default and then have to exclude things? This means that when you add another configuration and source

Re: Question on Immutability

2021-08-31 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 31 August 2021 at 06:15:07 UTC, jfondren wrote: On Tuesday, 31 August 2021 at 05:42:22 UTC, ag0aep6g wrote: On 31.08.21 02:50, Mike Parker wrote: Member functions marked as immutable can be called on both mutable and immutable instances. That's not true. Demonstrated: Well

Re: Question on Immutability

2021-08-30 Thread Mike Parker via Digitalmars-d-learn
On Monday, 30 August 2021 at 23:27:07 UTC, Merlin Diavova wrote: ``` After playing around the above works, Great! However I have some questions First, why do the interfaces have to be defined as `immutable interface`? The interfaces cannot be changed at runtime or instantiated. It isn't

Re: Labelled @nogc Working With Inner Scopes

2021-08-30 Thread Mike Parker via Digitalmars-d-learn
On Monday, 30 August 2021 at 20:26:46 UTC, Benoît Dubreuil wrote: My question is: In the source file `dummy.dummy.d`, why the first labelled attributes `@safe` and `@nogc` have no effect inside the struct's scope? In other words, why do I need to repeat labelled attributes statements in

Re: Is it legal to remove a key from associative array while iterating over aa.keys if a foreach loop?

2021-08-29 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 29 August 2021 at 11:09:28 UTC, Steven Schveighoffer wrote: This is exactly the opposite! Sorry about that. I can't believe I mixed those up.

Re: Is it legal to remove a key from associative array while iterating over aa.keys if a foreach loop?

2021-08-29 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 29 August 2021 at 08:55:44 UTC, realhet wrote: Is it safe, or do I have to take a snapsot of the keys range like this? -> You shouldn't remove anything when iterating over `.keys` or `.values`. Use `.byKey` and `.byValue` instead to get ranges that are independent of the aa.

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 August 2021 at 14:46:56 UTC, Ki Rill wrote: On Friday, 27 August 2021 at 13:54:18 UTC, Steven Schveighoffer wrote: [...] How do I tell DUB where to look for `raylibdll.lib` and `raylib.dll`? Via `lflags` section? What if I put them in a different folder instead of the

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 August 2021 at 13:41:56 UTC, Ki Rill wrote: I have downloaded the pre-compiled binaries from the official [Raylib ](https://github.com/raysan5/raylib/releases/tag/3.7.0) repo. I'm not using Visual Studio. Only dub and a text editor. But assuming you are on a 64-bit system,

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Mike Parker via Digitalmars-d-learn
On Friday, 27 August 2021 at 13:21:04 UTC, Ki Rill wrote: I have a Raylib project on Windows using DUB. I've added raylib-d via `dub add`. But what I can't figure out is how to tell DUB to link against raylib library. I have the following project structure: ``` -> source ---> app.d ->

Re: dlang opengl / gl / glu /glut library.

2021-08-22 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 22 August 2021 at 12:22:41 UTC, Виталий Фадеев wrote: https://forum.dlang.org/post/s5pvtq$2q83$1...@digitalmars.com On Wednesday, 21 April 2021 at 19:54:35 UTC, rikki cattermole wrote: On 22/04/2021 7:51 AM, Alain De Vos wrote: import bindc.opengl; bindbc bindbc-opengl

Re: Non-consistent implicit function template specializations

2021-08-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 09:59:53 UTC, Rekel wrote: time in the future. Even bugs don't seem to get fixed in any timely manner (Not meant as an insult, just being realistic :/). We do have a paid Issue/Pull-Request manager now (Razvan Nitu), and he's prioritizing issues for strike teams

Re: Non-consistent implicit function template specializations

2021-08-17 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 09:59:53 UTC, Rekel wrote: When using implicit function templates, identical specialization yield different results. Example: ```d template TFoo(T){ void foo(){writeln("1");} } // #1 template TFoo(T : T[]) { void foo(){writeln("2");} } // #2 void

Re: how to import .lib library

2021-08-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 August 2021 at 10:40:36 UTC, jfondren wrote: Yeah, that's not possible. You either need the source or a set of D interface files that declares all the symbols you need. Meaning, it is possible. On Windows where I assume these .lib files are: I mentioned C libraries in an

Re: how to import .lib library

2021-08-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 August 2021 at 10:12:17 UTC, Timofeyka wrote: Thank you for your reply! I wanted to link to my project another project without source code. Yeah, that's not possible. You either need the source or a set of D interface files that declares all the symbols you need. The compiler

Re: how to import .lib library

2021-08-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 August 2021 at 09:49:39 UTC, Timofeyka wrote: Hello! I may have a very stupid question, but still. How do I include a .lib library? How to use it in your code? You don't import a .lib file. They are for the linker, not the compiler. How you make use of it depends on what sort of

Re: What exactly are the String literrals in D and how they work?

2021-08-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 August 2021 at 08:11:39 UTC, rempas wrote: I mean that in C, we can assign a string literal into a `char*` and also a `const char*` type without getting a compilation error while in D, we can only assign it to a `const char*` type. I suppose that's because of C doing explicit

Re: Create alias of same name in inner scope, bug or feature?

2021-08-13 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 14 August 2021 at 03:47:05 UTC, Tejas wrote: ```d import std; auto abc(T)(auto ref T a, auto ref T b){ return a+b; } auto def(T)(auto ref T a, auto ref T b){ return a*b; } alias macro_1 = abc; void main() { writeln(macro_1(15, 20)); alias macro_1 = def;// is

Re: Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-13 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 August 2021 at 21:36:35 UTC, Ruby The Roobster wrote: Thank you very much. The program runs successfully now. You've got another potential issue you should be aware of. You've name a member of your `Skeleton` as `init`. This may cause issues at some point, as every type in

Re: Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-13 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 August 2021 at 21:10:38 UTC, Steven Schveighoffer wrote: Well, subtracting the length doesn't do much, you aren't actually accessing the array block, you are just changing the reference (which lives in thread-local storage). I kind of feel like the whole entity table thing is

Re: Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-13 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 August 2021 at 16:18:06 UTC, Ruby The Roobster wrote: Context for this: I am creating a module of my own, and this is a class contained in the module. You will notice that after calling this class' constructor anywhere in a Win32 API program, that the program doesn't close

Re: Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 August 2021 at 00:30:59 UTC, Ruby The Roobster wrote: When I run the program and close the window, the program still runs in background mode. I don't know why this happens nor how to fix it. Does anybody know what's going on? frame beat me to it, but it may well be that

Re: DUB "Error: only one `main` allowed."

2021-08-11 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 09:38:13 UTC, tastyminerals wrote: Hahaha, I fixed it by renaming the `my_script.d` to `app.d`. Oh boy. What you want is the `mainSourceFile` entry. From the dub documentation, [under "Build Settings"][1]: Determines the file that contains the main()

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 19:03:06 UTC, Marcone wrote: On Tuesday, 10 August 2021 at 19:01:42 UTC, Adam D Ruppe wrote: On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote: Using -Lgdi32.lib -Luser32.lib? Same error. The part after that: If you want the Windows subsystem too, use

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 August 2021 at 10:43:01 UTC, wjoe wrote: Could you elaborate on ```version(assert)``` a bit more, please ? Like I compiled with ```-release, -g``` and without the 2 options but the ```assert``` branch was always taken. Could it be that ```-unittest``` has something to do

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` or ```-g``` options, which version identifier is supposed to be used ? There's no ```release``` identifier and

Re: alias using Complex!Double in module ... linker error??

2021-08-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 21:40:09 UTC, james.p.leblanc wrote: I am getting linker errors with this stripped-down example: --- **my_main.d:** import std.stdio; import std.complex; import my_module; void main(){ my_TYPE xxx;

Re: Name Mangling & its representation of D types

2021-08-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 16:43:52 UTC, NonNull wrote: how does it work for recursive types like a struct containing a pointer to a struct of the same type A struct `S` with a member of type `S*` is still just a struct `S`. The pointer doesn't change anything about the type.

Re: Name Mangling & its representation of D types

2021-08-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 16:43:52 UTC, NonNull wrote: I'd like to understand how any D type is represented as a string by the name mangling done by the compilers. Does this always have the desirable property that different types have different mangled names, so that a type is faithfully

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread Mike Parker via Digitalmars-d-learn
On Friday, 30 July 2021 at 08:38:24 UTC, dangbinghoo wrote: but, where's these switch option documented? it seems it not appears in dmd --help or man dmd, or online document https://dlang.org/dmd-linux.html That's what he meant by "hidden" switch. I don't know why it isn't documented,

Re: Raylib linking error

2021-07-29 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 29 July 2021 at 10:07:15 UTC, Ki wrote: On Thursday, 29 July 2021 at 07:59:38 UTC, Ki wrote: I tried to compile a new project with Raylib yesterday: dub init => ... => dub add raylib-d. My dub.json file does contain the "libs": ["raylib"] section, so the compiler links against

Re: byKeyValue is not available at compilation-time right ?

2021-07-26 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 25 July 2021 at 17:38:23 UTC, someone wrote: i.e. your AA initialization is copy-pasted into each use of it, which means your program is rebuilding this AA at runtime every time it comes up. You probably got to this point as a bare `immutable structureLocations` errored out to the

Re: Destructors can't be @nogc?

2021-07-24 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 25 July 2021 at 00:15:30 UTC, Jim wrote: But I think `destroy()` not being @nogc even though the destructor is tagged @nogc is a bug, and it should be fixed. Because it is problematic behaviour even if we limit the usage of @nogc. It's not a bug. The destructor being tagged has

Re: Destructors can't be @nogc?

2021-07-24 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 24 July 2021 at 09:45:01 UTC, Jim wrote: In that case, what should we use to check functions called from `main` are not using the garbage collector? When compiling, you can pass -vgc to dmd and it will tell you where GC allocations are possible. Because it seems like we

Re: Destructors can't be @nogc?

2021-07-23 Thread Mike Parker via Digitalmars-d-learn
On Friday, 23 July 2021 at 20:24:02 UTC, Jim wrote: What is the problem here? Should I not call `destroy`? If so, what should I call instead? The problem is that you've marked main as `@nogc`, and `destroy` is not `@nogc`. Remove the annotation from main and it will compile.

Re: betterC shared static ctor

2021-07-21 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 08:11:06 UTC, vit wrote: Is it possible to call all shared static ctors in betterC? ```d //-betterC static immutable int i; shared static this(){ i = 42; } extern(C) void main(){ assert(i != 42); } ``` These rely on DRuntime, which is not linked in

Re: Not allowed to globally overload operators?

2021-07-20 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote: Why isn't it working by default? Initially, I was trying to create the spaceship operator of C++, but we aren't allowed to create new operators, it seems. Then I just wanted to verify whether we can even overload an operator globally,

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 17:14:12 UTC, Mike Parker wrote: I haven't had occasion to make use of any serialization libraries myself, but you can start here: https://wiki.dlang.org/Serialization_Libraries Also: https://code.dlang.org/search?q=serialization

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 16:54:18 UTC, Scotpip wrote: Yup - I have it running now but the code does seem to be a bit neglected and I'm seeing a depreciation warning too. I chose it because it's much the most downloaded serialisation package and is used in a couple of other popular packages.

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 16:44:31 UTC, Scotpip wrote: Again, if this helps anyone my current setup is to have a single main() in app.d. I changed the main() in my sandboxes to runSandbox(), and I import and run from app.d rather than directly. Or with a couple of keystrokes I can switch to

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 15:31:49 UTC, Scotpip wrote: I'm completely stuck till I can get this fixed, so any help would be very much appreciated! I used the example from the readme at: https://code.dlang.org/packages/msgpack-d which I pasted into the generated `app.d`. And all the

Re: opIndexUnary post in-/decrement how to ?

2021-07-14 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 14 July 2021 at 12:35:07 UTC, wjoe wrote: On Wednesday, 14 July 2021 at 11:31:36 UTC, Tejas wrote: ``` {auto a = i[1] , ++i[1] , a} //note the , not the ;``` Sorry I can't provide something even more concrete. Yes I saw that, and I suppose it would work just fine if it were

Re: No rdmd.exe in /bin64 on Windows - is this an issue?

2021-07-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 July 2021 at 11:23:38 UTC, Scotpip wrote: Mike - thanks for responding! You say that there wasn't a Windows 64 bit release "for good reason". That sounds a bit ominous - I'd appreciate your insights into what was behind this. Nothing ominous. It was just because of the

Re: mixin template's alias parameter ... ignored ?

2021-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 July 2021 at 02:22:46 UTC, Mike Parker wrote: On Tuesday, 13 July 2021 at 01:03:11 UTC, someone wrote: Being *local* to ... ain't imply visibility too regardless scope not being a visibility attribute ? I mean, scope is restricting the variable to be leaked outside the

Re: mixin template's alias parameter ... ignored ?

2021-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 July 2021 at 01:03:11 UTC, someone wrote: Being *local* to ... ain't imply visibility too regardless scope not being a visibility attribute ? I mean, scope is restricting the variable to be leaked outside the function/whatever and to me it seems like restricted to be seen

Re: mixin template's alias parameter ... ignored ?

2021-07-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 12 July 2021 at 23:45:57 UTC, someone wrote: Regarding -preview=dip1000 (and the explicit error description that could have helped me a lot back then) : DMD man page says the preview switch lists upcoming language features, so DIP1000 is something like a D proposal as I glanced

Re: No rdmd.exe in /bin64 on Windows - is this an issue?

2021-07-12 Thread Mike Parker via Digitalmars-d-learn
On Monday, 12 July 2021 at 23:57:37 UTC, Scotpip wrote: Given that this will be the first encounter with the language for many users, you might want to consider addressing this to create a good first impression? For a long time, the installer did not include 64-bit binaries on Windows for

Re: Why I'm getting this "Range Violation" error?

2021-07-09 Thread Mike Parker via Digitalmars-d-learn
On Friday, 9 July 2021 at 07:21:06 UTC, rempas wrote: When I execute it, I'm getting a range violation error. If I try to set "len" to be the length of the "prompt" minus 1, then it will work and it will print the "prompt" until the questionmark. So I cannot find where the error is...

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

2021-07-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 6 July 2021 at 13:27:43 UTC, Jack Applegame wrote: And that's sad. It should happen for properties only. Totally disagree. This is one of my favorite D features.

Re: Find a char among string (string.findAmong.char)

2021-07-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 6 July 2021 at 11:35:14 UTC, BoQsc wrote: I tried out .canFind method, and to test it I removed the letter 'o' from the Alphabet. Weirdly enough .canFind method still found 'o' letter among the Alphabet. https://run.dlang.io/is/2Fvenf Looks like it has something to do with the

Re: Remove array element within function

2021-07-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 July 2021 at 14:30:11 UTC, Mike Parker wrote: You never copy the contents of a dynamic array/slice. That only comes into play with static arrays: I should rephrase that. You aren't going to copy the contents of an array/slice just by passing it to a function.

Re: Remove array element within function

2021-07-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 July 2021 at 13:34:50 UTC, Rekel wrote: Ah, ref, thanks, I didn't know if that would work as I was confused since arrays themselves are kind of already pointers. Except they're not :-) Think of them as struct instances with length and pointer fields. That's actually what they

Re: Remove array element within function

2021-07-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 July 2021 at 13:41:59 UTC, Rekel wrote: I'm not sure if this is the place to talk about it, but on the same topic it's a little strange to me neither the Dlang Tour nor the arrays spec page mention removing elements. Even though basically everyone is going to use it sooner or

Re: Remove array element within function

2021-07-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 July 2021 at 13:10:55 UTC, Rekel wrote: Am I the only one slightly unamused by how arrays/ranges work? They keep backfiring on me, or require weird additions other languages wouldn't require such as manually changing .length, or worrying about what operation returns a copy etc.

Re: Remove array element within function

2021-07-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 July 2021 at 13:10:55 UTC, Rekel wrote: But what do you do when you have?: ```d void function(int[] a){ . . . long index = countUntil(a, element); a.remove(index); } ``` ```d void function(ref int[] a) { ... } ``` An array is effectively a length/pointer

Re: Is there an alias for standard libraries to use in import statement?

2021-07-04 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 4 July 2021 at 07:40:44 UTC, BoQsc wrote: I just started with a fresh look at the D language and would like to be able to rewrite this code: import std; void main() { writeln("Hello D"); } Into more readable standard library name: import system; void main() {

Re: Are D classes proper reference types?

2021-06-28 Thread Mike Parker via Digitalmars-d-learn
On Monday, 28 June 2021 at 06:13:06 UTC, Ola Fosheim Grøstad wrote: I don't have much time for chat, I prefer async communication. Slack isn't like our IRC or Discord channels. It's more async like the forums.

Re: what is D's idiom of Python's list.extend(another_list)?

2021-06-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 June 2021 at 08:40:47 UTC, ag0aep6g wrote: `~` works just fine with single elements: void main() { import std.stdio; int[] a = [2, 3, 4]; writeln(1 ~ a ~ 5); /* [1, 2, 3, 4, 5] */ } Cool. I've had it in my head for many years now that this

Re: what is D's idiom of Python's list.extend(another_list)?

2021-06-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 June 2021 at 06:16:15 UTC, mw wrote: Ha! great. I didn't know `~` works for both single elements and array! `~` by itself is the concatenation operator and only works with two array operands. `~=` is the append operator and can append arrays or single elements.

Re: what is D's idiom of Python's list.extend(another_list)?

2021-06-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 June 2021 at 05:36:36 UTC, mw wrote: i.e append an array of elements into another array: ```Python x = [1, 2, 3] x.extend([4, 5]) print(x) # [1, 2, 3, 4, 5] ``` Thanks. ```d x ~= [4, 5]; ```

Re: Can not get struct member addresses at compile time

2021-06-16 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 16 June 2021 at 13:26:43 UTC, jfondren wrote: Is this a bug? Probably. Please file an issue if there isn't one already: https://issues.dlang.org/

Re: Can not get struct member addresses at compile time

2021-06-16 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 16 June 2021 at 09:27:25 UTC, Doeme wrote: Is there an alternative to get to this point? Static module initializers are not really an option, since the whole thing should be -betterC. ```D import core.stdc.stdio; struct Foo{ ubyte bar; } __gshared Foo foo; void* baz =

Re: In general, who should do more work: popFront or front?

2021-06-15 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 15 June 2021 at 04:24:09 UTC, surlymoor wrote: At the moment, I feel that as long as the stashed front element isn't too "big" (For some definition of big, I guess.), that built-in caching should be fine. But is this acceptable? What's the best practice for determining which

Re: There are some Feed RSS or mail alert for new Dlang compiler update?

2021-06-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 June 2021 at 21:42:27 UTC, jfondren wrote: On Saturday, 12 June 2021 at 21:20:23 UTC, Marcone wrote: Becouse I can not find it. https://dlang.org/blog/category/dmd-releases/rss takes you to https://feeds.feedburner.com/OfficialDBlog which includes everything, but still has

Re: There are some Feed RSS or mail alert for new Dlang compiler update?

2021-06-12 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 12 June 2021 at 21:20:23 UTC, Marcone wrote: Becouse I can not find it. Your best bet is to subscribe to the announce mailing list: http://lists.puremagic.com/cgi-bin/mailman/listinfo/digitalmars-d-announce Martin announces every compiler release using the title "Release D

Re: Problem with Exceptions in Constructor

2021-06-11 Thread Mike Parker via Digitalmars-d-learn
On Friday, 11 June 2021 at 20:09:22 UTC, Mike Brown wrote: The error is flagged on the writeln(e.msg). Do I need to do something special to pass a string to an exception? dup? No, that code is fine. You're passing a string literal, so there's no need for a dup.

Re: LNK2019 error in the C++ interface

2021-06-10 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 10 June 2021 at 13:19:34 UTC, dokutoku wrote: I still haven't solved this problem. Not sure if this is the issue, but you don't need `extern` on these. You already have the `extern(C++)` thing at the top of the file. ```d extern void str_test(LPCSTR str1);

Re: how do i fix this node_dlang error?

2021-06-07 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 8 June 2021 at 00:58:12 UTC, Jack wrote: the dll which I was just build with dub command? how I have a version mismatch if they're the very same file? Electron embeds node and does not use whatever you have on your system. So if there’s a mismatch between the embedded version and

Re: how do i fix this node_dlang error?

2021-06-07 Thread Mike Parker via Digitalmars-d-learn
On Monday, 7 June 2021 at 22:24:03 UTC, Jack wrote: I think the entry point function is ```void atStart(napi_env env) {}``` so there's no DllMain... DLLMain is not strictly required. It's called by the system loader when the DLL is first loaded into the process. The MainFunction for node

Re: Receiving "pthread_mutexattr_init" during compilation when using FileLogger.

2021-06-07 Thread Mike Parker via Digitalmars-d-learn
On Monday, 7 June 2021 at 11:31:13 UTC, tastyminerals wrote: It's interesting how there is no information about class instantiation at module level anywhere in the docs. Even the Ali's book does not explicitly say that you cannot instantiate a class this way. Maybe I totally missed it but

Re: Receiving "pthread_mutexattr_init" during compilation when using FileLogger.

2021-06-07 Thread Mike Parker via Digitalmars-d-learn
On Monday, 7 June 2021 at 09:29:08 UTC, tastyminerals wrote: I getting ``` import/core/sync/mutex.d(87,36): Error: `pthread_mutexattr_init` cannot be interpreted at compile time, because it has no available source code ``` compile time error. One of those D exceptions which doesn't say where

Re: how do i fix this node_dlang error?

2021-06-06 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 6 June 2021 at 15:42:55 UTC, Jack wrote: 0.4.11\node_dlang\source\node_dlang.d(137,11): Error: none of the overloads of `this` are callable using argument types `(string, string, ulong, Throwable)`, candidates are: C:\D\dmd2\windows\bin\..\..\src\druntime\import\object.d(2440,30):

Re: how do i fix this node_dlang error?

2021-06-06 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 6 June 2021 at 04:25:39 UTC, Jack wrote: I'm trying to use the node_dlang pakckage but the code example from [this repo](https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples) isn't working the command ```dub build``` is fine but ```node example.js``` retuns an error

Re: Schroedinger's Ranges

2021-06-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 June 2021 at 10:18:25 UTC, kdevel wrote: a) What is the rationale behind not making byLineCopy the default? byLine was the original implementation. byLineCopy was added later after the need for it became apparent.

Re: Schroedinger's Ranges

2021-06-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 June 2021 at 10:30:24 UTC, Mike Parker wrote: On Thursday, 3 June 2021 at 10:18:25 UTC, kdevel wrote: a) What is the rationale behind not making byLineCopy the default? byLine was the original implementation. byLineCopy was added later after the need for it became apparent.

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

2021-05-31 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 03:18:22 UTC, someone wrote: On Sunday, 30 May 2021 at 12:27:34 UTC, Siemargl wrote: You forget semi-official DWT For starters I was advised that it is in not good shape. Another one going down :( But have you actually investigated it? It's being actively

Re: how to specify a default configuration in a library's dub.json? (i.e if the use doesn't not have subConfigurations)

2021-05-25 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 26 May 2021 at 00:19:23 UTC, mw wrote: Hi, I just did a build fix, and added two configurations to thrift's dub.json (whose "targetType": "library") https://github.com/apache/thrift/pull/2397/files I want to know how to specify a default configuration in the library's

Re: ugly and/or useless features in the language.

2021-05-23 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 23 May 2021 at 14:13:36 UTC, Alain De Vos wrote: This one compiles without any problem. Maybe someone can enlighten us on the status of scope(d)-variables and dip-1000. It is not fully clear for me. ``` import std.stdio; void main() @trusted { int *q=null; { int a;

Re: DUB doesn't seem to respect my config, am I doing something wrong?

2021-05-22 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote: I'm compiling using `dub --config=development` and I'm getting the following line: `Performing "debug" build using /usr/bin/dmd for x86_64`. The same exactly happens when I'm trying to do the release config. If I disable the `targetType`

Re: How to import the types mapresult and filterresult

2021-05-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 18 May 2021 at 12:15:25 UTC, Alain De Vos wrote: Something like: import X.Y.Z:mapresult ; You don't. The types returned by map, filter, and other algorithms are not public. They're "Voldemort", or anonymous, types. Instances aren't generally intended to be stored, but rather to

Re: Filter for opDispatch?

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 04:07:15 UTC, frame wrote: But the same with fields work? They are also protected. I'm not sure what you mean by "fields" here.

Re: Filter for opDispatch?

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 00:04:39 UTC, frame wrote: Yes, but why should the derived class not have access to it? I don't think that's your problem. From the template docs: _TemplateInstances_ are always instantiated in the scope of where the _TemplateDeclaration_ is declared... Your

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:25:10 UTC, Chris Piker wrote: Thanks for your patience with a potentially dumb question. I've been working on the code for well over 12 hours so I'm probably not thinking straight it this point. BTW, I can send you a couple of documents regarding ranges that

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:25:10 UTC, Chris Piker wrote: Is there some obvious trick or way of looking at the problem that I'm missing? In addition to what Adam said, if you do need to store the result for use in a friendlier form, just import `std.array` and append `.array` to the

Re: Scope of import

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:15:51 UTC, DLearner wrote: On Saturday, 15 May 2021 at 07:05:00 UTC, Mike Parker wrote: That's odd. What's your command line? rdmd main.d Okay, so it's definitely a bug in rdmd. Change module A to look like this and it works properly: ```d module A;

  1   2   3   4   5   6   7   8   9   10   >