Re: Using C header libs with importC

2024-01-09 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 January 2024 at 21:56:10 UTC, Renato wrote: [snip] Importing .h files from d files isn't supported yet because of a dispute with the lookup priority: https://issues.dlang.org/show_bug.cgi?id=23479 https://issues.dlang.org/show_bug.cgi?id=23547 Ah, too bad. Anyway, I was just

Re: Symbolic computations in D

2023-10-30 Thread jmh530 via Digitalmars-d-learn
On Monday, 30 October 2023 at 13:24:56 UTC, Sergey wrote: On Monday, 30 October 2023 at 13:13:47 UTC, jmh530 wrote: On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote: Julia is more an alternative to R, Matlab, Python than C++. Not really. Many especially popular and widely used

Re: Symbolic computations in D

2023-10-30 Thread jmh530 via Digitalmars-d-learn
On Sunday, 29 October 2023 at 10:44:03 UTC, ryuukk_ wrote: [snip] This is sad that people recommend OOP for this Julia doesn't have OOP and it took over, and that's what i'd recommend your students to check, C++ is a dead end, Julia it is for mathematical computing If D had tagged union

Re: Visual Studio 2022 no longer debugs D program, need an alternative debugger for Windows

2023-08-26 Thread jmh530 via Digitalmars-d-learn
On Saturday, 26 August 2023 at 16:57:42 UTC, solidstate1991 wrote: After a recent update, Visual Studio 2022 started to have serious troubles with D, namely having troubles with displaying debug variables, and growing constantly in memory until you either stop debugging or crashes Windows.

Re: Mir-algorithm tutorial?

2023-08-18 Thread jmh530 via Digitalmars-d-learn
On Friday, 18 August 2023 at 12:14:45 UTC, Ferhat Kurtulmuş wrote: On Friday, 18 August 2023 at 09:57:11 UTC, Ki Rill wrote: [...] Yes there isn't many guides around. Those are some of them. https://tastyminerals.github.io/tasty-blog/dlang/2020/03/22/multidimensional_arrays_in_d.html

Re: Mir-algorithm tutorial?

2023-08-18 Thread jmh530 via Digitalmars-d-learn
On Friday, 18 August 2023 at 08:06:10 UTC, Ki Rill wrote: On Friday, 18 August 2023 at 07:57:05 UTC, Ki Rill wrote: On Friday, 18 August 2023 at 07:54:04 UTC, Ki Rill wrote: Is there an up-to-date tutorial? It's just painful that I cannot find anything helpful on this topic. The official

Re: std.sumtyp and option ?

2023-06-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 June 2023 at 14:18:05 UTC, kiriakov wrote: How to create option type over std.sumtype ? ``` enum None; struct Some(T) { T x; } alias Option = SumType!(Some!T, None); ``` I get Error: undefined identifier `T` Try ```d alias Option(T) = SumType!(Some!T, None); ``` Your version

Re: Best way to use C library

2023-05-19 Thread jmh530 via Digitalmars-d-learn
On Friday, 19 May 2023 at 18:31:45 UTC, Maximilian Naderer wrote: Hello guys, So what’s currently the best way to use a big C library? Let’s assume something like cglm assimp glfw ImportC doesn’t really work for such huge libraries, I’ll investigate further. Deimos is outdated or there are

Re: Any working REPL program on windows? DREPL doesn't compile

2023-03-23 Thread jmh530 via Digitalmars-d-learn
On Thursday, 23 March 2023 at 11:46:48 UTC, matheus wrote: On Thursday, 23 March 2023 at 09:39:40 UTC, John Xu wrote: Anybody know any working REPL program? I failed to find a working one. https://github.com/dlang-community/drepl can't compile on my Windows 10, dub reports: ... According to

Re: Preventing the Compiler from Optimizing Away Benchmarks

2023-03-13 Thread jmh530 via Digitalmars-d-learn
On Monday, 13 March 2023 at 15:23:25 UTC, user1234 wrote: [snip] [1] https://theunixzoo.co.uk/blog/2021-10-14-preventing-optimisations.html that's illegal code. You mix GCC/LLVM syntax with D asm block and the front-end wont recognize that. LDC recognizes a syntax similar to what is

