Re: print ubyte[] as (ascii) string

2022-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/22 5:04 PM, eugene wrote: On Friday, 7 January 2022 at 21:17:33 UTC, Steven Schveighoffer wrote: In C you have one choice (printf), but that choice may not fit your needs. There are 2 buffers (RX one and TX one, both of 'reasonable' size) (it's the effing echo-server, nothing more) Ir

Re: print ubyte[] as (ascii) string

2022-01-07 Thread frame via Digitalmars-d-learn
On Friday, 7 January 2022 at 22:04:28 UTC, eugene wrote: There are 2 buffers (RX one and TX one, both of 'reasonable' size) (it's the effing echo-server, nothing more) * print content of RX-buffer, ommiting terminating '\n' ('\n' is the 'end of request') to (log/journal file)/stdout/ * oupt

Re: print ubyte[] as (ascii) string

2022-01-07 Thread Dukc via Digitalmars-d-learn
On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote: ```d char[] s = cast(char[])ioCtx.buf[0 .. strlen(cast(char*)ioCtx.buf.ptr) - 1]; // -1 is to eliminate terminating '\n' writefln("got '%s' from '%s:%d'", s, client.addr, client.port); ``` Is there some more concise/elegant way to d

Re: Windows link trouble

2022-01-07 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:48:17 UTC, mesni wrote: Windows: when creating dll file, ClassInfo and ModuleInfo are not exported? The linker swears specifically at *__Class or *__ModuleInfo symbols. nothing is exported unless you use the export keyword or a module definition file. but the

Re: print ubyte[] as (ascii) string

2022-01-07 Thread eugene via Digitalmars-d-learn
On Friday, 7 January 2022 at 21:17:33 UTC, Steven Schveighoffer wrote: In C you have one choice (printf), but that choice may not fit your needs. There are 2 buffers (RX one and TX one, both of 'reasonable' size) (it's the effing echo-server, nothing more) * print content of RX-buffer, ommitin

Re: print ubyte[] as (ascii) string

2022-01-07 Thread eugene via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:40:02 UTC, Adam D Ruppe wrote: On Friday, 7 January 2022 at 20:33:05 UTC, eugene wrote: * python guys have memory leaks * js guys have memory leaks GC isn't actually there to prevent memory leaks. Aha, unless you'll build GC into OS core :) Its main job is to

Re: print ubyte[] as (ascii) string

2022-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/7/22 2:54 PM, eugene wrote: A couple of impressions... * Does .until() make a copy of original string? And GC then will take care of it? No, `until` will iterate the string one character at a time until it sees that character (excluding it). It doesn't make a copy of the data. In eff

Re: Windows link trouble

2022-01-07 Thread mesni via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:48:17 UTC, mesni wrote: Windows: when creating dll file, ClassInfo and ModuleInfo are not exported? The linker swears specifically at *__Class or *__ModuleInfo symbols. DMD 2.98

Windows link trouble

2022-01-07 Thread mesni via Digitalmars-d-learn
Windows: when creating dll file, ClassInfo and ModuleInfo are not exported? The linker swears specifically at *__Class or *__ModuleInfo symbols.

Re: print ubyte[] as (ascii) string

2022-01-07 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:33:05 UTC, eugene wrote: * python guys have memory leaks * js guys have memory leaks GC isn't actually there to prevent memory leaks. Its main job is to guard against use-after-free memory corruption bugs. Actually, technically, the paradigm is "infinite lifet

Re: print ubyte[] as (ascii) string

2022-01-07 Thread eugene via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:08:00 UTC, H. S. Teoh wrote: So it should be good even for GC-phobic code. Nice term - "GC-phobic" :) But looking from my cave - it's not a phobia, it's an observation. We've got a huge and complex project at my job, and... * python guys have memory leaks *

Re: print ubyte[] as (ascii) string

2022-01-07 Thread eugene via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:08:00 UTC, H. S. Teoh wrote: The simplest way to handle a C string from D is just to use .fromStringz: yes, this approach was used in some my previous traival

Re: print ubyte[] as (ascii) string

2022-01-07 Thread eugene via Digitalmars-d-learn
On Sunday, 2 January 2022 at 15:13:06 UTC, Paul Backus wrote: On Sunday, 2 January 2022 at 09:15:32 UTC, eugene wrote: ``` p1.d(9): Error: cannot cast expression `until(b[], '\x0a', Flag.yes)` of type `Until!("a == b", ubyte[], char)` to `char[]` ``` Here's a working version: ```d import

Re: print ubyte[] as (ascii) string

2022-01-07 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 07, 2022 at 07:54:28PM +, eugene via Digitalmars-d-learn wrote: [...] > * Does .until() make a copy of original string? And GC then will take > care of it? No, it's one of the lazy range functions that lazily evaluates the string and does not allocate. > * So many ways to do sim

Re: print ubyte[] as (ascii) string

2022-01-07 Thread eugene via Digitalmars-d-learn
On Monday, 3 January 2022 at 02:50:46 UTC, Steven Schveighoffer wrote: On 1/2/22 4:15 AM, eugene wrote: On Sunday, 2 January 2022 at 08:39:57 UTC, eugene wrote: ```d     writefln("'%s, world'", cast(char[])b[].until('\n')); } ``` You missed a set of parentheses. That was lack of attention

Re: Module without object file?

2022-01-07 Thread Johan via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 22:17:38 UTC, kdevel wrote: Is there any chance to rephrase fsobjects.d such that it becomes a "header only"/"compile only" file of which no object file must be presented to the linker? https://wiki.dlang.org/LDC-specific_language_changes#LDC_no_moduleinfo -Joh

Re: Module without object file?

2022-01-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/6/22 6:06 PM, kdevel wrote: When you import this file, the compiler sees that it has imports, and assumes you must have built the `ModuleInfo` in some object somewhere, so it outputs a reference for the import graph. Makes sense. It seems that if there are just type definitions with enum

Re: Module without object file?

2022-01-07 Thread frame via Digitalmars-d-learn
On Thursday, 6 January 2022 at 22:54:59 UTC, kdevel wrote: In my setup make decides which file to (re)compile. Just found that dmd has the option -makedeps which resembles gcc's -M but theres no -MM to excluded dependencies from system files. Also gcc -M/-MM does not compile while dmd always g