Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2024 at 11:39:33PM +, Liam McGillivray via Digitalmars-d-learn wrote: [...] > I tried to rework the functions to use bitwise operations, but it was > difficult to figure out the correct logic. I decided that it's not > worth the hassle, so I just changed the value storage from

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-14 Thread Basile B. via Digitalmars-d-learn
On Friday, 15 March 2024 at 00:00:01 UTC, Richard (Rikki) Andrew Cattermole wrote: On 15/03/2024 12:47 PM, Basile B. wrote: On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray wrote: On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] I tried

Re: varargs when they're not all the same type?

2024-03-14 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 14 March 2024 at 23:13:51 UTC, Basile B. wrote: ... However explicit instantiation can take whatever is known at compile time, such as constant expressions or even certain static variables. So that is rather called an `alias sequence` in D. Which statement leads me to section

Re: varargs when they're not all the same type?

2024-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2024 at 08:58:21PM +, Andy Valencia via Digitalmars-d-learn wrote: > On Thursday, 14 March 2024 at 18:05:59 UTC, H. S. Teoh wrote: > > ... > > The best way to do multi-type varags in D is to use templates: > > > > import std; > > void myFunc(Args...)(Args args) { > >

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-14 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 15/03/2024 12:47 PM, Basile B. wrote: On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray wrote: On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] I tried to rework the functions to use bitwise operations, but it was difficult to figure

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray wrote: On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] I tried to rework the functions to use bitwise operations, but it was difficult to figure out the correct logic. I decided that it's

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-14 Thread Liam McGillivray via Digitalmars-d-learn
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki) Andrew Cattermole wrote: The cost of an add + increment then a bitwise and is only 2-4 cycles on a Haswell cpu. Depending upon if its working solely in registers (via inlining) or its operating on ram. Whereas if you need to do

Re: Alguien me dice como podria conectarme a una base de datos en SQL server?

2024-03-14 Thread dany via Digitalmars-d-learn
On Thursday, 14 March 2024 at 17:22:35 UTC, Matheus wrote: On Thursday, 14 March 2024 at 17:08:17 UTC, dany wrote: ... queria conectarme a SQLserver :'( You will need an ODBC driver (Bindings): https://code.dlang.org/packages/arsd-official%3Amssql Matheus. ese tambien conecta con sql

Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-14 Thread Inkrementator via Digitalmars-d-learn
Hello, I am trying to derive a struct from another. I want to modify each field such that type of it goes from some T to Nullable!T, preserving all fieldnames and UDAs. I think that fieldnames and UDAs can only be duplicated via string-mixins. This means that all field-types that aren't

Re: varargs when they're not all the same type?