Preventing the Compiler from Optimizing Away Benchmarks

2023-03-13 Thread jmh530 via Digitalmars-d-learn
I was looking at [1] for ways to prevent the compiler from optimizing away code when trying to benchmark. It has the following C++ code as a simpler version: ``` inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) { asm volatile("" : "+r,m"(value) : : "memory"); } ``` I made an

Re: dub.selections.json & optional dependencies: How's it work?

2023-02-24 Thread jmh530 via Digitalmars-d-learn
On Friday, 24 February 2023 at 19:37:41 UTC, Steven Schveighoffer wrote: On 2/24/23 2:01 PM, jmh530 wrote: I'm looking at the dub package format [1] about optional dependencies and it says: "With this set to true, the dependency will only be used if explicitly selected in

dub.selections.json & optional dependencies: How's it work?

2023-02-24 Thread jmh530 via Digitalmars-d-learn
I'm looking at the dub package format [1] about optional dependencies and it says: "With this set to true, the dependency will only be used if explicitly selected in dub.selections.json. If omitted, this attribute defaults to false." And it occurs to me that I don't know anything about how

Combining Templates While Minimizing Bloat

2023-02-14 Thread jmh530 via Digitalmars-d-learn
The code below has two `foo` functions that take slices, one accepts a const(T)* iterator and one accepts a generic Iterator with the property that the slice isn't convertible to the first one. The nice thing about this is that if you pass it with a double* or const(double)*, then it doesn't

Re: Assign to Array Column

2023-02-01 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 1 February 2023 at 13:14:47 UTC, Siarhei Siamashka wrote: On Tuesday, 31 January 2023 at 01:04:41 UTC, Paul wrote: Greetings, for an array byte[3][3] myArr, I can code myArr[0] = 5 and have: 5,5,5 0,0,0 0,0,0 Can I perform a similar assignment to the column? This, myArr[][0]

Re: Solving optimization problems with D

2023-01-03 Thread jmh530 via Digitalmars-d-learn
On Sunday, 1 January 2023 at 22:00:29 UTC, max haughton wrote: On Sunday, 1 January 2023 at 21:11:06 UTC, Ogi wrote: I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread jmh530 via Digitalmars-d-learn
On Sunday, 4 December 2022 at 23:25:34 UTC, Adam D Ruppe wrote: On Sunday, 4 December 2022 at 22:46:52 UTC, Ali Çehreli wrote: That's way beyond my pay grade. Explain please. :) The reason that the GC stops threads right now is to ensure that something doesn't change in the middle of its

Re: Hipreme's #4 Tip of the day - Don't use package.d

2022-11-04 Thread jmh530 via Digitalmars-d-learn
On Friday, 4 November 2022 at 19:17:04 UTC, Adam D Ruppe wrote: On Friday, 4 November 2022 at 19:10:33 UTC, jmh530 wrote: If you don't plan to use private(package_name), then I don't know what the point of it is. This works fine without the package.d anyway. Oh really, then what's the point

Re: Hipreme's #4 Tip of the day - Don't use package.d

2022-11-04 Thread jmh530 via Digitalmars-d-learn
On Friday, 4 November 2022 at 16:56:59 UTC, Hipreme wrote: [snip] You can use any name instead. The only difference between an ordinary source file and a package.d is the module name. For instance, if you're inside the filesystem directory, you can change the name to literally anything and

Re: Catching C errors

2022-10-20 Thread jmh530 via Digitalmars-d-learn
On Thursday, 20 October 2022 at 11:59:45 UTC, data pulverizer wrote: [snip] Mine is also private for now till it reaches an acceptable state when I'll think about whether it should be publicly released or jealously guarded. It's a project I'm building for my own use really. It can't hurt to

Re: library to solve the system of linear equations

