On Tuesday, 2 April 2024 at 18:21:58 UTC, Mike Shah wrote:
An easier fix may be perhaps to just use 'dub' and install the
glfw dependency. In my talk, I did everything from scratch (my
preferred way), though I suspect using dub with glfw-d
(https://code.dlang.org/packages/glfw-d) may provide
On Monday, 1 April 2024 at 21:23:50 UTC, WhatMeWorry wrote:
Huge fan of Mike Shah's YouTube videos regarding D and his
latest for D conference:
https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf
So I installed github desktop
On Monday, 1 April 2024 at 21:23:50 UTC, WhatMeWorry wrote:
Huge fan of Mike Shah's YouTube videos regarding D and his
latest for D conference:
https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf
So I installed github desktop
Huge fan of Mike Shah's YouTube videos regarding D and his latest
for D conference:
https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf
So I installed github desktop app and cloned his Talks repo.
There is a build command
On Monday, 4 March 2024 at 18:08:52 UTC, Andy Valencia wrote:
For any other newbie dlang voyagers, here's a version which
works as expected using the system memory allocator. On my
little i7 I get 1.48 secs wallclock with 5.26 CPU seconds.
...
Using a technique I found in a unit test in
On Monday, 4 March 2024 at 16:02:50 UTC, Andy Valencia wrote:
On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew
Cattermole wrote:
... I still hope to be able to share memory between spawned
threads, and if it isn't a shared ref of a shared variable,
then what would it be? Do I
On Monday, 4 March 2024 at 16:02:50 UTC, Andy Valencia wrote:
On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew
Cattermole wrote:
A way to do this without spawning threads manually:
...
Thank you! Of course, a thread dispatch per atomic increment
is going to be s.l.o.w., so
On Monday, 4 March 2024 at 03:42:48 UTC, Richard (Rikki) Andrew
Cattermole wrote:
A way to do this without spawning threads manually:
...
Thank you! Of course, a thread dispatch per atomic increment is
going to be s.l.o.w., so not surprising you had to trim the
iterations.
Bug I still
A way to do this without spawning threads manually:
```d
import std.parallelism : TaskPool, parallel, taskPool, defaultPoolThreads;
import std.stdio : writeln;
import std.range : iota;
enum NSWEPT = 1_000_000;
enum NCPU = 4;
void main() {
import core.atomic : atomicLoad, atomicOp;
I tried a shared memory parallel increment. Yes, it's basically
a cache line thrasher, but I wanted to see what's involved in
shared memory programming. Even though I tried to follow all the
rules to make true shared memory (not thread local) it appears I
failed, as the wait loop at the end
This is the type defined from c code import by importC:
```c
struct A {
int count;
int[] i;
}
```
This kind data need to be init as const to avoid runtime cost,
and need to be done from D code.
how can I do this ?
To put code into D source, I can use "-i=package" to
automatically
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote:
a bug ?
It helps if you explain what you're talking about so we don't
have to guess.
I tried the code on my computer and it worked fine. But then
figuring, you must be saying something doesn't work right, I
tried it on another
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote:
[...]
a bug ?
thanks anyway
Try to define the flag as static
```d
static shared(bool) isDone = false;
```
I dont know if that should be a compiler error to have local
shared (I tend to think yes as locals are specific to a frame,
import core.thread;
import std.concurrency;
import std.stdio : w = writeln;
void w2(shared(bool) *done)
{
while (*done == false)
{
Thread.sleep(100.msecs);
w("print done? ", *done);
}
}
void s2()
{
shared(bool)
On Tuesday, 28 November 2023 at 18:43:37 UTC, Adam D Ruppe wrote:
On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote:
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A,
from A_Ptr of type A*.
I think what you really want is
On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote:
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A,
from A_Ptr of type A*.
I think what you really want is
typeof(*A_Ptr) ASUB;
the typeof thing returns the type you'd get from the
Trying to manipulate 'typeof' return strings, preferably at
compile-time.
e.g. to produce struct B below (intended to have an A
sub-struct), from A_Ptr alone.
```
struct A {
int AFld1;
}
A* A_Ptr;
struct B {
int BFld2;
typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from
On Wednesday, 1 November 2023 at 20:49:16 UTC, Zz wrote:
Hi,
Currently using std.csv and would like to do the following
using mir.csv.
auto data = std.csv.csvReader!Layout(input).array;
Are there any examples out there on using mir.csv?
Regards,
Zz
you can find some examples in source
Hi,
Currently using std.csv and would like to do the following using
mir.csv.
auto data = std.csv.csvReader!Layout(input).array;
Are there any examples out there on using mir.csv?
Regards,
Zz
On Sunday, 21 May 2023 at 11:20:30 UTC, ag0aep6g wrote:
On 21.05.23 12:55, Theo wrote:
As for the other part, if I use an abstract base class, I
*must* indicate when i'm overriding the base class method by
explicately saying 'override'.
I wouldn't mind if implementing interface methods
On 21.05.23 12:55, Theo wrote:
As for the other part, if I use an abstract base class, I *must*
indicate when i'm overriding the base class method by explicately saying
'override'.
I wouldn't mind if implementing interface methods required `override` as
well. I don't know if there is a
On Sunday, 21 May 2023 at 10:33:07 UTC, ag0aep6g wrote:
On 21.05.23 12:28, ag0aep6g wrote:
Since @trusted functions are guaranteed (by the programmer) to
be safe, they are allowed to overload/implement @safe
functions/prototypes.
*override
oh ok. so i can override a @safe interface method
On 21.05.23 12:28, ag0aep6g wrote:
Since @trusted functions are guaranteed (by the programmer)
to be safe, they are allowed to overload/implement @safe
functions/prototypes.
*override
On 21.05.23 11:55, Theo wrote:
class MerchantShip : Ship
{
private int speed = 0; // If only I had 'private(this)' !!
// how do I know this method is actually an implementation of an
interface method
// and not a method specific to this class?
// AND ... how come I can
see comments in the code below. they are my questions.
But feel free to ignore the comment about 'private(this)' ;-)
interface Ship
{
@safe void setSpeed(int speed);
@safe int getSpeed();
}
class PirateShip : Ship
{
private int speed = 0; // If only I had 'private(this)' !!
On Monday, 1 May 2023 at 03:53:24 UTC, Cecil Ward wrote:
On Wednesday, 26 April 2023 at 23:07:39 UTC, WhatMeWorry wrote:
[...]
Correction: I can’t count. There are only two instructions in
parallel with another pair running alongside, not three. The
first reg, reg move counts as zero
On Wednesday, 26 April 2023 at 23:07:39 UTC, WhatMeWorry wrote:
On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers
within the last 30 years should recognize all forms of
On 27/04/2023 11:07 AM, WhatMeWorry wrote:
On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers within the
last 30 years should recognize all forms of this and do the right
On Wed, Apr 26, 2023 at 11:07:39PM +, WhatMeWorry via Digitalmars-d-learn
wrote:
> On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
> > Don't forget ``num % 2 == 0``.
> >
> > None should matter, pretty much all production compilers within the
> > last
On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers within
the last 30 years should recognize all forms of this and do the
right thing.
Thanks. Fastest reply ever! And I
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers within the last
30 years should recognize all forms of this and do the right thing.
I just need an even/odd functionality. Don't think D has a
built-in operator.
// Found this C code online.
int isEven(int num)
{
return !(num & 1);
}
// found this in std.functional.unaryFun
alias isEven = unaryFun!("(a & 1) == 0");
assert(isEven(2) && !isEven(1));
If
On Friday, 13 January 2023 at 05:17:59 UTC, thebluepandabear
wrote:
(Sorry if this is a duplicate.)
If I have the following code inside of a module:
```D
class Obj {
private {
string name = "Hi";
}
}
class ObjDerived : Obj {
}
```
Is it best practice to define `ObjDerived`
(Sorry if this is a duplicate.)
If I have the following code inside of a module:
```D
class Obj {
private {
string name = "Hi";
}
}
class ObjDerived : Obj {
}
```
Is it best practice to define `ObjDerived` inside another module,
since `ObjDerived` can still access the
typeof(screen.output.findSplit("")) s;
Perfect. That was the "essence" of my question. But thanks to
Ali, I don't have to use such esoteric syntax. D is a wonderful
language, but I seem to shoot myself in the foot :)
On 10/25/22 6:07 PM, WhatMeWorry wrote:
I'm naturally getting a undefined identifier `s` error in the return.
Is there some way to refactor my code? I tried to declare s outside of
the else brackets like:
auto screen = executeShell(cmdLine);
auto s;
...
{
s =
On 10/25/22 15:07, WhatMeWorry wrote:
> auto screen = executeShell(cmdLine);
> auto s;
That can't work because there is no information to infer the type of
's'. Judging from the return type of getPath, perhaps it's string[]:
string[] s;
This is the question we should answer first
I'm naturally getting a undefined identifier `s` error in the
return. Is there some way to refactor my code? I tried to
declare s outside of the else brackets like:
auto screen = executeShell(cmdLine);
auto s;
...
{
s = screen.output.findSplit("REG_SZ");
}
but that doesn't compile
On Sunday, 23 October 2022 at 17:36:25 UTC, Paul Backus wrote:
On Sunday, 23 October 2022 at 13:32:44 UTC, matheus wrote:
...
You say your idea is "like passing some argument", so why not
actually pass an argument?
For example:
...
Hi, thanks for the example, and yes I'd like to do that,
On Sunday, 23 October 2022 at 16:16:55 UTC, Sergey wrote:
On Sunday, 23 October 2022 at 15:47:27 UTC, matheus wrote:
Hi H. S. Teoh,
I think you misunderstood my question, since English is not my
first language maybe this was a problem from my part, but
anyway, I'm not talking about "
On Sunday, 23 October 2022 at 13:32:44 UTC, matheus wrote:
I have a design question and I'd like to hear some advice.
Let's say that I want to create a method to sort an array:
arr.sort(asc);
I think usually this would usually return a new set of that
array but now sorted.
But If I
On Sunday, 23 October 2022 at 15:47:27 UTC, matheus wrote:
Hi H. S. Teoh,
I think you misunderstood my question, since English is not my
first language maybe this was a problem from my part, but
anyway, I'm not talking about "sort" from main library.
This example was if I had d
Hi H. S. Teoh,
I think you misunderstood my question, since English is not my
first language maybe this was a problem from my part, but anyway,
I'm not talking about "sort" from main library.
This example was if I had designed my "own version".
Matheus.
On Sun, Oct 23, 2022 at 01:32:44PM +, matheus via Digitalmars-d-learn wrote:
> Hi,
>
> I have a design question and I'd like to hear some advice. Let's say
> that I want to create a method to sort an array:
>
> arr.sort(asc);
>
> I think usually this would
Hi,
I have a design question and I'd like to hear some advice. Let's
say that I want to create a method to sort an array:
arr.sort(asc);
I think usually this would usually return a new set of that array
but now sorted.
But If I want to do this in the original, I think I would do
On 10/22/22 5:53 PM, WhatMeWorry wrote:
string[] tokens = userSID.output.split!isWhite;
writeln("tokens = ", tokens);
tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "",
On Saturday, 22 October 2022 at 21:53:05 UTC, WhatMeWorry wrote:
string[] tokens = userSID.output.split!isWhite;
writeln("tokens = ", tokens);
[...]
Is there a clever way that I can discard all the extra null
strings in the resultant string array?
Easiest way is to use [`filter`][1].
On Saturday, 22 October 2022 at 22:01:09 UTC, Enjoys Math wrote:
On Saturday, 22 October 2022 at 21:53:05 UTC, WhatMeWorry wrote:
string[] tokens = userSID.output.split!isWhite;
writeln("tokens = ", tokens);
tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "",
__MWE Code:__
```
module DlangForumsMWE;
import std.stdio;
import std.algorithm.mutation;
int main()
{
//string[] tokens = userSID.output.split!isWhite;
//writeln("tokens = ", tokens);
auto tokens = ["SID", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
On 10/22/22 14:53, WhatMeWorry wrote:
>
>
> string[] tokens = userSID.output.split!isWhite;
> writeln("tokens = ", tokens);
Could you please show minimal compilable code that demonstrates the
issue. I spent some time with some guesses but failed (to get my code to
compile with
On Saturday, 22 October 2022 at 21:53:05 UTC, WhatMeWorry wrote:
string[] tokens = userSID.output.split!isWhite;
writeln("tokens = ", tokens);
tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "",
string[] tokens = userSID.output.split!isWhite;
writeln("tokens = ", tokens);
tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "",
On 10/14/22 01:43, WhatMeWorry via Digitalmars-d-learn wrote:
Does D provide any guidance as to what is preferred or are they identical for
all intents and purposes?
You won't see a difference for this specific example since the split function
supports character, string and even range
Changing the order of lines...
On 10/13/22 16:43, WhatMeWorry wrote:
> return s.split(';'); // single quotes
That one is a single character and very lightweigth because it's just an
integral value. You can't put more than one character within single quotes:
';x' // ERROR
> return
I was a little (nicely) surprised that I could use double quotes,
single quotes, or back ticks in the following line of code.
return s.split(";"); // double quotes
or
return s.split(';'); // single quotes
or
return s.split(`;`); // back ticks
Does D provide any guidance as to what is
On Tuesday, 17 May 2022 at 00:10:55 UTC, Alain De Vos wrote:
Let's say a shape is ,a circle with a radius ,or a square with
a rectangular size.
I want to pass shapes to functions, eg to draw them on the
screen,
draw(myshape) or myshape.draw();
But how do i implement best shapes ?
You could
On Tuesday, 17 May 2022 at 09:30:12 UTC, forkit wrote:
On Tuesday, 17 May 2022 at 04:37:58 UTC, Ali Çehreli wrote:
In you OOP example, I am curious why you chose Shape to be an
interface, rather than a base class.
You can inherit from multiple interfaces, but only from one base
class.
So
On 5/17/22 02:30, forkit wrote:
> On Tuesday, 17 May 2022 at 04:37:58 UTC, Ali Çehreli wrote:
>>
>
> In you OOP example, I am curious why you chose Shape to be an interface,
> rather than a base class.
I always have the same question. :) interface feels lighterweight, so i
On Tuesday, 17 May 2022 at 04:37:58 UTC, Ali Çehreli wrote:
In you OOP example, I am curious why you chose Shape to be an
interface, rather than a base class.
On Tuesday, 17 May 2022 at 05:08:30 UTC, matheus wrote:
In D there would be a better way to do such thing?
Nothing really specific to D, but for one or two properties, you
might just add them as function parameters with default values:
```d
void draw(float scale = 1.0f);
```
If you have
On Tuesday, 17 May 2022 at 00:10:55 UTC, Alain De Vos wrote:
Let's say a shape is ,a circle with a radius ,or a square with
a rectangular size.
I want to pass shapes to functions, eg to draw them on the
screen,
draw(myshape) or myshape.draw();
But how do i implement best shapes ?
In addition
On 5/16/22 22:08, matheus wrote:
> interface Shape {
>void draw();
>void draw(float scale);
> }
Interfaces can have 'final' functions:
interface Shape {
void draw(float scale);
final void draw() {
draw(1);
}
}
Obviously, for that to work, now Circle.draw() etc. required to
but I have a question, in your second
example, let's say that sometimes it would be required to "draw"
with some scale factor, so (As a newbie) I would do something
like this:
interface Shape {
void draw();
void draw(float scale);
}
Then in Circle class:
void draw(float scale) {
On 5/16/22 17:10, Alain De Vos wrote:
Let's say a shape is ,a circle with a radius ,or a square with a
rectangular size.
I want to pass shapes to functions, eg to draw them on the screen,
draw(myshape) or myshape.draw();
But how do i implement best shapes ?
There are many ways of achieving
Let's say a shape is ,a circle with a radius ,or a square with a
rectangular size.
I want to pass shapes to functions, eg to draw them on the screen,
draw(myshape) or myshape.draw();
But how do i implement best shapes ?
On Tue, Apr 19, 2022 at 05:01:15PM +, Era Scarecrow via Digitalmars-d-learn
wrote:
[...]
> In linux using zram i've allocated and made a compressed drive of 8Gb
> which took only 200k of space [...] All unallocated pages are assumed
> null/zero filled, and if you zeroize a block it will
On Saturday, 16 April 2022 at 20:48:15 UTC, Adam Ruppe wrote:
On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote:
Is virtual memory entering into the equation?
Probably. Memory allocated doesn't physically exist until
written to a lot of the time.
This might be very much an OS
On Tue, Apr 19, 2022 at 12:54:06PM +, bauss via Digitalmars-d-learn wrote:
> On Saturday, 16 April 2022 at 20:48:15 UTC, Adam Ruppe wrote:
> > On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote:
> > > Is virtual memory entering into the equation?
> >
> > Probably. Memory allocated
On Saturday, 16 April 2022 at 20:48:15 UTC, Adam Ruppe wrote:
On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote:
Is virtual memory entering into the equation?
Probably. Memory allocated doesn't physically exist until
written to a lot of the time.
You can also exceed your RAM in
On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote:
Is virtual memory entering into the equation?
Probably. Memory allocated doesn't physically exist until written
to a lot of the time.
I'm playing around with dynamic arrays and I wrote the tiny
program (at bottom). I get the following output:
PS C:\D\sandbox> dmd -m64 maxMem.d
PS C:\D\sandbox> .\maxMem.exe
Reserving 1,610,613,245 elements
reserve() returned a size of: 1,610,613,245
The capacity() of big is 1,610,613,245
On Wednesday, 23 March 2022 at 00:51:42 UTC, Era Scarecrow wrote:
On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote:
We already have this:
import std.conv : to;
int x;
long y;
y = x.to!long; // equivalent to straight assignment / cast
x =
On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote:
On Tue, Mar 22, 2022 at 09:11 PM, Era Scarecrow wrote:
[...]
I'd almost wish D had a more lenient mode and would do
automatic down-casting, then complain if it *would* have
failed to downcast data at runtime.
[...]
We already
On Tue, Mar 22, 2022 at 09:11:00PM +, Era Scarecrow via Digitalmars-d-learn
wrote:
[...]
> I'd almost wish D had a more lenient mode and would do automatic
> down-casting, then complain if it *would* have failed to downcast data
> at runtime.
[...]
We already have this:
import
ned as the
default?
This question is probably going off topic but still be
interesting to know if there's an answer.
> Is it better to use int, long, size_t?
D uses size_t for automatic indexes during foreach, and as I
said, it makes sense to me.
Otherwise, I think the go-to type should be int for
On 3/22/22 11:28, Era Scarecrow wrote:
> So when should you use size_t?
I use size_t for anything that is related to count, index, etc. However,
this is a contested topic because size_t is unsigned. As soon as you use
it in an expression, the whole expression becomes unsigned as well.
() so that we
can seek() to an earlier place and ulong for tell().
Perhaps we should back up and ask a different question. I've
been working on adaptation of Reed Solomon Codes, and i keep
getting thrown with casting errors, to the point where i just
want to make everything size_t to make
On 3/18/22 7:01 PM, Ali Çehreli wrote:
On 3/18/22 14:54, WhatMeWorry wrote:
> size_t huge = uint.max; // compiles
That means size_t is uint on that build.
Not that Ali is wrong in the full sense, but this line alone will
compile on both 64 and 32-bit systems, so it is not informative.
On 3/18/22 14:54, WhatMeWorry wrote:
> size_t is an alias to one of the unsigned integral basic types, and
> represents a type that is large enough to represent an offset into all
> addressable memory.
In practice, that general description means "size_t is either ulong or
uint" depending on
On Friday, 18 March 2022 at 21:54:55 UTC, WhatMeWorry wrote:
Isn't ulong an integer? And isn't memory addresses 64 bits long?
Only if you are doing a 64 bit build. Try using -m64
Quoting the D documentation:
size_t is an alias to one of the unsigned integral basic types,
and represents a type that is large enough to represent an offset
into all addressable memory. And I have a line of code:
size_t huge = ulong.max;
dmd GC.d
GC.d(29): Error: cannot implicitly
to type qualifiers before the function
> definitions "this" (like a return type?) and the output was exactly
> identical. So I guess my question is, is this just a matter of
> esthetics or is some more nuanced goal at work here?
In method declarations, modifiers like const/imm
eturn type?) and the output was exactly identical. So
I guess my question is, is this just a matter of esthetics or is some
more nuanced goal at work here?
For constructors, being on the front is not misleading. But for a member
function that returns a value, take a look:
```d
struct S
{
int * x;
On Thursday, 27 January 2022 at 17:42:09 UTC, WhatMeWorry wrote:
So I guess my question is, is this just a matter of esthetics
or is some more nuanced goal at work here?
It doesn't matter much for constructors, but in general, the
problem with placing qualifiers in front is that it looks
s were placed after the function parameter list
(int i). Just for fun, I moved to type qualifiers before the
function definitions "this" (like a return type?) and the output
was exactly identical. So I guess my question is, is this just
a matter of esthetics or is some more nuanced goal at work here?
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote:
On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov
wrote:
The difference is in how arguments are being passed, which you
seem to have discovered already :)
Would like to know where the linkage format is defined, thx.
It
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote:
It claims that the D calling convention matches C. But it seems
that the arguments are pushed in order whereas C does it in
reverse order and the -218697648 value is indeed my 3rd string
pointer.
Windows has two calling conventions for
On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov
wrote:
The difference is in how arguments are being passed, which you
seem to have discovered already :)
Would like to know where the linkage format is defined, thx.
It should be here: https://dlang.org/spec/abi.html although
On Monday, 24 January 2022 at 17:23:01 UTC, frame wrote:
I understand that the linkage must match but besides the name
mangling, what's happen here? What is the difference if I
remove the `extern (C)` part from the T alias?
The difference is in how arguments are being passed, which you
seem
If I declare a function as extern(C) inside a DLL, I have also to
cast the function pointer as extern(C) or it fails calling, eg.
```d
// --- my.dll
export extern (C) void log(int mode, string a, string b, string
c) {
/* stuff */
}
// --- main.d
alias T = extern (C) void function(int,
On Sunday, 23 January 2022 at 09:38:57 UTC, Siarhei Siamashka
wrote:
On Sunday, 23 January 2022 at 09:08:46 UTC, Stanislav Blinov
wrote:
Using `iota` here incurs additional computation and argument
copies that are actually never used, i.e. wasted work. So I'd
say go with `generate`, as that
On Sunday, 23 January 2022 at 09:08:46 UTC, Stanislav Blinov
wrote:
Using `iota` here incurs additional computation and argument
copies that are actually never used, i.e. wasted work. So I'd
say go with `generate`, as that seems the intent.
Isn't this normally a compiler's job to eliminate
On Saturday, 22 January 2022 at 23:54:27 UTC, forkit wrote:
On Saturday, 22 January 2022 at 19:55:43 UTC, Stanislav Blinov
wrote:
thanks for the explanation. That really helped :-)
writeln( generate!(() => dice(0.6, 1.4)).take(howManyTimes) );
[1, 1, 1, 1, 0]
(or after reading Ali's
On Saturday, 22 January 2022 at 19:55:43 UTC, Stanislav Blinov
wrote:
thanks for the explanation. That really helped :-)
writeln( generate!(() => dice(0.6, 1.4)).take(howManyTimes) );
[1, 1, 1, 1, 0]
(or after reading Ali's response - getting rid of rnd, and using
_ )
writeln(
On 1/22/22 11:32, forkit wrote:
> trying to make sense of the below:
The generate() solution shown by Stanislav Blinov is suitable here.
> auto rnd = Random(unpredictableSeed);
Somebody else mentioned this before but none of the programs we've seen
so far seemed to need a special random
same as above line?
//writeln(howManyTimes.iota.map!(5 => rnd.dice(0.6,
1.4)).format!"%(%s,%)");
}
// ---
No, it's not the same. 'Tis not really a "map question", looks
more like a question about
https://dlang.org/spec/expression.html#function_literals (see
#10).
trying to make sense of the below:
// ---
module test;
import std;
void main()
{
auto rnd = Random(unpredictableSeed);
int howManyTimes = 5;
// ok - using 'e =>' makes sense
writeln(howManyTimes.iota.map!(e => rnd.dice(0.6,
1.4)).format!"%(%s,%)");
// ok - though
On Friday, 21 January 2022 at 02:10:34 UTC, Steven Schveighoffer
wrote:
thanks Steven (and Ali too).
On 1/20/22 18:07, forkit wrote:
I have a line of code, that I do NOT want executed when -debug is passed
in.
enforce(!exists(fname), "Oop! That file already exists!");
Is this even possible? (with using -version ..)
The following should do it:
debug {} else {
foo();
}
Ali
On 1/20/22 9:07 PM, forkit wrote:
I have a line of code, that I do NOT want executed when -debug is passed
in.
enforce(!exists(fname), "Oop! That file already exists!");
Is this even possible? (with using -version ..)
`debug` is like a `version` block.
```d
debug {} else {
// code that
1 - 100 of 1857 matches
Mail list logo