2024-03-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 14 March 2024 at 20:58:21 UTC, Andy Valencia wrote: On Thursday, 14 March 2024 at 18:05:59 UTC, H. S. Teoh wrote: ... The best way to do multi-type varags in D is to use templates: import std; void myFunc(Args...)(Args args) { Thank you. The first parenthetical

Re: varargs when they're not all the same type?

2024-03-14 Thread Andy Valencia via Digitalmars-d-learn
On Thursday, 14 March 2024 at 18:05:59 UTC, H. S. Teoh wrote: ... The best way to do multi-type varags in D is to use templates: import std; void myFunc(Args...)(Args args) { Thank you. The first parenthetical list is of types, is it not? I can't find anywhere which says

Re: How to use eventcore write an echo server?

2024-03-14 Thread Dejan Lekic via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 05:13:26 UTC, zoujiaqing wrote: How to fix it? than you ;) Try the following: ``` class Connection { StreamSocketFD client; ubyte[1024] buf = void; // Add these two lines before the constructor: nothrow: @safe:

Re: varargs when they're not all the same type?

2024-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2024 at 05:57:21PM +, Andy Valencia via Digitalmars-d-learn wrote: > Can somebody give me a starting point for understanding varadic > functions? I know that we can declare them > > int[] args... > > and pick through whatever the caller provided. But if the caller >

Re: varargs when they're not all the same type?

2024-03-14 Thread monkyyy via Digitalmars-d-learn
On Thursday, 14 March 2024 at 17:57:21 UTC, Andy Valencia wrote: Can somebody give me a starting point for understanding varadic functions? I know that we can declare them int[] args... and pick through whatever the caller provided. But if the caller wants to pass two int's and a

varargs when they're not all the same type?

2024-03-14 Thread Andy Valencia via Digitalmars-d-learn
Can somebody give me a starting point for understanding varadic functions? I know that we can declare them int[] args... and pick through whatever the caller provided. But if the caller wants to pass two int's and a _string_? That declaration won't permit it. I've looked into the

Re: Alguien me dice como podria conectarme a una base de datos en SQL server?

2024-03-14 Thread Matheus via Digitalmars-d-learn
On Thursday, 14 March 2024 at 17:08:17 UTC, dany wrote: ... queria conectarme a SQLserver :'( You will need an ODBC driver (Bindings): https://code.dlang.org/packages/arsd-official%3Amssql Matheus.

Re: Alguien me dice como podria conectarme a una base de datos en SQL server?

2024-03-14 Thread dany via Digitalmars-d-learn
On Thursday, 14 March 2024 at 16:55:12 UTC, Ferhat Kurtulmuş wrote: On Thursday, 14 March 2024 at 16:42:04 UTC, dany wrote: [...] Deberias preguntar en Ingles en este foro. No mucha gente que habla Espanol aqu. Puedes buscar un biblioteca en https://code.dlang.org/search?q=sql. Usa un

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-14 Thread Monkyyy via Digitalmars-d-learn
On Thursday, 14 March 2024 at 16:32:10 UTC, rkompass wrote: On Thursday, 14 March 2024 at 16:12:00 UTC, rkompass wrote: Hello @monkyyy again, your solution is much more elegant:-) No need to do a deep copy. I was thinking about a way to achieve that but had no clue. I will study opSlice now.

Re: Alguien me dice como podria conectarme a una base de datos en SQL server?

2024-03-14 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 14 March 2024 at 16:42:04 UTC, dany wrote: Hola a todos necesito conectarme a una base de datos sql y ps no me sale :'( quisiera saber como podria porfis, ayuda :') import std.stdio; import std.json; //import std.database.mysql; //import raylib; import ddbc; void main() {

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-14 Thread rkompass via Digitalmars-d-learn
Hello @monkyyy, thank you for your help. I will study and try your code. Meanwhile I have found that I can add this function into the struct: ```d // postblit constructor, see // https://stackoverflow.com/questions/38785624/d-struct-copy-constructor this(this) {

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-14 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 13 March 2024 at 22:16:52 UTC, rkompass wrote: I want to make a custom dictionary that I may iterate through with foreach. Several times. What I observe so far is that my dict as a simple forward range is exhausted after the first foreach and I have to deeply copy it beforehand.

Re: Recommendation about templating engine library

2024-03-14 Thread Andrea via Digitalmars-d-learn
On Thursday, 14 March 2024 at 14:23:36 UTC, Inkrementator wrote: Having used djinn, it is "mostly unmaintained" because it is feature complete. It addresses your criticisms while potentially introducing new problems. It is very simple and the documentation is complete (due to the

Re: Recommendation about templating engine library

2024-03-14 Thread Inkrementator via Digitalmars-d-learn
On Monday, 11 March 2024 at 16:10:24 UTC, Andrea wrote: just trying it out and kinda fits my needs; the main issues are lack of documentation and the need to explicit loop on array data structures in the code (using sub-contexts) instead of having a "foreach" loop statement in the template

Re: The std.file rename method fails in the docker environment.

2024-03-14 Thread Paolo Invernizzi via Digitalmars-d-learn
On Wednesday, 13 March 2024 at 23:59:24 UTC, zoujiaqing wrote: On Wednesday, 13 March 2024 at 22:16:13 UTC, Sergey wrote: On Wednesday, 13 March 2024 at 21:49:55 UTC, zoujiaqing wrote: this is bug in D. It seems like a bug in Hunt-framework. And Hunt - is an abandoned project. Hunt

How to connect SQLserver to Dlang using ddbc library

2024-03-14 Thread dany via Digitalmars-d-learn
Hello people, I WOULD LIKE TO KNOW HOW I CAN CONNECT FROM MY SQL Server to my database. I have seen the GitHub of DDBC, but I'm getting errors. I just made this code, in my SQL Server I don't have any password or user to log in, I just want to enter the name of my database or the server.