2022-10-17 Thread jmh530 via Digitalmars-d-learn
On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote: Dear All, Thank you so much for your replies and hints! I got it working today. All the libraries are properly linked and the Equation solver runs smoothly. The compilers turned out to be problematic though. The "Mir" library does not

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-03 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 October 2022 at 21:18:43 UTC, mw wrote: [snipping] A CSV library should consider all the use cases, and allow users to ignore certain fields. In R, you have to force `NULL` for `colClasses` for the other columns. In other words, the user has to know the number of columns of

Re: Best way to read CSV data file into Mir (2d array) ndslice?

2022-09-21 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 21 September 2022 at 13:08:14 UTC, jmh530 wrote: On Wednesday, 21 September 2022 at 05:31:48 UTC, mw wrote: Hi, I'm just wondering what is the best way to read CSV data file into Mir (2d array) ndslice? Esp. if it can parse date into int/float. I searched a bit, but can't

Re: Best way to read CSV data file into Mir (2d array) ndslice?

2022-09-21 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 21 September 2022 at 05:31:48 UTC, mw wrote: Hi, I'm just wondering what is the best way to read CSV data file into Mir (2d array) ndslice? Esp. if it can parse date into int/float. I searched a bit, but can't find any example. Thanks. It probably can't hurt to try the

Re: plot api

2022-09-14 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 14 September 2022 at 19:34:56 UTC, Alain De Vos wrote: Let's say i want to plot the function f(x)=sin(x)/x. Which API would you advice, in order for me to not re-invent the wheel. Have you tried ggplotd? https://code.dlang.org/packages/ggplotd

Re: C function taking two function pointers that share calculation

2022-09-14 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 14 September 2022 at 18:02:07 UTC, JG wrote: [snip] Maybe others know better but I would have thought the only way is to use globals to do this. Often c libraries that I have used get round this by taking a function and a pointer and then the library calls your function on the

C function taking two function pointers that share calculation

2022-09-14 Thread jmh530 via Digitalmars-d-learn
There is a C library I sometimes use that has a function that takes two function pointers. However, there are some calculations that are shared between the two functions that would get pointed to. I am hoping to only need to do these calculations once. The code below sketches out the general

Re: Function attribute best practices

2022-09-13 Thread jmh530 via Digitalmars-d-learn
On Monday, 12 September 2022 at 16:39:14 UTC, Paul Backus wrote: [snip] Yes. Except for `@trusted`, explicit attributes on template code are a smell. [snip] If I can be 100% sure that something will always be @safe/nothrow/pure/@nogc, then I might consider marking them as such. For

Re: importC and cmake

2022-09-07 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 7 September 2022 at 00:31:53 UTC, zjh wrote: On Tuesday, 6 September 2022 at 19:44:23 UTC, jmh530 wrote: . `xmake` is simpler. Ok...but I didn't write the library so I can't exactly tell them to use xmake when they already use cmake.

importC and cmake

2022-09-06 Thread jmh530 via Digitalmars-d-learn
I was thinking about trying out importC with a library I have used in the past (it's been a few years since I used it with D). The library uses cmake to generate static or dynamic libraries (I believe I did static with Windows and dynamic with Linux, but I can't really recall). My

Re: Implicit integer conversions Before Preconditions

2022-05-24 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 21:05:00 UTC, Steven Schveighoffer wrote: [snip] ```d // e.g. foo(int x) in (x >= 0) { return foo(uint(x)); } ``` And remove those useless `in` conditions on the unsigned versions, an unsigned variable is always >= 0. -Steve Thanks. That makes perfect sense.

Implicit integer conversions Before Preconditions

2022-05-24 Thread jmh530 via Digitalmars-d-learn
In the code below, `x` and `y` are implicitly converted to `uint` and `ushort` before the function preconditions are run. Is there any way to change this behavior? It feels unintuitive and I can't find in the spec where it says when the conversions in this case occur, but it clearly happens

Re: What are (were) the most difficult parts of D?

