Re: Ranges

2022-08-04 Thread Ali Çehreli via Digitalmars-d-learn
On 8/4/22 11:05, frame wrote: > `popFront()` The function was this: void popFront() { students = students[1 .. $]; } > copies all > elements except the first one into the variable (and overwrites it), so > it moves the data forward. That would be very slow. :) What

Re: Hacking C code vs D code

2022-08-04 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 4 August 2022 at 23:11:36 UTC, pascal111 wrote: One of problems faced me in C programming is hacking data with C code that some hackers do with C code which make me needs more tools to protect my C code, but I don't have good resources in my current time, while I noticed that D

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:42:23 UTC, jfondren wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/") { n++; } } unittest { auto a = S(1),

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 02:20:31 UTC, Steven Schveighoffer wrote: On 8/4/22 9:51 PM, Paul Backus wrote: Another option: use -vcg-ast, and have the compiler tell you what it's actually calling. It's not ignoring that line, it's just not doing what you think it's doing. The output's not

Re: Ranges

2022-08-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 August 2022 at 22:54:42 UTC, pascal111 wrote: I didn't notice that all what we needs to pop a range forward is just a slice, yes, we don't need variable here. Ranges and Slices are not the same thing. Slicing an array is easy. This is a language possibility. For example, you

Re: Ranges

2022-08-04 Thread Ali Çehreli via Digitalmars-d-learn
On 8/4/22 06:08, pascal111 wrote: > In next code from > "https://www.tutorialspoint.com/d_programming/d_programming_ranges.htm;, That page seems to be adapted from this original: http://ddili.org/ders/d.en/ranges.html > we have two issues: > > 1) Why the programmer needs to program

Re: Ranges

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 22:14:26 UTC, Ali Çehreli wrote: On 8/4/22 11:05, frame wrote: > `popFront()` The function was this: void popFront() { students = students[1 .. $]; } > copies all > elements except the first one into the variable (and overwrites it), so >

Re: Unittest Absurdity

