Re: key membership in multi-dimensional assoc. array

2023-06-14 Thread Paul via Digitalmars-d-learn
On Thursday, 15 June 2023 at 02:21:16 UTC, Steven Schveighoffer wrote: Not in as short code. You could write a helper though: ```d auto deepIn(V, K, Keys...)(V[K] aa, Keys keys) if (Keys.length > 0) { auto v = keys[0] in aa; static if(keys.length == 1) return v; else return

Calling C functions that modify a string

2023-06-14 Thread Pat Maddox via Digitalmars-d-learn
Hi there, I want to call a C function that upcases a string. I have something working, I just want to check in here to see if there's a better approach that I'm missing. I ask because `std.string.toStringZ()` returns an `immutable char *`. As far as I can tell, I have two options: 1. Make

Re: key membership in multi-dimensional assoc. array

2023-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/23 9:47 PM, Paul wrote: I found I can check for key membership in a multi-D aa... ```d byte zKey = someval; byte[byte][byte][byte] cubelist; foreach(byte xK, yzcubelist; cubelist) {   foreach(byte yK, zcubelist; yzcubelist) {     foreach(byte zK, val; zcubelist) { ``` with this

Re: key membership in multi-dimensional assoc. array

2023-06-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 15 June 2023 at 01:47:45 UTC, Paul wrote: I found I can check for key membership in a multi-D aa... ```d byte zKey = someval; byte[byte][byte][byte] cubelist; foreach(byte xK, yzcubelist; cubelist) { foreach(byte yK, zcubelist; yzcubelist) { foreach(byte zK, val; zcubelist) {

key membership in multi-dimensional assoc. array

2023-06-14 Thread Paul via Digitalmars-d-learn
I found I can check for key membership in a multi-D aa... ```d byte zKey = someval; byte[byte][byte][byte] cubelist; foreach(byte xK, yzcubelist; cubelist) { foreach(byte yK, zcubelist; yzcubelist) { foreach(byte zK, val; zcubelist) { ``` with this expression... ```d if(zKey in

Re: ldc link error on new machine: undefined reference to `_D6object9Throwable7messageMxFNbNfZAxa'

2023-06-14 Thread mw via Digitalmars-d-learn
On Thursday, 15 June 2023 at 01:20:50 UTC, H. S. Teoh wrote: On Thu, Jun 15, 2023 at 12:49:30AM +, mw via Digitalmars-d-learn wrote: Hi, Recently encountered a similar problem, ultimately the cause was that my library paths turned out to be wrongly set, so it was picking up the wrong

Re: ldc link error on new machine: undefined reference to `_D6object9Throwable7messageMxFNbNfZAxa'

2023-06-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 15, 2023 at 12:49:30AM +, mw via Digitalmars-d-learn wrote: > Hi, > > I switched to a different machine to build my project, suddenly I got > lots of link errors. (It builds fine on the old machine, and my > software version are the same on both machines LDC - the LLVM D >

Re: Union with bits ?

2023-06-14 Thread Paul via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 22:44:41 UTC, Ali Çehreli wrote: By the way, the string that bitfields() generates can be visualized by simply printing it: const code = bitfields!( ubyte, "A", 1, ubyte, "B", 1, ubyte, "C", 1, ubyte,

ldc link error on new machine: undefined reference to `_D6object9Throwable7messageMxFNbNfZAxa'

2023-06-14 Thread mw via Digitalmars-d-learn
Hi, I switched to a different machine to build my project, suddenly I got lots of link errors. (It builds fine on the old machine, and my software version are the same on both machines LDC - the LLVM D compiler (1.32.2)) e.g.: ``` ... /usr/bin/ld:

Re: Union with bits ?

2023-06-14 Thread Ali Çehreli via Digitalmars-d-learn
On 6/14/23 15:04, Paul wrote: > Question: Why do you say "may be slower than necessary"? Do you mean > compile or runtime or both? Definitely at compile time because the string that gets mixed-in first needs to be generated from your specification. For that, the bitfields() function must be

Re: Union with bits ?

2023-06-14 Thread Paul via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 14:43:58 UTC, Ali Çehreli wrote: D's string mixin syntax may not be the best, the implementation may be slower than necessary, and the concept may be strange (not macros but very similar) but I still find phobos's bifields to be brilliant.

Re: pregunta preguntona, acerca de el resultado de remoteAddress()

2023-06-14 Thread Danico via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 19:50:21 UTC, Danico wrote: que significa los ultimos numeros de 192.168.0.13:50732 , cuando hago un remoteAddress() y en un servidor socket? On Wednesday, 14 June 2023 at 19:50:21 UTC, Danico wrote: Thanks everyone, it was an ephemeral ports, are automatically

Re: pregunta preguntona, acerca de el resultado de remoteAddress()

2023-06-14 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 19:50:21 UTC, Danico wrote: que significa los ultimos numeros de 192.168.0.13:50732 , cuando hago un remoteAddress() y en un servidor socket? Es un numero de puerto. No estoy seguro que preguntar en un idioma otra que ingles es un buena idea aqui. Lee esto por

Re: pregunta preguntona, acerca de el resultado de remoteAddress()

2023-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/23 3:50 PM, Danico wrote: que significa los ultimos numeros de 192.168.0.13:50732 , cuando hago un remoteAddress() y en un servidor socket? Those last numbers are the port on the remote machine. It's how the system knows which socket to forward the connection to (any system can have

Re: Obtener ip de clientes por sockets | get clients Ip by sockets

2023-06-14 Thread Danico via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 19:28:20 UTC, Steven Schveighoffer wrote: On 6/14/23 3:11 PM, Danico wrote: auto clientAddress = client.peerAddress(); remoteAddress, not peerAddress: https://dlang.org/phobos/std_socket.html#.Socket.remoteAddress -Steve I guess just should replace the word,

Re: Obtener ip de clientes por sockets | get clients Ip by sockets

2023-06-14 Thread Danico via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 19:28:20 UTC, Steven Schveighoffer wrote: -Steve Thanks :D it works

Re: Obtener ip de clientes por sockets | get clients Ip by sockets

2023-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/23 3:11 PM, Danico wrote: auto clientAddress = client.peerAddress(); remoteAddress, not peerAddress: https://dlang.org/phobos/std_socket.html#.Socket.remoteAddress -Steve

Obtener ip de clientes por sockets | get clients Ip by sockets

2023-06-14 Thread Danico via Digitalmars-d-learn
Hola gente, tengo un problema, nose como hacer par poder obtener la ip del cliente que se conecta a mi servidor, aqui esta la funcion de mi servidor: ` alias print = writeln; void main() { auto server = new Socket(AddressFamily.INET, SocketType.STREAM); print(" [-] Nuevo

Re: Why doesn't the bindbc-sfml work

2023-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/23 2:21 PM, glowiak wrote: Hello. I am trying to get a window open using BincBC-SFML. Sadly the compiler gives me an error: ``    Starting Performing "debug" build using /usr/bin/dmd for x86_64. ``  Up-to-date bindbc-sfml 1.0.2: target for configuration [staticBC] is up to date. ``  

Why doesn't the bindbc-sfml work

2023-06-14 Thread glowiak via Digitalmars-d-learn
Hello. I am trying to get a window open using BincBC-SFML. Sadly the compiler gives me an error: ``Starting Performing "debug" build using /usr/bin/dmd for x86_64. `` Up-to-date bindbc-sfml 1.0.2: target for configuration [staticBC] is up to date. ``Building tdvcraft ~master:

Re: Union with bits ?

2023-06-14 Thread Ali Çehreli via Digitalmars-d-learn
On 6/13/23 17:59, Paul wrote: > I would like to have labeled bits in a union with a ubyte. Something > like this: > ```d > struct MyStruct { > union { > ubyte status; > bit A, B, C…etc > } > } > ``` > Is something like this possible? > > Thanks D's string mixin syntax

Re: Union with bits ?

2023-06-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 08:51:19 UTC, Rene Zwanenburg wrote: You can do something like this if you don't mind compiling with -preview=bitfields: That doesn't do what you think it does. There's no guarantee the bits will actually line up with the status byte. The best way to do what

Parser

2023-06-14 Thread Cecil Ward via Digitalmars-d-learn
I’m thinking that I might had to end up writing a partial, rather rough parser for parts of the D language. Could I get some suggestions for help that I might find in the way of software components? D has a very powerful regex module, I believe. I have been writing inline asm library routines

Re: Union with bits ?

2023-06-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 00:59:30 UTC, Paul wrote: I would like to have labeled bits in a union with a ubyte. Something like this: ```d struct MyStruct { union { ubyte status; bit A, B, C…etc } } ``` Is something like this possible? Thanks You can do something