On Thursday, 11 April 2024 at 16:23:44 UTC, Andy Valencia wrote:
[...]
void
main(in string[] argv)
^^
What if you want to use
bool memorymapped;
getopt (argv, "m", &memorymapped);
inside main? [1]
Have you tried using "rm" [2] instead of "r" as stdioOpenmode
under Linux
for a
On Friday, 31 May 2024 at 16:07:23 UTC, Andy Valencia wrote:
I'm coding a server which takes TCP connections. I end up in
the main thread with .accept() which hands me a Socket. I'd
like to hand this off to a spawn()'ed thread to do the actual
work.
Have you taken into consideration that ea
In order to make this work
```d
import std.typecons;
alias vstring = Typedef!string;
void main ()
{
import std.stdio;
import std.conv;
auto v = 3.to!vstring; // ain't work out of the box
writeln (v);
auto w = 3.to!string;
writeln (w);
long l = 3.to!long;
writeln (l);
On Saturday, 31 August 2024 at 14:25:29 UTC, Paul Backus wrote:
[...]
Once the next release of Phobos comes out, with [PR 9039][1]
merged, you'll be able to do it like this:
```d
import std.typecons;
Nullable!V maybeGet(K, V)(V[K] aa, K key)
{
if (auto ptr = key in aa)
return null
On Saturday, 31 August 2024 at 13:48:52 UTC, ryuukk_ wrote:
On Saturday, 31 August 2024 at 13:00:42 UTC, Steven
Schveighoffer wrote:
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote:
```D
void main()
{
int[string] test;
test["hello"] = 42;
if (auto it = "hello" in test)
On Wednesday, 4 August 2021 at 09:41:45 UTC, Mathias LANG wrote:
[...]
JSONType used to be named `JSON_TYPE`, and this was changed in
v2.082.0. I think GDC-11 is somewhere around v2.076.0 (with a
lot of backport for bugs, but no feature / Phobos backport).
Since v2.082.0 was released 2018-09-02
On Saturday, 16 April 2022 at 13:45:17 UTC, kdevel wrote:
[...]
Will that be corrected in GCC 11.3 or not until GCC 12?
GCC 12.
On Sunday, 15 May 2022 at 11:10:41 UTC, SvGaming wrote:
I want to ask the user to select their USB drive by typing the
mount location. For some reason that does not work and just
skips over the user input part.
```d
void writeusb() {
writeln("Here is a list of your mounted drives: ");
On Sunday, 15 May 2022 at 12:19:22 UTC, SvGaming wrote:
[...]
This code runs as expected.
Strange. It does not for me. I even tried different compilers.
It simply does not ask for user input here where it is supposed
to:
```d
writef("Type the path to your USB drive: ");
string cont = readln;
On Sunday, 15 May 2022 at 15:27:32 UTC, SvGaming wrote:
[...]
It works if that code is the main function. But in the full
program that is only one of the functions and is not the main
function.
Until you post your full programm ideally in a reduced form [1]
everybody who is willing to help mu
On Monday, 16 May 2022 at 16:53:15 UTC, SvGaming wrote:
[...]
https://github.com/svgaming234/ezusb
forgot to post it in the previous reply, I am kind of stupid
In main your program reads an integer:
```
int n;
writef("Pick an option: ");
readf(" %s", &n);
```
but your console/Termina
I am compiling some test code which dmd v2.100.and linking
against a libdecimal.a compiled in March, probably compiled with
dmd v2.099.0.
```
$ dmd -g mytest.d decimal.git/libdecimal.a
```
Now the linker complains:
```
decimal.git/libdecimal.a(decimal_4f_a27.o):(.data._D7decimalQi25Invalid
I am trying to build a project with GDC. It successfully compiles
with dmd and ldmd2. When I use gdc in one go the binary is
successfully build:
```
$ gdc -o ppinsta esah.d evaluate.d jsr.d jsw.d parser.d ppinsta.d
ptvr.d stack.d testdatagenerator.d
```
Though after compiling separately the
On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
Any ideas?
ppinsta.d
```
import std.stdio : write, writeln;
import parser; // <- comment this out and gdc links
void main ()
{
string [string] h;
writeln (h);
}
```
parser.d
```
module parser;
import std.regex : regex;
private imm
On Saturday, 28 May 2022 at 14:03:13 UTC, Adam D Ruppe wrote:
On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
gdc -o ppinsta ppinsta.o esah.o evaluate.o jsr.o jsw.o
parser.o ptvr.o stack.o testdatagenerator.o
You might need to add -lgphobos or -lgphobos2 or whatever it is
called too e
On Saturday, 28 May 2022 at 13:55:09 UTC, Tejas wrote:
On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
I am trying to build a project with GDC. It successfully
compiles with dmd and ldmd2. When I use gdc in one go the
binary is successfully build:
[...]
Is seperate compilation worki
On Saturday, 28 May 2022 at 14:44:56 UTC, Adam D Ruppe wrote:
On Saturday, 28 May 2022 at 14:16:51 UTC, kdevel wrote:
$ gdc -o ppinsta ppinsta.d parser.d
Compiling together is faster anyway this is prolly what you
want most the time.
But I know what's going on now, it is the template emissi
On Saturday, 28 May 2022 at 14:37:07 UTC, kdevel wrote:
dmd:
```
$ dmd -c ppinsta.d
$ dmd -c parser.d
$ dmd -of=ppinsta ppinsta.o parser.o
$ ./ppinsta
[]
```
(checking ldc/ldmd2 later)
```
$ ldc2 -c ppinsta.d && ldc2 -c parser.d && ldc2 -of=ppinsta
ppinsta.o parser.o && ./ppinsta
[]
$ ldmd2
On Saturday, 28 May 2022 at 15:10:25 UTC, Steven Schveighoffer
wrote:
[...]
Is this specific to gdc, or does it happen for other compilers
as well?
The former.
On Friday, 18 March 2022 at 19:42:02 UTC, Anonymouse wrote:
On Thursday, 17 March 2022 at 14:00:45 UTC, kdevel wrote:
If ```import std.regex;``` is commented out or if
```-checkaction=context``` is removed from the cmd line the
unittest passes. Can anybody reproduce this?
https://run.dlang.io
On Friday, 3 June 2022 at 23:40:50 UTC, Steven Schveighoffer
wrote:
During the last beerconf, I wrote a short blog post about how
`Error` and `Exception` are different, and why you should never
continue after catching `Error`s.
Feedback welcome, I didn't announce here when I wrote it
because
On Saturday, 4 June 2022 at 14:05:14 UTC, Paul Backus wrote:
[...]
What does that mean? Am I `Error` blind?
Generally you do not need to subclass `Error` yourself. The
most common way of throwing an `Error` in user code is to use
`assert`, which (with default compiler flags) throws an
`As
On Saturday, 4 June 2022 at 16:55:31 UTC, Steven Schveighoffer
wrote:
[...]
The point of an `Error` is that your code can assume it cannot
happen. If it does happen, the code is invalid.
According to my favorite dictionary "assume" means "take for
granted" [1]. If `Error`s may happen how can
On Sunday, 5 June 2022 at 00:40:26 UTC, Ali Çehreli wrote:
[...]
Errors are thrown when the program is discovered to be in an
invalid state.
The following program throws an `Error` in popFront:
import std.range;
void main ()
{
int [1] a;
auto q = a[1..$]; // line 6
On Sunday, 5 June 2022 at 01:43:06 UTC, Steven Schveighoffer
wrote:
[...]
But you aren't perfect, and so maybe you make a mistake, and
trigger an Error. The compiler handles this unexpected
condition by unwinding the stack back to the main function,
printing the error and exiting, so you can
On Sunday, 5 June 2022 at 07:21:18 UTC, Ola Fosheim Grøstad wrote:
[...]
The reality is that software is layered. Faults at different
layers should have different consequences at the discretion of
a capable programmer.
+1
On Sunday, 5 June 2022 at 14:24:39 UTC, Ali Çehreli wrote:
[...]
struct S {
int[] a;
int[] b;
void add(int i) {// <-- Both arrays always same size
a ~= i;
b ~= i * 10;
}
void foo() {
assert(a.length == b.length); // <-- Invariant check
// ...
}
}
void main() {
On Sunday, 5 June 2022 at 17:04:49 UTC, Ali Çehreli wrote:
On 6/5/22 08:07, kdevel wrote:
[...]
Like many other programmers who include me, Sean Parent may be
right.[1]
Other than being a trivial example to make a point, the code
I've shown may be taking advantage of the "structure of array"
On Sunday, 5 June 2022 at 20:53:32 UTC, Steven Schveighoffer
wrote:
[...]
For this purpose nobody needs a separate subclass named
`Error`. That works with `Exception`s.
You can use Exceptions instead. But the difference is they are
part of the program instead of considered a check on the
pro
On Sunday, 5 June 2022 at 21:08:11 UTC, Steven Schveighoffer
wrote:
[...]
Just FYI, this is a *different discussion* from whether Errors
should be recoverable.
The wording of this "question" bothers me really. What does
"Errors" mean here? If you mean thrown object having a (sub)type
of `Err
On Tuesday, 7 June 2022 at 18:37:13 UTC, Steven Schveighoffer
wrote:
[...]
My very common use of `scope(failure)` for my DB code:
```d
conn.exec("START TRANSACTION");
scope(success) conn.exec("COMMIT");
scope(failure) conn.exec("ROLLBACK");
```
Are there multiple (successful) returns in your
On Sunday, 5 June 2022 at 23:57:19 UTC, Steven Schveighoffer
wrote:
On 6/5/22 6:09 PM, kdevel wrote:
On Sunday, 5 June 2022 at 20:53:32 UTC, Steven Schveighoffer
wrote:
[...]
For this purpose nobody needs a separate subclass named
`Error`. That works with `Exception`s.
You can use Exceptions
On Monday, 13 June 2022 at 13:15:42 UTC, Steven Schveighoffer
wrote:
Possibly, but I don't close the handle. It goes back to a pool
to get reused.
Um. I need a (fresh) connection per CGI process. I wonder if
nowadays the TLS startup between the browser and the webserver
isn't at least one o
On Wednesday, 15 June 2022 at 03:09:56 UTC, Steven Schveighoffer
wrote:
I don't see what you see wrong with the code I wrote. It's
straightforward, obvious, and does the job I need it to do, in
a way that's not prone to future mistakes.
Sometimes it is not easy to explain why code "feels" wron
On Wednesday, 15 June 2022 at 20:46:56 UTC, Steven Schveighoffer
wrote:
[...]
It has not harmed my code though. I tried throwing inside a
scope guard, and it just works, I'm not sure why you can't
throw in those?
You can but that is not acceptable for the spec explicitly
forbids that:
On Thursday, 16 June 2022 at 11:28:32 UTC, bauss wrote:
[...]
https://dlang.org/spec/statement.html#scope-guard-statement
Quote (again): "A [...] scope(success) statement may not exit
with a throw [...]."
[...]
If the spec forbids it, but the compiler allows it, wouldn't it
then be a bug?
W
On Thursday, 16 June 2022 at 13:54:52 UTC, Steven Schveighoffer
wrote:
[scope (success) lowered to finally]
[...]
Furthermore I always thought of scope guards as a means for
cleanup. Cleanup implies in my eyes removing things which have
been used in a previous task. This intended use is docu
On Tuesday, 19 July 2022 at 23:19:28 UTC, jfondren wrote:
Thanks for your thorough presentation.
[...]
Another option is to get newer glibc onto this system (not
installing it, just making it available for dmd. use
LD_LIBRARY_PATH).
On older systems the dynamic loader (ld.so) may not execut
On Tuesday, 26 July 2022 at 23:43:59 UTC, pascal111 wrote:
In next example code, it used user-made exception,
[...]
try {
if( b == 0 ) {
throw new Exception("Cannot divide by zero!");
} else {
result = format("%s",a/b);
}
[..
On Wednesday, 27 July 2022 at 09:35:12 UTC, Ali Çehreli wrote:
The following program show an example as well as 'enforce',
which I prefer over explicit if+throw+else:
Me too.
enforce!MissingArguments(args.length == 42,
format!"Too few arguments:
%s"(args.length)
On Thursday, 28 July 2022 at 06:12:49 UTC, Alexander Zhirov wrote:
On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov
wrote:
```sh
/root/usr/program/gcc/9.5.0/install/bin/cc app.o -o app
-L/root/usr/program/ldc/1.30/install/lib -lphobos2-ldc
-ldruntime-ldc -Wl,--gc-sections -lrt -ldl
On Thursday, 28 July 2022 at 00:46:19 UTC, pascal111 wrote:
On Thursday, 28 July 2022 at 00:36:54 UTC, ryuukk_ wrote:
I don't remember the exact syntax for GDC, but it should be
pretty similar to DMD
You need to pass the module to the compiler
gdc main.d dcollect.d
I'm using CODE::BLOCK
On Thursday, 28 July 2022 at 10:39:06 UTC, Alexander Zhirov wrote:
[...]
I don't understand what I need to do.
You wrote
At first I thought that I needed to rebuild the GCC compiler
for the i586
architecture. I downloaded GCC 9.5.0 and started the
installation:
Then you wrote that
On Wednesday, 27 July 2022 at 18:19:34 UTC, pascal111 wrote:
I made a library of some useful functions while I was studying
C, and I'm curious to know if D has equivalents or some ones
for some of my functions, or I have to retype 'em again in D.
The library link:
https://github.com/pascal111-
On Thursday, 28 July 2022 at 12:26:50 UTC, pascal111 wrote:
[...]
Aha! you mean "/**/",
it has no job, just to separate between functions codes.
Do you think it helps the compiler if you put these
`/**/`
between
On Thursday, 28 July 2022 at 12:25:05 UTC, pascal111 wrote:
[...]
ofix.c: In function 'fix':
ofix.c:7:3: warning: 'z' is used uninitialized
[-Wuninitialized]
7 | y=modf(x,z);
| ^
ofix.c:5:12: note: 'z' was declared here
5 | double y,* z;
|^
```
I woul
On Thursday, 28 July 2022 at 12:45:51 UTC, Alexander Zhirov wrote:
[...]
I have already downloaded the latest GCC sources, nothing
compiles anyway.
How did you manage to get hold of this compiler?
```
/root/usr/program/gcc/9.5.0/install/bin/cc
```
Everything falls on the same error.
```sh
c
On Thursday, 28 July 2022 at 12:44:19 UTC, pascal111 wrote:
[...]
Do you think it helps the compiler if you put these
`/**/`
between your functions? Or is there anybody else who benefits
from it?
"Do you think it helps the compiler if you put these"
Ar
On Thursday, 28 July 2022 at 13:58:24 UTC, pascal111 wrote:
[...]
Precisely in what way? I am not kidding. I am seriously asking
the question: In what way may a C or C++ compiler benefit from
lines between functions which contain only comments consisting
of nothing else than asterisks?
Seriou
On Thursday, 28 July 2022 at 14:57:36 UTC, pascal111 wrote:
[...]
Sure. What effect do YOU hope to causes or prevent by writing
```
/**/
```
between all of your functions?
I'm normal programmer, by mean that I'm not so expert in C
matters to know reall
On Thursday, 28 July 2022 at 15:25:00 UTC, Alexander Zhirov wrote:
On Thursday, 28 July 2022 at 13:16:26 UTC, kdevel wrote:
On Thursday, 28 July 2022 at 12:45:51 UTC, Alexander Zhirov
wrote:
[...]
I have already downloaded the latest GCC sources, nothing
compiles anyway.
How did you manage t
On Thursday, 28 July 2022 at 15:25:00 UTC, Alexander Zhirov wrote:
[...]
Everything falls on the same error.
```sh
checking for suffix of object files... configure: error: in
`/home/thinstation/source/gcc/12.1.0/build/i586-pc-linux-gnu/libgcc':
configure: error: cannot compute suffix of object
On Thursday, 28 July 2022 at 16:03:46 UTC, Alexander Zhirov wrote:
[...]
How did you manage to get hold of this compiler?
```
/root/usr/program/gcc/9.5.0/install/bin/cc
```
Where does this compiler come from?
This is an unpacked archive from an official source from the
GNU website
https:/
On Monday, 1 August 2022 at 07:35:34 UTC, Christian Köstlin wrote:
[...]
```
An arguably shorter solution (that drops some of your logging)
could be:
```d
import std;
void main() {
dirEntries(".", "*.json", SpanMode.shallow)
.filter!(f => !f.name.canFind("output"))
.map!(r
At DConf '22 day 3 Robert Schadek presented at around 07:22:00 in
the YT video the function `splitIds`. Given an HTML page from
bugzilla containing a list of issues `splitIds` aims at
extracting all bug-ids referenced within a specific url context:
```
long [] splitIds (string page)
{
enum
On Monday, 8 August 2022 at 17:45:03 UTC, bauss wrote:
On Monday, 8 August 2022 at 13:55:02 UTC, ag0aep6g wrote:
auto x = s.x;
[...]
Your problem is here and not because it was __gshared.
You're copying the value and obviously it can be changed in the
meantime, that's common sense.
On Friday, 12 August 2022 at 21:41:25 UTC, Christian Köstlin
wrote:
which would enable something like
```d
return s
.readText
.parseJSON
.contextWithException((UTFException e) {
return new Exception("Cannot process UTF-8 in
config file%s\n %s".format(
On Saturday, 13 August 2022 at 13:36:08 UTC, Christian Köstlin
wrote:
[...]
1. error handling in main path: exactly thats what I would like
todo. but for that the errors that raise need to have
meaningful information. this is exactly what I am trying in
those context* functions ... they do not
Quote from `src/druntime/src`:
```
/**
* Returns:
* A reference to the _next error in the list. This is used
when a new
* $(D Throwable) is thrown from inside a $(D catch) block.
The originally
* caught $(D Exception) will be chained to the new $(D
Throwable) via this
On Sunday, 2 October 2022 at 23:37:26 UTC, ryuukk_ wrote:
I got the answer thanks to IRC chat:
https://dlang.org/spec/declaration.html#void_init
Quote:
Implementation Defined: If a void initialized variable's value
is used
before it is set, its value is implementation defined.
Shouldn
On Monday, 3 October 2022 at 15:56:02 UTC, Paul Backus wrote:
Shouldn't this read
Unspecified Value: If a void initialized variable's value
is used
before it is set, its value is unspecified.
Yes, it should. Many of the contributors to the D spec are not
very well versed in the precis
Is this a known bug?
```
// file b.d
import std.stdio;
struct S {
private void foo (ubyte c)
{
writeln (__PRETTY_FUNCTION__);
}
void foo ()
{
}
}
```
```a.d
// file a.d
unittest {
import b;
auto s = S ();
s.foo ('x');
}
```
```
$ dmd -g -unittest -main a.d b.d
On Saturday, 8 October 2022 at 09:46:59 UTC, kdevel wrote:
```
$ dmd -g -unittest -main a.d b.d
$ ./a
void b.S.foo(ubyte c)
1 modules passed unittests
```
2.086.1
a.d(5): Error: struct `b.S` member foo is not accessible
2.090.1
compiles
On Saturday, 8 October 2022 at 09:59:17 UTC, kdevel wrote:
On Saturday, 8 October 2022 at 09:46:59 UTC, kdevel wrote:
```
$ dmd -g -unittest -main a.d b.d
$ ./a
void b.S.foo(ubyte c)
1 modules passed unittests
```
2.086.1
a.d(5): Error: struct `b.S` member foo is not accessible
2.09
On Saturday, 8 October 2022 at 10:05:33 UTC, kdevel wrote:
```
$ dmd -g -unittest -main -run a.d b.d
a.o: In function `_D1a16__unittest_L2_C1FZv':
(...)./a.d:5: undefined reference to `_D1b1S3fooMFhZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
```
`b.d` is th
On Saturday, 8 October 2022 at 15:56:01 UTC, Jack Pope wrote:
Altering the definition sequence in b.d to have the private
version second has the desired result. Otherwise, when
following private foo, it looks like public foo gets adopted as
a public constructor. The same for classes.
Created
Given a struct `S` with method `foo`: Any of these expressions
```
&foo
&S.foo
&.S.foo
```
when they occur inside the struct they represent a delegate and
not a function pointer. Is it okay to "extract" and use the
function pointer from the delegate in this way:
```
struct S {
void
On Saturday, 15 October 2022 at 00:31:47 UTC, Iain Buclaw wrote:
```
auto funcptr (alias method) ()
{
return &method;
}
:
fun = funcptr!bar;
:
```
Which works but neither dmd nor gdc were able to optimize the
additional function call away.
pragma(inline, true)
auto funcpt
On Wednesday, 9 November 2022 at 19:05:58 UTC, Ali Çehreli wrote:
In case it matters, the file system is ext4.
My code runs in tmp (tmpfs).
2) Make a sub-directory:
mkdir deleteme/a
Running the program shows no output; 'a' is not visited as a
directory entry.
Was say strace/ltrace?
``
On Thursday, 10 November 2022 at 21:27:28 UTC, Ali Çehreli wrote:
On 11/9/22 12:06, Ali Çehreli wrote:
> I am using its sibling 'ftw'
Now that we know that dirEntries works properly, I decided not
to use ftw.
However, ftw performs about twice as fast as dirEntries
(despite some common code
On Monday, 14 November 2022 at 17:08:38 UTC, Gavin Ray wrote:
Just came here to say I hit the same bug, here's my import list:
* https://issues.dlang.org/show_bug.cgi?id=19937
object._d_assert_fail linker error if compiling with
-checkaction=context
* https://issues.dlang.org/show_bug.cgi?
On Friday, 11 November 2022 at 16:00:12 UTC, Ali Çehreli wrote:
On 11/11/22 05:13, kdevel wrote:
> dmd -O compiled patched (see below!) version applied to
/usr/bin on my
> desktop
> yields:
>
> ftw : 363 ms, 750 ÎŒs, and 5 [*]
> dirEntries: 18 secs, 831 ms, 738 ÎŒs, and 3 [*]
Great. I did
On Monday, 14 November 2022 at 21:05:01 UTC, kdevel wrote:
[...]
the runtimes are
ftw : 98 ms, 470 ÎŒs, and 2 *beeep*
dirEntries: 170 ms, 515 ÎŒs, and 2 *beeep*
(to be continued)
When I examine the process with strace it appears that the ftw
version gets the whole information fro
https://dlang.org/spec/importc.html
`square.c`
```
int square(int i)
{
return i * i;
}
```
`demo.d`
```
import std.stdio;
import square;
void main()
{
int i = 7;
writefln("The square of %s is %s", i, square(i));
}
```
```
$ dmd --version
DMD64 D Compiler v2.101.1
Copyright (C) 1999-2
On Friday, 13 January 2023 at 12:20:23 UTC, Dennis wrote:
I don't think there's a way to test examples of separate
compilation in the spec currently.
What must be added or changed in order to test every example
which is intended to produce an executable?
After reading Walter's remark "ImportC sees those macro
definitions and transforms them into manifest constant
declarations" in
Issue 23622 - ImportC #defines conflict with declarations
I wondered how it was implemented:
`myccode.c`
```
int getx ()
{
return X;
#define X 1
}
```
`imc.d
On Sunday, 12 March 2023 at 13:27:05 UTC, Adam D Ruppe wrote:
[...] *any* storage class will work for type inference. [...]
After heaving read [1] I immediately thought of this:
void main ()
{
deprecated i = 3;
i = 4;
}
$ dmd test.d
test.d(4): Deprecation: variable `
On Thursday, 13 April 2023 at 22:09:48 UTC, Jacob Shtokolov wrote:
[...]
ref opIndex(string key) return
[...]
Regarding the return ref I found this code of 2019 on my harddisk
which is from or was motivated by a dconf talk:
```
ref int foo (ref int i)
{
return i;
}
ref int bar ()
{
On Friday, 14 April 2023 at 09:42:14 UTC, Bastiaan Veelo wrote:
[...]
Up to dmd v2.100.2 I am warned/get an error during compilation:
```
$ dmd returnref2.d
returnref2.d(3): Deprecation: returning `i` escapes a
reference to parameter `i`
returnref2.d(1):perhaps annotate the parameter wi
On Friday, 14 April 2023 at 11:18:21 UTC, Dennis wrote:
On Friday, 14 April 2023 at 10:31:58 UTC, kdevel wrote:
But in fact it is returned unless it is `return ref`.
When using `return ref`, `return scope`, `scope` etc., you
should be using the latest compiler and annotate functions you
want
On Saturday, 15 April 2023 at 12:45:31 UTC, Richard (Rikki)
Andrew Cattermole wrote:
It was bad analysis by the compiler, which has since been
corrected.
It should have been applied only to @safe code.
But why is the @unsafe programmer now left unprotected in cases
like this
```
ref int fo
On Saturday, 15 April 2023 at 13:24:52 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 16/04/2023 1:20 AM, kdevel wrote:
On Saturday, 15 April 2023 at 12:45:31 UTC, Richard (Rikki)
Andrew Cattermole wrote:
It was bad analysis by the compiler, which has since been
corrected.
It should have be
On Saturday, 15 April 2023 at 14:10:57 UTC, Dennis wrote:
[...]
This adds complexity, just to add some 'intermediate' safety
between `@system` and `@safe` in a few cases. It's better to
keep the rules simple and consistent.
Thanks for the answer! While playing around with return ref I
came a
On Saturday, 15 April 2023 at 15:50:18 UTC, Dennis wrote:
[...]
care about the type / mutability of the pointer.
Returning `i`'s address in a long does not trigger the escape
detector:
```
long foo (long s, return ref int i)
{
s = cast (long) &i;
return s;
}
auto bar ()
{
int i;
```
import std.range;
import std.parallelism;
void vec_op (double [] outp, const double [] inp,
double function (double) f)
{
foreach (ref a, b; parallel (lockstep (outp, inp)))
a = f (b);
}
```
Should this compile? dmd says
```
[...]/src/phobos/std/parallelism.d(4094): Error: canno
On Friday, 19 May 2023 at 11:07:01 UTC, anonymouse wrote:
What am I doing wrong here?
[...]
curl.set(CurlOption.writedata, &fp);
According to [1] this line must read
```
curl.set(CurlOption.writedata, cast (void *) fp.getFP());
```
[1] https://curl.se/libcurl/c/CURLOPT_WRITEDAT
On Friday, 19 May 2023 at 23:36:28 UTC, anonymouse wrote:
[...]
The reason I used a while loop was to detect loss of internet
connection and resume the process once the connection is
re-established.
What if the internet connection is not re-established within an
reasonable amount of time? Wh
Thanks for your explications!
On Friday, 19 May 2023 at 21:18:28 UTC, Ali Çehreli wrote:
[...]
- std.range.zip can be used instead but it does not provide
'ref' access to its elements.
How/why does sort [1] work with zipped arrays?
[...]
The following amap example there may be useful for y
On Saturday, 20 May 2023 at 18:27:47 UTC, Ali Çehreli wrote:
[...]
And I've just discovered something.
Me2! The serial version using array indexing
void vec_op_naive0 (double [] outp, const double [] inp,
double function (double) fp)
{
enforce (inp.length == outp.length);
On Friday, 26 May 2023 at 13:18:15 UTC, Steven Schveighoffer
wrote:
[...]
This worked for me:
```d
char[4] fourC(string s)
{
if(s.length >= 4)
return s[0 .. 4];
Silent truncation? Non-ASCII chars?
char[4] res = 0;
According to [1], [2] or [3] that should read
```
char[
On Sunday, 2 July 2023 at 17:02:44 UTC, Paul wrote:
I have a struct similar to the following example. I'd like to
build an adder method without having to code the whole method.
How do I use the D language to do this? Template, mixins,
CTFE..all of them?
```d
struct myS {
int a, b, c, d
On Tuesday, 15 August 2023 at 17:59:27 UTC, vino wrote:
Request your help in finding duplicate element without sorting
as per the below example
```d
module remove_duplicates;
import std.stdio;
import std.format : format;
import std.string : strip;
int main (string [] args)
{
bool [string]
On Saturday, 11 November 2023 at 17:29:14 UTC, BoQsc wrote:
https://dlang.org/library/std/process.html
How do I pipe (|) through three programs using std.process?
```
echo This is a sample text | find "sample" | find "text"
```
```d
import std.stdio;
import std.process;
version (Windows) { e
On Saturday, 18 November 2023 at 18:09:53 UTC, BoQsc wrote:
Latest iteration on this thread.
Limitations:
* pipes through two programs.
* very verbose, hard to use.
What exactly are you trying to achieve?
```
import std;
import std.process;
version (Windows) { enum Find = "find"; }
version
On Friday, 24 November 2023 at 13:05:30 UTC, Ferhat Kurtulmuş
wrote:
[...]
```
import core.stdc.stdio : sprintf;
import core.stdc.math : log10;
import std.exception : assumeUnique;
import std.stdio : writeln;
size_t nod(int num){
return cast(size_t)((num==0)?1:log10(num)+1);
}
On Tuesday, 28 November 2023 at 09:43:47 UTC, Dom DiSc wrote:
On Tuesday, 28 November 2023 at 08:51:21 UTC, Mark Davies wrote:
On Friday, 24 November 2023 at 09:35:00 UTC, BoQsc wrote:
```
import std.stdio;
char[10] longToString(long n) @nogc
```
For a 'long' 10 characters is likely to be not
On Wednesday, 29 November 2023 at 16:48:09 UTC, Paul Backus wrote:
[...]
If you're using a new enough compiler, it even supports named
arguments:
S3 fun2() { return S3(b: 2, a: 5); }
Indeed. Seems to be in dmd since 2.103.0 (2.102.2 didn't support
this syntax). Alas, the Change Log [1] re
After switching to dmd v2.105.3 I get this warnings almost
everywhere. Do I really have to fork msgpack-d in order to get
rid of these warnings?
Now I replaced every "in ref" with "in" in my own code but I do
not add that preview flag to the compiler invocation. Is that
safe?
If I not use -allinst the linker complains when using the current
msgpack-d v1.0.5, e.g.
[...]msgpack-d/src/msgpack/package.d:203: undefined reference to
`pure nothrow @nogc @safe immutable(char)[]
core.internal.dassert._d_assert_fail!(int)._d_assert_fail!(int)._d_assert_fail(scope const(immut
On Saturday, 16 December 2023 at 20:04:54 UTC, Kevin Bailey wrote:
I've added a TON of writeln's to confirm this. The *instant* I
made the parameter "ref", the real program starts acting as
expected, and the print-outs show the correct results.
If you comment out this line
```
//m[f] = 1;
1 - 100 of 365 matches
Mail list logo