2022-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/22 9:51 PM, Paul Backus wrote: On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: I found the issue:  opOpAssign isn't getting called at all.  I have no idea why, though. Given that the example works, the problem must be in some other part of your code that you

Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
How do I get unittests to actually execute operator overloads? E.g.: ```d struct Struct { void opOpAssign(string op)(Struct rhs) //Assume that the operator `/=` is implemented here { //... } } unittest { Struct a = Struct(1); Struct b = Struct(2); a /= b;

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:51:21 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:42:23 UTC, jfondren wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes

Re: CMake and D

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 20:59:50 UTC, Johan wrote: On Thursday, 4 August 2022 at 20:29:30 UTC, Jan Allersma wrote: So something goes wrong with linking, but I dont know what. Execute `dmd -v` on some test program. It will output the linker line at the end of the output, the line

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:53:42 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/") { n++; } } Nevermind. I have

Re: curses/ncurses liberary in D

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote: On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: https://github.com/adamdruppe/arsd/blob/master/terminal.d How can I use this terminal module? Is there a document for it?

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:25:50 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:23:40 UTC, Ruby The Roobster wrote: [SNIP] Any function other than an operator overload seems to work fine. Also, this isn't mentioned in the spec. Additional Information: Fails for both DMD

Re: Unittest Absurdity

2022-08-04 Thread jfondren via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/") { n++; } } unittest { auto a = S(1), b = S(2); a /= b; b /= a; assert(a.n == 2);

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: On Friday, 5 August 2022 at 01:42:23 UTC, jfondren wrote: On Friday, 5 August 2022 at 01:38:48 UTC, jfondren wrote: Here's a complete example that passes tests: ```d struct S { int n; void opOpAssign(string op)(S rhs)

Re: Unittest Absurdity

2022-08-04 Thread Paul Backus via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: I found the issue: opOpAssign isn't getting called at all. I have no idea why, though. Given that the example works, the problem must be in some other part of your code that you haven't posted. If you can post a more

Re: Unittest Absurdity

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 5 August 2022 at 01:23:40 UTC, Ruby The Roobster wrote: [SNIP] Any function other than an operator overload seems to work fine. Also, this isn't mentioned in the spec. Additional Information: Fails for both DMD and LDC on Windows x86_64 for dmd v2.100.1

Hacking C code vs D code

2022-08-04 Thread pascal111 via Digitalmars-d-learn
One of problems faced me in C programming is hacking data with C code that some hackers do with C code which make me needs more tools to protect my C code, but I don't have good resources in my current time, while I noticed that D code is more secure than C code by mean it will be more useful

Re: curses/ncurses liberary in D

2022-08-04 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 11:52:48PM +, pascal111 via Digitalmars-d-learn wrote: > On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote: > > On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: > > > > https://github.com/adamdruppe/arsd/blob/master/terminal.d > > > > > > How

Re: Obsecure problem 2

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 21:37:50 UTC, jfondren wrote: On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote: [...] I agree to the extent that I wanted to do so, and might still have if a delivery hadn't interrupted by post. But one way to encourage others to put in more effort

Re: How to find all modules in a package?

2022-08-04 Thread Domain via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 12:27:32 UTC, frame wrote: On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? You can do something like that: ```d static foreach (sym;

Re: Obsecure problem 2

2022-08-04 Thread Ali Çehreli via Digitalmars-d-learn
On 8/4/22 00:57, pascal111 wrote: > I don't see my post. Some posts are blocked by the spam filter. (Apparently, your message did not have a sender name and cannot be passed because of that.) Ali

Arbitrary precision decimal numbers

2022-08-04 Thread Ruby The Roobster via Digitalmars-d-learn
Is there any implementation in phobos of something similar to BigInt but for non-integers as well? If there isn't is there a dub package that does this, and if so, which one?

Ranges

2022-08-04 Thread pascal111 via Digitalmars-d-learn
In next code from "https://www.tutorialspoint.com/d_programming/d_programming_ranges.htm;, we have two issues: 1) Why the programmer needs to program "empty()", "front()", and "popFront()" functions for ranges while they exist in the language library? it seems there's no need to exert efforts

Re: Obsecure problem 2

2022-08-04 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 21:35:29 UTC, Ruby The Roobster wrote: On Wednesday, 3 August 2022 at 19:11:51 UTC, pascal111 wrote: [...] No need for a code. See, there is a keyword called `ref`, that can be used both in function parameters and in foreach loops, and it is the equivalent of

Re: How to find all modules in a package?

2022-08-04 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 04, 2022 at 07:22:04AM +, Domain via Digitalmars-d-learn wrote: > On Wednesday, 3 August 2022 at 12:27:32 UTC, frame wrote: > > On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: > > > I want to find out all public functions in all modules in a package. > > > Can I do that

code review: splitIds from DConf '22 day 3: saving a sort and "getting performance"

2022-08-04 Thread kdevel via Digitalmars-d-learn
At DConf '22 day 3 Robert Schadek presented at around 07:22:00 in the YT video the function `splitIds`. Given an HTML page from bugzilla containing a list of issues `splitIds` aims at extracting all bug-ids referenced within a specific url context: ``` long [] splitIds (string page) { enum

Re: Ranges

2022-08-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 August 2022 at 13:08:21 UTC, pascal111 wrote: ```D import std.stdio; import std.string; struct Student { string name; int number; string toString() const { return format("%s(%s)", name, number); } } struct School {

Re: Ranges

2022-08-04 Thread frame via Digitalmars-d-learn
On Thursday, 4 August 2022 at 13:08:21 UTC, pascal111 wrote: 1) Why the programmer needs to program "empty()", "front()", and "popFront()" functions for ranges while they exist in the language library? it seems there's no need to exert efforts for that.

CMake and D

2022-08-04 Thread Jan Allersma via Digitalmars-d-learn
Hello, I am trying to compile an application with both C++ and D source code. First I have `main.d`: ``` extern (C++) void init(); extern (C++) void draw(int row, int column, int x, int y); extern (C++) void render(); void main() { init(); draw(3, 3, 0, 0); draw(3, 3, 2, 2);

Re: CMake and D

2022-08-04 Thread Johan via Digitalmars-d-learn
On Thursday, 4 August 2022 at 20:29:30 UTC, Jan Allersma wrote: So something goes wrong with linking, but I dont know what. Execute `dmd -v` on some test program. It will output the linker line at the end of the output, the line starting with `cc yourcode.o -o yourcode ...`. On that linker

curses/ncurses liberary in D

2022-08-04 Thread pascal111 via Digitalmars-d-learn
https://forum.dlang.org/post/bjldcmojboremdrok...@forum.dlang.org On Wednesday, 3 November 2021 at 05:43:05 UTC, harakim wrote: On Wednesday, 3 November 2021 at 01:39:02 UTC, H. S. Teoh wrote: On Wed, Nov 03, 2021 at 01:33:28AM +, dangbinghoo via Digitalmars-d-learn wrote: On Wednesday, 3

Re: curses/ncurses liberary in D

2022-08-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: https://github.com/adamdruppe/arsd/blob/master/terminal.d How can I use this terminal module? Is there a document for it? http://arsd-official.dpldocs.info/arsd.terminal.html

Re: curses/ncurses liberary in D

2022-08-04 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote: On Wednesday, 3 November 2021 at 05:43:05 UTC, harakim wrote: https://github.com/adamdruppe/arsd/blob/master/terminal.d How can I use this terminal module? Is there a document for it? It is part of the arsd-official package,