On Friday, 31 December 2021 at 00:57:26 UTC, kdevel wrote:
```dptr.d
class R {
}
void foo (R r)
{
}
alias fn = void function (R);
void lyr (fn F) (R r)
{
}
immutable fn foo_ptr = &foo; // line 14
pragma (msg, typeof (foo_ptr));
auto ptr = lyr!(foo_ptr);// line 17
```
dmd reports:
```
im
```dptr.d
class R {
}
void foo (R r)
{
}
alias fn = void function (R);
void lyr (fn F) (R r)
{
}
immutable fn foo_ptr = &foo; // line 14
pragma (msg, typeof (foo_ptr));
auto ptr = lyr!(foo_ptr);// line 17
```
dmd reports:
```
immutable(void function(R))
dptr.d(14): Error: expression `& f
On Thursday, 30 December 2021 at 19:13:10 UTC, Marcone wrote:
I get this error: Error: undefined identifier `emit`, did you
mean function `exit`?
You need to call it on the signal.
class A {
mixin Signal thing;
}
A a = new A;
a.thing.emit();
On Thursday, 30 December 2021 at 19:13:10 UTC, Marcone wrote:
I get this error: Error: undefined identifier `emit`, did you
mean function `exit`?
Did you `import std.signals`?
— Bastiaan.
I get this error: Error: undefined identifier `emit`, did you
mean function `exit`?
On Thursday, 30 December 2021 at 17:52:20 UTC, eugene wrote:
everything as needed.
Nevertheless, I do have zeroes in the buffer, so:
```d
import std.stdio;
import std.string;
void main() {
ubyte[8] b = [0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00, 0x00];
/* "hello\n\0\0" */
char[] s
On Thursday, 30 December 2021 at 17:43:14 UTC, Tejas wrote:
I'm not at my computer anymore, could you please replace the
`0x00` with `0x0A` and tell me if `strip` still doesn't work
for my solution?
Ok.
I think the `fromstringz` is trimming the null bytes for you,
making the `\n` the last ch
On Thursday, 30 December 2021 at 17:31:27 UTC, eugene wrote:
On Thursday, 30 December 2021 at 16:49:17 UTC, Tejas wrote:
I _think_ the above code is correct, please verify
Self-contained example:
```d
import std.stdio;
import std.string;
void main() {
ubyte[8] b = [0x68, 0x65, 0x6C, 0x6
On Thursday, 30 December 2021 at 17:16:10 UTC, Tejas wrote:
I'll need to know the error message
There is none, see example in my prev message
because the following works:
```d
import std;
void main()
{
ubyte[] c ;
c.length = 100;
char[] arr = cast(char[])c[0 .. $];
foreach(ref
On Thursday, 30 December 2021 at 16:49:17 UTC, Tejas wrote:
I _think_ the above code is correct, please verify
Self-contained example:
```d
import std.stdio;
import std.string;
void main() {
ubyte[8] b = [0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00, 0x00];
/* "hello\n\0\0" */
char[
On Thursday, 30 December 2021 at 17:07:20 UTC, eugene wrote:
On Thursday, 30 December 2021 at 16:49:17 UTC, Tejas wrote:
```d
char[] s = cast(char[])ioCtx.buf[0 .. $];// please remember
that in `[0 .. $]` last index is automatically `length - 1`
but just buf[$] will be an error since there the
On Thursday, 30 December 2021 at 16:49:17 UTC, Tejas wrote:
```d
char[] s = cast(char[])ioCtx.buf[0 .. $];// please remember
that in `[0 .. $]` last index is automatically `length - 1` but
just buf[$] will be an error since there the actual `length`
will be used
```
I _think_ the above code
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 do
On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote:
I suspect the question was asked somewhere before.
If so just give a link.
Anyway:
```d
class IoContext {
...
ubyte[] buf;
...
this(uint bufSize) {
buf = new ubyte[bufSize];
}
}
```
```d
class IoContex
On Thursday, 30 December 2021 at 11:17:39 UTC, afg45 wrote:
See the https://en.wikipedia.org/wiki/Common_logarithm fpr the
explanations.
```
import std.stdio, std.math;
void main(string[] args)
{
alias numDigits = (f) => log10(f + 0.5).ceil();
}
```
Thanks a lot! However, I used the "log
On Thursday, 30 December 2021 at 16:00:59 UTC, Era Scarecrow
wrote:
The answer i ended up with was a quick conversion to a UTF in
order to print it. Seems you might have to convert to Latin-1.
For a moment I only have symbols from the lower half of ASCII
table.
I meant - can that be done as
On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote:
The buffer contains (ascii) string terminated with '\n'. In
order to print it not as an array of numbers (buf is 1024 bytes
long), but as usual string I do
Few years ago i asked a similar question, not to do UTF-8 but to
do Ascii.
On Thursday, 30 December 2021 at 09:03:58 UTC, rempas wrote:
Let's say that I have the following float/double: 137.837
How can I find how many places from left the dot appears? So in
this example I want to take either three or four (depending on
how you think it). Does anyone knows how I can d
I suspect the question was asked somewhere before.
If so just give a link.
Anyway:
```d
class IoContext {
...
ubyte[] buf;
...
this(uint bufSize) {
buf = new ubyte[bufSize];
}
}
```
The buffer contains (ascii) string terminated with '\n'.
In order to print it not a
Let's say that I have the following float/double: 137.837
How can I find how many places from left the dot appears? So in
this example I want to take either three or four (depending on
how you think it). Does anyone knows how I can do that and can
explain it to me?
20 matches
Mail list logo