2022-05-12 Thread jmh530 via Digitalmars-d-learn
On Thursday, 12 May 2022 at 15:32:24 UTC, Adam D Ruppe wrote: On Thursday, 12 May 2022 at 15:18:34 UTC, jmh530 wrote: What's the difference between a Type and Type Identifier? The is expression roughly follows variable declaration style. You write int a; to declare a new symbol named `a`

Re: What are (were) the most difficult parts of D?

2022-05-12 Thread jmh530 via Digitalmars-d-learn
On Thursday, 12 May 2022 at 12:13:32 UTC, Basile B. wrote: [snip] ``` is ( Type : TypeSpecialization , TemplateParameterList ) is ( Type == TypeSpecialization , TemplateParameterList ) is ( Type Identifier : TypeSpecialization , TemplateParameterList ) is ( Type Identifier == TypeSpecialization

Re: What are (were) the most difficult parts of D?

2022-05-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 09:06:52 UTC, bauss wrote: On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali dip1000

Re: Including C sources in a DUB project

2022-05-10 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 20:50:12 UTC, Alexander Zhirov wrote: On Tuesday, 10 May 2022 at 19:13:21 UTC, Dennis wrote: It has an example directory: https://github.com/dlang/dub/tree/master/examples And if there are two compilers in the system - `dmd` and `ldc`, which compiler chooses

Re: Including C sources in a DUB project

2022-05-10 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 19:13:21 UTC, Dennis wrote: [snip] It has an example directory: https://github.com/dlang/dub/tree/master/examples If your configuration is missing, you could make a Pull Request to add it. So it does. Thanks. We might also link to that on the dub.pm website.

Re: Including C sources in a DUB project

2022-05-10 Thread jmh530 via Digitalmars-d-learn
On Monday, 9 May 2022 at 09:17:06 UTC, Alexander Zhirov wrote: [snip] It would be nice if dub included a directory of example configurations for common issues like this.

Re: Compile delegate with enum into proper function?

2022-05-08 Thread jmh530 via Digitalmars-d-learn
On Sunday, 8 May 2022 at 03:58:06 UTC, Tejas wrote: [snip] If there is only one possible value for the overload, is there an issue with using default arguments? [snip] Default arguments are intended to be resolved at runtime. That is, if you compile a function with two parameters and one

Re: Compile delegate with enum into proper function?

2022-05-07 Thread jmh530 via Digitalmars-d-learn
On Saturday, 7 May 2022 at 23:30:37 UTC, Paul Backus wrote: [snip] Worth noting that you *can* write ```d alias foo = partial!(foo, a); ``` ...which will add the partially-applied version to `foo`'s overload set. You sure about that? Below fails to compile on godbolt with ldc 1.27.1 [1].

Re: Compile delegate with enum into proper function?

2022-05-07 Thread jmh530 via Digitalmars-d-learn
On Saturday, 7 May 2022 at 18:46:03 UTC, Paul Backus wrote: On Saturday, 7 May 2022 at 18:36:40 UTC, jmh530 wrote: In the code below, there is a two parameter function `foo` and an override of it with only one parameter. In the override case, I force the second one to be 1, but ideally there

Compile delegate with enum into proper function?

2022-05-07 Thread jmh530 via Digitalmars-d-learn
In the code below, there is a two parameter function `foo` and an override of it with only one parameter. In the override case, I force the second one to be 1, but ideally there should be a way to specify it at compile-time. It would be kind of nice to be able to do it with an enum and a

Re: DMD failed with exit code -1073741819

2022-05-03 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 19:03:56 UTC, Dennis wrote: On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote: Does anyone have any idea what causes these types of errors? Sounds like a stack overflow, maybe your code has a complex/recursive part that makes DMD's call stack very deep. Thanks.

DMD failed with exit code -1073741819

2022-05-03 Thread jmh530 via Digitalmars-d-learn
I made some changes to some code I'm working on and now there are some lines that are giving me funky DMD error codes (I can tell it is some lines because I comment them out and the errors go away). So for instance, one line I have a static assert that gives an error code -1073741819, but if I

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote: [snip] Yes. std.random is another. I gave up out on the current one. Luckily I already had external libraries for that before I started using D. Have you tried mir.random?

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 19:35:00 UTC, jmh530 wrote: [snip] Step 1: In the integral overloads, use allSatisfy!(isSigned, B, E) || allSatisfy!(isUnsigned, T, U) for the current behavior Step 2: When !(allSatisfy!(isSigned, B, E) || allSatisfy!(isUnsigned, T, U)), then convert to

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 15:55:55 UTC, bachmeier wrote: On Wednesday, 16 February 2022 at 15:21:11 UTC, jmh530 wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior doesn't make much sense. What do you propose as an alternative? What about the narrowest type that fits

Re: Jupyter notebook with Dlang

2021-11-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 16 November 2021 at 14:40:01 UTC, Imperatorn wrote: https://forum.dlang.org/post/pvwbeqzvktovnhoag...@forum.dlang.org On Wednesday, 29 April 2020 at 15:49:05 UTC, Jan Hönig wrote: [snip] I would also like to know this! I would also be interested.

Re: alias this - am I using it wrong?

2021-08-25 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:23:06 UTC, Adam D Ruppe wrote: [snip] That's a lot about alias this that I didn't know. Thanks.

Re: How to get element type of a slice?

2021-08-18 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 14:40:20 UTC, Ferhat Kurtulmuş wrote: [snip] Very informative, thanks. My code is lying here[1]. I want my struct to accept 2d static arrays, random access ranges, and "std.container.Array". I could achieve it with its present form, and I will probably slightly

Re: equivalent of std.functional.partial for templates?

2021-08-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 14:08:59 UTC, Paul Backus wrote: [snip] Should have read further--this does not work with template functions due to [issue 1807.][1] My mistake. [1]: https://issues.dlang.org/show_bug.cgi?id=1807 Looks like that strengthens the case for moving forward with

Re: Integer programming in D?

2021-07-19 Thread jmh530 via Digitalmars-d-learn
On Monday, 19 July 2021 at 12:39:41 UTC, Arredondo wrote: Is there an integer linear programming/discrete optimization library for D? an equivalent to the JuMP library for Julia for instance. Doesn't have to be too big, I really only need to solve a few smallish binary linear systems, but

Re: assert(false) and GC

2021-07-08 Thread jmh530 via Digitalmars-d-learn
On Thursday, 8 July 2021 at 18:11:50 UTC, DLearner wrote: Hi Please confirm that: ` assert(false, __FUNCTION__ ~ "This is an error message"); ` Will _not_ trigger GC issues, as the text is entirely known at compile time. Best regards Consider below. Only z will generate an error. This

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 04:17:19 UTC, someone wrote: On Wednesday, 30 June 2021 at 03:55:05 UTC, Vladimir Panteleev wrote: If you want to give any type a "null" value, you could use [`std.typecons.Nullable`](https://dlang.org/library/std/typecons/nullable.html). At LEAST for some

Re: Financial Library

2021-06-13 Thread jmh530 via Digitalmars-d-learn
On Sunday, 13 June 2021 at 22:32:16 UTC, Bastiaan Veelo wrote: On Sunday, 13 June 2021 at 12:46:29 UTC, Financial Wiz wrote: What are some of the best Financial Libraries for D? I would like to be able to aggregate as much accurate information as possible. Thanks. I am not into financials,

Re: dual-context deprecation

2021-05-17 Thread jmh530 via Digitalmars-d-learn
On Monday, 17 May 2021 at 14:35:51 UTC, Steven Schveighoffer wrote: [snip] The feature is deprecated in its current form. The issue as I understand it (i.e. very little) is that compilers other than DMD could not use this same way to implement dual contexts, and so they could not have the

Re: dual-context deprecation

2021-05-17 Thread jmh530 via Digitalmars-d-learn
On Monday, 17 May 2021 at 13:51:32 UTC, Paul Backus wrote: [snip] See this issue for context: https://issues.dlang.org/show_bug.cgi?id=5710 Thanks. Lots of details there that I don't follow all of. I mentioned in the deprecation PR [1] that it was not listed in the list of deprecated

dual-context deprecation

2021-05-17 Thread jmh530 via Digitalmars-d-learn
The code below (simplified from my actual problem) generates a warning that member function b "requires a dual-context, which is deprecated". However when I look at the list of deprecated features [1], I'm not seeing which one this is referring to. Is it a valid deprecation? I could only

Re: Since dmd 2.096.0: import `x.t` is used as a type

2021-05-03 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 May 2021 at 18:36:25 UTC, Basile B. wrote: [snip] BTW during the PR review the problem you encounter [was anticipated](https://github.com/dlang/dmd/pull/12178#issuecomment-773886263) si I guess you're stuck with [the author

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:56:48 UTC, jmh530 wrote: What you're basically asking for the first one is to convert for row major to column major. There doesn't seem to be a specific function for that, but you can piece it together. The second one is just applying allReversed to the

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:26:15 UTC, Newbie wrote: [snip] Forgot to add the the first array was created using the following code. auto base = iota(2, 5, 3); What you're basically asking for the first one is to convert for row major to column major. There doesn't seem to be a

Re: DIP1000 and immutable

2021-04-27 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 27 April 2021 at 14:44:48 UTC, Adam D. Ruppe wrote: On Tuesday, 27 April 2021 at 14:28:12 UTC, jmh530 wrote: However, should it ever matter if you escape an immutable? Your example is a pretty clear case of use-after-free if gloin actually did escape the reference and kept it

DIP1000 and immutable

2021-04-27 Thread jmh530 via Digitalmars-d-learn
What is the motivation for DIP1000 also applying to immutable? For instance, in the code (compiled with -dip1000), adapted from the spec [1], you get the same errors with immutable function parameters as you would with mutable ones. However, should it ever matter if you escape an immutable?

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 16:32:28 UTC, Ali Çehreli wrote: On 3/17/21 3:54 AM, jmh530 wrote: On Tuesday, 16 March 2021 at 23:49:00 UTC, H. S. Teoh wrote: double[] data; data = cast(double[]) malloc(n * double.sizeof)[0 .. n]; This is one of those things that is not explained

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 16:20:06 UTC, Steven Schveighoffer wrote: [snip] I've had online battles about this terminology, and people asked me to change my array article to disavow this distinction, but I'm not going to change it. It's so much easier to understand. -Steve I'll be on

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 14:30:26 UTC, Guillaume Piolat wrote: On Wednesday, 17 March 2021 at 10:54:10 UTC, jmh530 wrote: This is one of those things that is not explained well enough. Yes. I made this article to clear up that point:

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 23:49:00 UTC, H. S. Teoh wrote: [snip] Note that T[] is just a slice, not the dynamic array itself. The dynamic array is allocated and managed by the GC when you append stuff to it, or when you create a new array with `new` or an array literal. None of the

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread jmh530 via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 [...] It might help to separate break this out into smaller functions. May make it easier to follow what is happening.

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 16:22:59 UTC, IGotD- wrote: [snip] Are we talking about the same things here? You mentioned DMD but I was talking about programs compiled with DMD (or GDC, LDC), not the nature of the DMD compiler in particular. Bump the pointer and never return any memory

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 15:36:37 UTC, Ola Fosheim Grøstad wrote: On Friday, 15 January 2021 at 15:20:05 UTC, jmh530 wrote: Hypothetically, would it be possible for users to supply their own garbage collector that uses write barriers? Yes. You could translate Google Chrome's Oilpan to D.

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:50:00 UTC, welkam wrote: On Thursday, 14 January 2021 at 18:51:16 UTC, Ola Fosheim Grøstad wrote: One can follow the same kind of reasoning for D. It makes no sense for people who want to stay high level and do batch programming. Which is why this disconnect

Re: C++ or D?

2020-12-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 December 2020 at 19:51:07 UTC, Ola Fosheim Grøstad wrote: [snip] Sort of, in C++ it would be something like this template class OuterName> void myfunction(OuterName x){ stuff(); } [snip] You mean like this struct Foo(T) { T x; } void foo(T : Foo!V, V)(T x) {

Re: Running unit tests from DUB single file packages

2020-12-22 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 15:06:09 UTC, drug wrote: [snip] But what do you mean exactly by "work with dependency"? As I understand, `dub test` does not run unit tests in dependencies and single file packages work with dependencies in general. Do you mean something else? I'm finishing

Re: Running unit tests from DUB single file packages

2020-12-21 Thread jmh530 via Digitalmars-d-learn
On Monday, 21 December 2020 at 11:31:49 UTC, drug wrote: [snip] Unfortunately I'm very busy. But I check it again and it turns out that the fix does not resolve the problem completely. This PR just remove the single file from testing so currently dub does not run unit tests in the single file

Re: Running unit tests from DUB single file packages

2020-12-20 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 12:51:11 UTC, drug wrote: [snip] Thanks! Let's see if it gets merged or if a slightly more involved solution is needed. Remake it - https://github.com/dlang/dub/pull/2052 This has more chances to be merged Looks like this got merged and will be part of

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 14:15:22 UTC, Johannes Loher wrote: [snip] The point of using DUB (and the single file package format) is easy access to libraries from the DUB registry. If I didn't want to use a dependency, I would not be using DUB at all. That said, leaving out the

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: [snip] Any hints on how to execute unit tests from single file DUB packages? Is it even possible at the moment? Thanks in advance for any help! [1] https://adventofcode.com/ Have you tried it without the imports?

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 13:52:35 UTC, jmh530 wrote: On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: [snip] Any hints on how to execute unit tests from single file DUB packages? Is it even possible at the moment? Thanks in advance for any help! [1]

Re: lambdas with types

2020-11-20 Thread jmh530 via Digitalmars-d-learn
On Friday, 20 November 2020 at 14:57:42 UTC, H. S. Teoh wrote: On Fri, Nov 20, 2020 at 02:47:52PM +, Paul Backus via Digitalmars-d-learn wrote: [...] In this specific case, you could also make `foo` a type-safe variadic function [1], which would eliminate the need for `allSatisfy`:

lambdas with types

2020-11-20 Thread jmh530 via Digitalmars-d-learn
Doing something like below fails because I don't seem to be able to make a templated lambda that just takes types. Is the only way to do something similar to create a separate function to handle the condition, or is there some other way to do something with similar flexibility? import

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:53:48 UTC, Mike Parker wrote: [snip] I can attest that in the 17 years I've been hanging around here, the fact that enum is used to indicate a manifest constant has not been a serious source of WTF posts. So I think "pretty much everyone coming to D" have

Re: How to use libmir --> mir-algorithm, numir, mir-random?

2020-09-09 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 9 September 2020 at 15:30:33 UTC, Shaleen Chhabra wrote: [snip] Hi, I updated my dmd version to dmd-2.093.1 Now it throws a conflict error between 1. function mir.ndslice.topology.iota!(long, 1LU).iota at mir/ndslice/topology.d(630) conflicts with function

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread jmh530 via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:39:44 UTC, H. S. Teoh wrote: [snip] "Furthermore, it can dispatch to a type-erased implementation ala Java -- at your choice;" This is interesting. Would you just cast to Object?

Re: Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
On Thursday, 6 August 2020 at 18:09:50 UTC, ag0aep6g wrote: [snip] `is(...)` only works on types. You're looking for `__traits(isSame, T, Foo)`. For `is(T!U == Foo!U, U)` to work, the compiler would have to guess U. If the first guess doesn't work, it would have to guess again, and again,

Re: Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
On Thursday, 6 August 2020 at 16:01:35 UTC, jmh530 wrote: [snip] It seems as if the T is properly Foo(T) and can only be instantiated with actual types. Something like below works and might work for me. template test(alias T) if (__traits(isTemplate, T)) { void test(U)(U x)

Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
The code below compiles, but I want to put an additional constraint on the `test` function is only called with a Foo struct. I tried things like is(T == Foo) and is(T : Foo), but those don't work. However, something like is(T!int : Foo!int) works, but is(T!U == Foo!U, U) doesn't. Any idea

Re: 2-D array initialization

2020-08-02 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 August 2020 at 19:19:51 UTC, Andy Balba wrote: I'm not a gitHub fan, but I like the mir functions; and it looks like I have to download mir before using it. mir has quite a few .d files..Is there a quick way to download it ? dub [1] is now packaged with dmd, which is the

Re: 2-D array initialization

2020-07-31 Thread jmh530 via Digitalmars-d-learn
On Friday, 31 July 2020 at 23:42:45 UTC, Andy Balba wrote: ubyte[3][4] c ; How does one initialize c in D ? none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; c[0] = ubyte[3] [5, 5, 5] ; c[1] = ubyte[3] [15, 15,15] ; c[2] =

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:41:35 UTC, 9il wrote: [snip] Ah, no, my bad! You write @fmamath, I have read it as @fastmath. @fmamath is OK here. I've mixed up @fastmath and @fmamath as well. No worries.

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:26:19 UTC, 9il wrote: [snip] @fmamath private double sd(T)(Slice!(T*, 1) flatMatrix) @fastmath violates all summation algorithms except `"fast"`. The same bug is in the original author's post. I hadn't realized that @fmamath was the problem, rather than

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 05:57:56 UTC, tastyminerals wrote: [snip] Here is a (WIP) project as of now. Line 160 in https://github.com/tastyminerals/mir_benchmarks_2/blob/master/source/basic_ops.d std of [60, 60] matrix 0.0389492 (> 0.001727) std of [300, 300] matrix 1.03592 (> 0.043452)

Re: D Mir: standard deviation speed

2020-07-14 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 19:04:45 UTC, tastyminerals wrote: I am trying to implement standard deviation calculation in Mir for benchmark purposes. I have two implementations. One is the straightforward std = sqrt(mean(abs(x - x.mean())**2)) and the other follows Welford's algorithm for

Re: Upcoming refraction module in bolts [was: DUB project type support for Emacs Projectile]

2020-06-15 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2020 at 17:32:26 UTC, Jean-Louis Leroy wrote: [snip] Thanks, cool.

Re: DUB project type support for Emacs Projectile

2020-06-15 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2020 at 13:17:11 UTC, Jean-Louis Leroy wrote: [snip] Nah, I saw it. Well. My take on it has been ready for months but I had to wait for my employer's permission to publish it. They are very open-source friendly, and as a consequence there is a glut of requests for

Re: DUB project type support for Emacs Projectile

2020-06-14 Thread jmh530 via Digitalmars-d-learn
On Sunday, 14 June 2020 at 17:19:05 UTC, Jean-Louis Leroy wrote: [snip] In case you missed it, I thought you would find this interesting https://forum.dlang.org/thread/dytpsnkqnmgzniiwk...@forum.dlang.org

Re: Why is there no range iteration with index by the language?

2020-06-10 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 10 June 2020 at 00:53:30 UTC, Seb wrote: [snip] Anyhow, I would be highly in favor of DMD doing this. It's one of those many things that I have on my list for D3 or a D fork. Chapel supports zippered iteration [1]. From the discussion here, it sounds very much like the

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 14:27:26 UTC, data pulverizer wrote: [snip] Out of curiosity what does the "." in front of `foo` mean? I've seen that in some D code on the compiler in GitHub and have no idea what it does. I tried Googling it to no avail. It doesn't have anything to do with UFCS

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 12:20:46 UTC, Adam D. Ruppe wrote: [snip] Why do you even want foo!"fabs"? Usually when I see people having this problem it is actually a misunderstanding of what is possible with the foo!fabs style - which is better in basically every way and can be used in most

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 10:28:39 UTC, Paul Backus wrote: [snip] Thanks for that suggestion. That works for me. Unfortunately, it's probably not worth the extra effort though, versus doing foo!fabs in my case.

  1   2   3   4   5   >