I have the following code:
```
import core.stdc.stdio;
void print(T)(string prompt, T args...) {
size_t len = prompt.length;
size_t i = 0;
while (prompt[i] != '{' && i < len) {
printf("%c", prompt[i]);
i++;
}
}
void main() {
print("Hello, world!\n", 10);
}
```
When I execute
On Friday, 9 July 2021 at 07:21:06 UTC, rempas wrote:
When I execute it, I'm getting a range violation error. If I
try to set "len" to be the length of the "prompt" minus 1, then
it will work and it will print the "prompt" until the
questionmark. So I cannot find where the error is...
Beca
On Friday, 9 July 2021 at 07:21:06 UTC, rempas wrote:
I have the following code:
`prompt[i]!='{'`,here,i=len.so `array overflow`
On Friday, 9 July 2021 at 07:38:50 UTC, Mike Parker wrote:
On Friday, 9 July 2021 at 07:21:06 UTC, rempas wrote:
When I execute it, I'm getting a range violation error. If I
try to set "len" to be the length of the "prompt" minus 1,
then it will work and it will print the "prompt" until the
On Friday, 9 July 2021 at 07:54:44 UTC, zjh wrote:
On Friday, 9 July 2021 at 07:21:06 UTC, rempas wrote:
I have the following code:
`prompt[i]!='{'`,here,i=len.so `array overflow`
Thanks a lot. It seems I have a lot to learn. Have an amazing day!
I just wonder if I'm able to do system calls directly from D or
If I have to create bindings from "unistd.h" from C
On Friday, 9 July 2021 at 03:32:31 UTC, Adam D Ruppe wrote:
On Friday, 9 July 2021 at 03:09:52 UTC, Tony wrote:
The editor I am using (Code::Blocks) displays the characters
just fine. So it seems that the error message should be
"Error: Outside the ASCII code space".
D supports stuff outside
On Friday, 9 July 2021 at 08:08:57 UTC, rempas wrote:
I just wonder if I'm able to do system calls directly from D or
If I have to create bindings from "unistd.h" from C
I don't know if it covers what you want but, druntime has those
definitions:
https://github.com/dlang/druntime/blob/master
On Friday, 9 July 2021 at 08:08:57 UTC, rempas wrote:
I just wonder if I'm able to do system calls directly from D or
If I have to create bindings from "unistd.h" from C
If with directly means 'without calling any C function' you can
use inline assembly:
```D
version(linux)
void rt_sigreturn(
On Friday, 9 July 2021 at 08:18:51 UTC, Ferhat Kurtulmuş wrote:
On Friday, 9 July 2021 at 08:08:57 UTC, rempas wrote:
I just wonder if I'm able to do system calls directly from D
or If I have to create bindings from "unistd.h" from C
I don't know if it covers what you want but, druntime has th
On Friday, 9 July 2021 at 08:28:25 UTC, Dennis wrote:
On Friday, 9 July 2021 at 08:08:57 UTC, rempas wrote:
I just wonder if I'm able to do system calls directly from D
or If I have to create bindings from "unistd.h" from C
If with directly means 'without calling any C function' you can
use i
I want this feature in D:
```
element.border = 1, solid;
struct Element
{
@property
void border( int width, BorderStyle style )
{
this.borderWidth = width;
this.borderStyle = style;
}
}
```
Description:
```
element.border = 1, solid;
```
will rewriten to the
```
element.border
On Friday, 9 July 2021 at 10:19:59 UTC, Виталий Фадеев wrote:
I want this feature in D:
```
element.border = 1, solid;
struct Element
{
@property
void border( int width, BorderStyle style )
{
this.borderWidth = width;
this.borderStyle = style;
}
}
```
Description:
```
element.b
On Friday, 9 July 2021 at 10:19:59 UTC, Виталий Фадеев wrote:
It possible in current version 2.097 ?
If you `import std.typecons` you can do:
```D
element.border = tuple(1, solid).expand;
```
But it's not pretty. I suggest either calling the function
regularly, or combing all settings in a si
On Friday, 9 July 2021 at 11:04:23 UTC, Dennis wrote:
On Friday, 9 July 2021 at 10:19:59 UTC, Виталий Фадеев wrote:
It possible in current version 2.097 ?
If you `import std.typecons` you can do:
```D
element.border = tuple(1, solid).expand;
```
But it's not pretty. I suggest either calling t
On 7/9/21 12:21 AM, rempas wrote:
>while (prompt[i] != '{' && i < len) {
In addition to what others said, you can take advantage of ranges to
separate concerns of filtering and iteration. Here are two ways:
import core.stdc.stdio;
import std.algorithm;
// Same as your original
void print
On Wednesday, 7 July 2021 at 01:44:20 UTC, Steven Schveighoffer
wrote:
But it got me thinking, how often do people roll their own vs.
trying to compose using existing Phobos nuggets?
When there's not an obvious/simple way to do something by
composing ranges, I tend to just give up and write pr
On Friday, 9 July 2021 at 11:56:40 UTC, Ali Çehreli wrote:
In addition to what others said, you can take advantage of
ranges to separate concerns of filtering and iteration. Here
are two ways:
[...]
Of course another help from the legend himself ;) As always
thanks a lot and have an amazing
The file can be found quickly
[here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" function for the equivalent system call? "close", "write", "read" etc. all exist. Anyone knows what's going
On 10/07/2021 2:51 AM, rempas wrote:
The file can be found quickly
[here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/unistd.d)
or in your system if you want. Now the question is, why isn't there an
"open" function for the equivalent system call? "close", "write", "read"
On 7/9/21 10:51 AM, rempas wrote:
The file can be found quickly
[here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/unistd.d)
or in your system if you want. Now the question is, why isn't there an
"open" function for the equivalent system call? "close", "write", "read"
etc.
On Friday, 9 July 2021 at 15:04:32 UTC, rikki cattermole wrote:
On 10/07/2021 2:51 AM, rempas wrote:
The file can be found quickly
[here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" func
On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer
wrote:
But reading/writing, closing these file descriptors is always
the same.
For sockets you'd typically use `recv` and `send` instead or
`read` and `write` because the former give extra options and the
latter don't work on Window
On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer
wrote:
On 7/9/21 10:51 AM, rempas wrote:
The file can be found quickly
[here](https://github.com/dlang/druntime/blob/master/src/core/sys/posix/unistd.d) or in your system if you want. Now the question is, why isn't there an "open" func
On Friday, 9 July 2021 at 15:31:50 UTC, Dennis wrote:
On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer
wrote:
But reading/writing, closing these file descriptors is always
the same.
For sockets you'd typically use `recv` and `send` instead or
`read` and `write` because the former
On 7/9/21 8:31 AM, rempas wrote:
> I searched "fnctl" in the repo [...] Probably made a typo
Yes, the typo should be obvious to the non-dyslexic among us. :)
fnctl <-- wrong
fcntl <-- correct
Ali
On 7/9/21 11:31 AM, Dennis wrote:
On Friday, 9 July 2021 at 15:11:38 UTC, Steven Schveighoffer wrote:
But reading/writing, closing these file descriptors is always the same.
For sockets you'd typically use `recv` and `send` instead or `read` and
`write` because the former give extra options a
On Friday, 9 July 2021 at 15:37:41 UTC, Ali Çehreli wrote:
On 7/9/21 8:31 AM, rempas wrote:
> I searched "fnctl" in the repo [...] Probably made a typo
Yes, the typo should be obvious to the non-dyslexic among us. :)
fnctl <-- wrong
fcntl <-- correct
Ali
Lol, I'm not dyslexic (or at least I
On Fri, Jul 09, 2021 at 05:11:06AM +, Виталий Фадеев via
Digitalmars-d-learn wrote:
[...]
> I using CPU Pentium B970 It is old CPU, but even it contains a
> graphics accelerator.
> Mesa DRI Intel(R) HD Graphics 2000 (SNB GT1), has 4 conveers on GPU.
> Smartphones also contains GPU.
> Because O
I'm reading the library reference for
[core.time](https://dlang.org/phobos/core_time.html#Duration) and
It says that the duration is taken in "hnsecs" and I cannot
understand if we can change that and choose the precision. Does
anyone know if we can do that?
On Friday, 9 July 2021 at 20:43:48 UTC, rempas wrote:
I'm reading the library reference for
[core.time](https://dlang.org/phobos/core_time.html#Duration)
and It says that the duration is taken in "hnsecs" and I cannot
understand if we can change that and choose the precision. Does
anyone know
On 7/9/21 1:54 PM, Paul Backus wrote:
On Friday, 9 July 2021 at 20:43:48 UTC, rempas wrote:
I'm reading the library reference for
[core.time](https://dlang.org/phobos/core_time.html#Duration) and It
says that the duration is taken in "hnsecs" and I cannot understand if
we can change that and c
On Friday, 9 July 2021 at 20:54:21 UTC, Paul Backus wrote:
On Friday, 9 July 2021 at 20:43:48 UTC, rempas wrote:
I'm reading the library reference for
[core.time](https://dlang.org/phobos/core_time.html#Duration)
and It says that the duration is taken in "hnsecs" and I
cannot understand if we
On Friday, 9 July 2021 at 21:13:02 UTC, rempas wrote:
```
Duration dur = end - start;
dur = dur.total!"nsecs";
```
What are you trying to do, assigning a nanosecond value to a
Duration? The Duration already has that many nanoseconds in it.
and I get the following error message:
"Error: can
i think it only allocate when it hit the assert, but program will
halt so it's not big deal, even though i feel this is a stupid
design to make everything depend on GC... it gives bad impression
when you want avoid it
here is how i do to detect hidden GC allocations
https://run.dlang.io/is/H
On Friday, 9 July 2021 at 21:13:02 UTC, rempas wrote:
On Friday, 9 July 2021 at 20:54:21 UTC, Paul Backus wrote:
On Friday, 9 July 2021 at 20:43:48 UTC, rempas wrote:
I'm reading the library reference for
[core.time](https://dlang.org/phobos/core_time.html#Duration)
and It says that the durati
On 7/8/21 11:11 AM, DLearner wrote:
Hi
Please confirm that:
`
assert(false, __FUNCTION__ ~ "This is an error message");
`
Will _not_ trigger GC issues, as the text is entirely known at compile
time.
Best regards
One way of forcing compile-time evaluation in D is to define an enum
(whi
On Friday, 9 July 2021 at 22:53:10 UTC, Ali Çehreli wrote:
On 7/8/21 11:11 AM, DLearner wrote:
Hi
Please confirm that:
`
assert(false, __FUNCTION__ ~ "This is an error message");
`
Will _not_ trigger GC issues, as the text is entirely known at
compile time.
Best regards
One way of for
On 7/9/21 4:12 PM, russhy wrote:
>> One way of forcing compile-time evaluation in D is to define an enum
>> (which means "manifest constant" in that use).
That's all I meant. It was a general comment.
> this is very bad, assert are good because they are one liner, making it
> 2 line to avoid GC
On Friday, 9 July 2021 at 23:34:25 UTC, Ali Çehreli wrote:
On 7/9/21 4:12 PM, russhy wrote:
>> One way of forcing compile-time evaluation in D is to define
an enum
>> (which means "manifest constant" in that use).
That's all I meant. It was a general comment.
> this is very bad, assert are goo
On 7/9/21 5:04 PM, Ali Çehreli wrote:
On 7/9/21 1:54 PM, Paul Backus wrote:
On Friday, 9 July 2021 at 20:43:48 UTC, rempas wrote:
I'm reading the library reference for
[core.time](https://dlang.org/phobos/core_time.html#Duration) and It
says that the duration is taken in "hnsecs" and I cannot
On 7/9/21 8:44 PM, russhy wrote:
On Friday, 9 July 2021 at 23:34:25 UTC, Ali Çehreli wrote:
On 7/9/21 4:12 PM, russhy wrote:
>> One way of forcing compile-time evaluation in D is to define
an enum
>> (which means "manifest constant" in that use).
That's all I meant. It was a general comment.
On Saturday, 10 July 2021 at 01:23:26 UTC, Steven Schveighoffer
wrote:
On 7/9/21 8:44 PM, russhy wrote:
On Friday, 9 July 2021 at 23:34:25 UTC, Ali Çehreli wrote:
On 7/9/21 4:12 PM, russhy wrote:
>> One way of forcing compile-time evaluation in D is to
>> define
an enum
>> (which means "mani
On Friday, 9 July 2021 at 19:15:44 UTC, H. S. Teoh wrote:
On Fri, Jul 09, 2021 at 05:11:06AM +, Виталий Фадеев via
Digitalmars-d-learn wrote: [...]
[...]
[...]
[...]
Generally, text rendering on OpenGL is a huge pain to
implement. This is not specific to D, but to OpenGL in general,
be
On Friday, 9 July 2021 at 21:04:42 UTC, Ali Çehreli wrote:
On 7/9/21 1:54 PM, Paul Backus wrote:
[...]
Yes but the resolution seems not to be better than 100 nsecs. A
quick research reveals a better resolution is not possible with
common hardware on at least Linux.
The following program al
45 matches
Mail list logo