On Wednesday, 30 March 2022 at 12:46:07 UTC, Vijay Nayar wrote:
Consider the following code example:
```d
import std.stdio;
void main()
{
alias DelegateT = string delegate();
// An array of delegates, each has their own scope.
DelegateT[] funcs;
foreach (i; ["ham", "cheese"]) {
//
On Sunday, 3 April 2022 at 08:37:45 UTC, user1234 wrote:
On Saturday, 2 April 2022 at 21:57:02 UTC, Marcone wrote:
Where I download Digital Mars C Preprocessor sppn.exe? I need
it to use ImportC
it's part of the [DMC] toolchain.
[DMC]:
http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c
On Wednesday, 6 April 2022 at 10:36:04 UTC, francesco.andreetto
wrote:
I have two structs, point and vec, in which I want to implement
some arithmetic operations.
The operations are:
```
point - point = vec
point + vec = point
```
Using mixin templates the code compiles but calling the
operat
On Thursday, 7 April 2022 at 10:50:35 UTC, BoQsc wrote:
Here I try to concatenate three character strings using
`wcsncat()`.
[...]
Maybe try using `wstring` instead of string? Also use the `w`
postfix
```d
wstring dlang_string = "BBB"w;
I can't test because I'm not on my PC and I
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
Dub(DMD 2.099.1) builds and runs the following code without a
warning.
import std.stdio;
import core.stdc.stdlib;
@live
void test()
{
int* p = cast(int*) malloc(32);
p = cast(int*) malloc(32);
On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer
wrote:
On 4/28/22 10:48 PM, Salih Dincer wrote:
[...]
There is no string interpolation in D. You can use a function
such as `std.conv.text` to produce a string given interleaving
strings and items. Or you can use `std.format.form
On Friday, 29 April 2022 at 16:10:52 UTC, Salih Dincer wrote:
On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer
wrote:
[...]
I see, think it can be done with mixin:
```d
template prn(alias args)
{
string prn()
{
string result = "write(";
foreach(s; args.split("|"))
On Saturday, 30 April 2022 at 09:25:18 UTC, Dukc wrote:
On Sunday, 24 April 2022 at 21:00:50 UTC, Alain De Vod wrote:
[...]
A few picks.
1: You do not need to import `destroy`. Everything in `object`
is automatically imported.
[...]
Hell, just using `scope int[] i` should be enough to tr
On Saturday, 30 April 2022 at 14:29:56 UTC, notsteve wrote:
Hi,
I am trying to setup a simple webserver in D using vibe.d
(0.9.4) and want to use mongoDB as a database. To achieve this,
I've set up a mongoDB atlas instance with the following command
inside the standard app.d file created by v
On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote:
module test;
struct MatrixImpl(S, size_t M, size_t N)
{
}
[...]
AFAICT, I'm afraid you'll have to stick to `dot2` 🙁
This DIP I believe does what you want but... It wasn't looked
upon favorably...
https://github.com/dl
On Monday, 2 May 2022 at 22:01:51 UTC, ag0aep6g wrote:
On 02.05.22 22:47, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote:
On 02.05.22 21:17, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:
[...]
```d
template MyAlias(T){
al
On Tuesday, 3 May 2022 at 00:38:34 UTC, Tejas wrote:
On Monday, 2 May 2022 at 22:01:51 UTC, ag0aep6g wrote:
On 02.05.22 22:47, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote:
On 02.05.22 21:17, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 16:29:05 UTC, Loara
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote:
Error: array literal in @nogc function test.myfun may cause a
GC allocation
@nogc void myfun(){
scope int[] i=[1,2,3];
}//myfun
May is a fuzzy word...
For this particular piece of code, you can use a static array to
guarant
On Friday, 6 May 2022 at 08:25:34 UTC, Siarhei Siamashka wrote:
On Friday, 6 May 2022 at 07:05:35 UTC, zjh wrote:
For example, I think `d` can also make use of `'winrt'`, which
is very important for `GUI` programming . `D` officials should
pay attention to `it`.
I have downloaded `dwinrt` and
On Sunday, 8 May 2022 at 01:38:55 UTC, jmh530 wrote:
On Saturday, 7 May 2022 at 23:30:37 UTC, Paul Backus wrote:
[snip]
Worth noting that you *can* write
```d
alias foo = partial!(foo, a);
```
...which will add the partially-applied version to `foo`'s
overload set.
You sure about that? Bel
On Saturday, 7 May 2022 at 18:36:40 UTC, jmh530 wrote:
In the code below, there is a two parameter function `foo` and
an override of it with only one parameter. In the override
case, I force the second one to be 1, but ideally there should
be a way to specify it at compile-time.
It would be k
On Tuesday, 10 May 2022 at 01:00:24 UTC, frame wrote:
So `__traits(getOverloads)` returns also templated members and
`__traits(isTemplate)` can select those members. Unfortunately,
`Parameters!` does not work with the templated member. How can
I pass a symbol of T or A... to `Parameters!` as de
On Tuesday, 10 May 2022 at 11:33:24 UTC, frame wrote:
On Tuesday, 10 May 2022 at 11:26:44 UTC, frame wrote:
On Tuesday, 10 May 2022 at 03:18:14 UTC, Tejas wrote:
Can you try
Makes no difference.
OK, I tried it in separate test and works. Weird, I already
tried that before, there must be s
On Wednesday, 11 May 2022 at 14:20:07 UTC, H. S. Teoh wrote:
On Wed, May 11, 2022 at 01:37:21PM +, matheus via
Digitalmars-d-learn wrote:
> [...]
[...]
[...]
[...]
My suggestion is: when prototyping, don't even think about
attributes. Just templatize your functions and let the compiler
On Thursday, 12 May 2022 at 15:18:34 UTC, jmh530 wrote:
On Thursday, 12 May 2022 at 12:13:32 UTC, Basile B. wrote:
[snip]
```
is ( Type : TypeSpecialization , TemplateParameterList )
is ( Type == TypeSpecialization , TemplateParameterList )
is ( Type Identifier : TypeSpecialization ,
TemplatePa
On Friday, 13 May 2022 at 04:19:26 UTC, Ola Fosheim Grøstad wrote:
On Friday, 13 May 2022 at 03:31:53 UTC, Ali Çehreli wrote:
On 5/12/22 18:56, forkit wrote:
> So...you want to do a talk that challenges D's complexity, by
getting
> back to basics?
I wasn't thinking about challenging complexity
On Friday, 13 May 2022 at 03:31:53 UTC, Ali Çehreli wrote:
On 5/12/22 18:56, forkit wrote:
> So...you want to do a talk that challenges D's complexity, by
getting
> back to basics?
I wasn't thinking about challenging complexity but it gives me
ideas.
I am looking for concrete topics like tem
On Sunday, 15 May 2022 at 21:33:24 UTC, Ali Çehreli wrote:
D programmers don't write move constructors or move assignment.
Such concepts don't even exist.
Never say never :
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1040.md
Walter is one of the authors of the DIP
Also, there's `op
On Tuesday, 17 May 2022 at 09:38:31 UTC, Sergey wrote:
On Monday, 16 May 2022 at 17:32:20 UTC, Allen Garvey wrote:
I'm working on a comparison of WebAssembly performance for
error propagation dithering using D, C++ and Zig. So far C++
and Zig work as expected, but for D, despite using the same
On Wednesday, 18 May 2022 at 01:04:16 UTC, Alain De Vos wrote:
I tried neovim editor & serve-d and failed.
I tried kate editor & serve-d and failed.
https://github.com/Pure-D/serve-d
Anyone has a clue ?
I'm using [lunarvim](https://github.com/LunarVim/LunarVim). It
provides you the ability t
On Wednesday, 18 May 2022 at 21:52:18 UTC, HuskyNator wrote:
On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote:
After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get
this behavior.
Only when I use `dub run --b=debug` however (default for me).
`dub run --b=release` does return wh
On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote:
I need to write a piece of software to track and categorize
some purchases. It's the kind of thing I could probably write
in a couple of hours in C#/Java + html/css/javascript. However,
something keeps drawing me to D and as this is a simpl
On Tuesday, 24 May 2022 at 02:29:38 UTC, cc wrote:
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
[...]
FWIW your code will compile if you add `extern(C++)` to `Foo`
On Friday, 27 May 2022 at 08:39:08 UTC, vit wrote:
Hello, I have this problem:
```d
static int i;
void bar(T)(){
static if(is(T == int))
(()@system => 1)();
static if(is(T == float))
i = 42;
}
void foo(T)(){
bar!T();
}
void main()@safe pure{
foo!lon
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 working successfully for dmd and ldc?
The only bug I know of
On Tuesday, 31 May 2022 at 08:51:45 UTC, realhet wrote:
Hi,
In my framework I just found a dozen of compile time error
handling like:
...else static assert("Invalid type");
This compiles without error. And it was useless for detecting
errors because I forgot the first "false" or "0" paramet
On Thursday, 2 June 2022 at 01:49:32 UTC, Ruby The Roobster wrote:
On Thursday, 2 June 2022 at 01:29:39 UTC, Ruby The Roobster
wrote:
On Thursday, 2 June 2022 at 01:00:57 UTC, Ali Çehreli wrote:
On 6/1/22 17:36, Ruby The Roobster wrote:
> A stripped down version of some code I have:
Not much e
On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote:
how to work this around.
```d
__gshared const TEST = import(`onlineapp.d`);
extern(C) void main(){
__gshared bin_ptr = TEST.ptr;
}
```
```sh
dmd2 -betterC -J. onlineapp.d
onlineapp.d(3): Error: cannot use non-constant CTFE point
On Saturday, 11 June 2022 at 11:51:43 UTC, Tejas wrote:
On Saturday, 11 June 2022 at 10:07:46 UTC, test123 wrote:
how to work this around.
```d
__gshared const TEST = import(`onlineapp.d`);
extern(C) void main(){
__gshared bin_ptr = TEST.ptr;
}
```
```sh
dmd2 -betterC -J. onlineapp.d
On Sunday, 12 June 2022 at 05:05:46 UTC, forkit wrote:
Is it possible to create a package.d, consisting of (for
example), two modules, where each module can access private
declarations within each other.
In essence, declaring 'a module level friendship', or a kind of
'extended module' if you
On Friday, 17 June 2022 at 01:04:28 UTC, Paul Backus wrote:
Nope. The way UFCS works is that allows you to call free
functions using member-function syntax, and member-function
syntax is always `object.memberName`, so UFCS only works for
functions that have a name, not anonymous functions.
On Tuesday, 21 June 2022 at 17:09:28 UTC, JG wrote:
Suppose we are often writing something like
```d
theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex]=x;
```
One would like to something like
```d
alias shortName =
theFirstName[theFirstIndex].theSecondName[theSeco
On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:
Hi,
I know with PyD, D can call Python, and with autowrap, Python
can call a D .dll, I'm just wondering if someone can show an
example that Python <==> d can call both ways? esp. show
passing D objects to Python and then call its member fu
On Wednesday, 10 August 2022 at 14:11:04 UTC, Ruby The Roobster
wrote:
On Saturday, 6 August 2022 at 13:20:19 UTC, Sergey wrote:
On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster
wrote:
Is there any implementation in phobos of something similar to
BigInt but for non-integers as well
On Friday, 19 August 2022 at 16:36:24 UTC, MyNameHere wrote:
On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote:
Oh and `DevicePath()` is a convenience member returning a
pointer to the 'dynamic array' (as the array decays to a
pointer in C too), so no need to fiddle with `.offsetof` and
c
On Friday, 2 September 2022 at 18:39:27 UTC, rikki cattermole
wrote:
I think you are wanting opAssign not opBinary.
Also you made a mistake, since its a struct you don't want to
new it when you construct and return it.
```d
return new Time(secos / 3600, (secos % 3600) / 60, secos % 60);
```
On Tuesday, 13 September 2022 at 03:13:59 UTC, Daniel Donnell, Jr
wrote:
On Sunday, 11 September 2022 at 02:14:51 UTC, zjh wrote:
On Saturday, 10 September 2022 at 22:07:32 UTC, Ali Çehreli
wrote:
On 9/10/22 13:04, Daniel Donnell wrote:
> https://dlang.org/spec/cpp_interface.html
At DConf, Man
On Saturday, 24 September 2022 at 23:04:00 UTC, rassoc wrote:
On 9/24/22 15:28, Adam D Ruppe via Digitalmars-d-learn wrote:
gdb --args ./your_program
and then it will tell you all the details you want to know
about when this happens.
Thank you for your input, Adam. Real shame that there's n
On Friday, 21 October 2022 at 22:03:53 UTC, Kevin Bailey wrote:
I'm trying to do this equivalent C++:
unordered_map map;
for (auto i = map.find(something); i != map.end(); ++i)
...do something with i...
in D, but obviously with an associative array. It seems that
it's quite
ea
On Tuesday, 1 November 2022 at 15:49:54 UTC, Keivan Shah wrote:
On Tuesday, 1 November 2022 at 15:42:43 UTC, Imperatorn wrote:
On Tuesday, 1 November 2022 at 15:40:04 UTC, Keivan Shah wrote:
Hello,
Today I came across a strange bug while using D with `dmd`. I
have still not been able to figur
On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin
wrote:
Dear dlang-folk,
one of the tools I always return to is rake
(https://ruby.github.io/rake/). For those that do not know it,
its a little like make in the
sense that you describe your build as a graph of tasks with
dependenc
On Thursday, 3 November 2022 at 04:41:14 UTC, Siarhei Siamashka
wrote:
C++ code:
```C++
#include
class A {
public:
void foo() { std::cout << "foo" << std::endl; }
};
int main() {
auto a1 = new A;
a1->foo(); // prints "foo"
A a2;
a2.foo(); // prints "foo"
delete a1;
}
```
D code:
```
On Thursday, 3 November 2022 at 15:40:02 UTC, H. S. Teoh wrote:
On Thu, Nov 03, 2022 at 04:41:14AM +, Siarhei Siamashka via
Digitalmars-d-learn wrote: [...]
```D
@safe:
import std.stdio;
class A {
void foo() { writeln("foo"); }
}
void main() {
auto a1 = new A;
a1.foo(); // prints "foo"
On Tuesday, 8 November 2022 at 00:05:18 UTC, vushu wrote:
Any where to find learning material for using dmd as a library?
thanks.
https://github.com/Superbelko/dmdlib-notes
This is the only resource I know of
On Sunday, 13 November 2022 at 18:51:09 UTC, Siarhei Siamashka
wrote:
On Saturday, 12 November 2022 at 14:07:46 UTC, Per Nordlöw
wrote:
Have anybody created a wrapper container
```d
struct Sorted(ArrayLike, alias lessThanPred)
```
that wraps an array-like type `ArrayLike` so that it's always
On Wednesday, 23 November 2022 at 11:06:12 UTC, []() {}() wrote:
On Wednesday, 23 November 2022 at 09:51:46 UTC, FeepingCreature
wrote:
Why then should a programming language insist that all other
code in the module should be able to bypass my specification,
and do as it pleases to my type?
On Friday, 25 November 2022 at 17:45:57 UTC, Paul Backus wrote:
On Friday, 25 November 2022 at 14:07:28 UTC, ShadoLight wrote:
On Saturday, 19 November 2022 at 15:00:16 UTC, Paul Backus
wrote:
Since, in your example, `lf` has global lifetime, the
compiler deduces that `lf.fp` also has global li
On Sunday, 27 November 2022 at 17:06:31 UTC, vushu wrote:
On Saturday, 16 May 2020 at 17:45:56 UTC, Konstantin wrote:
[...]
I'm actually also very curious about this issue, since I come
from c++ where this is possible, and it is a very common
functionality for example for dependency inversio
On Tuesday, 27 December 2022 at 15:09:11 UTC, Sergei Nosov wrote:
Consider, I have the following code:
```
auto a = [3, 6, 2, 1, 5, 4, 0];
auto indicies = iota(3);
auto ai = indexed(a, indicies);
ai = indexed(ai, iota(2));
writeln(ai);
```
Basically, my idea is to apply `i
On Thursday, 5 January 2023 at 09:10:00 UTC, areYouSureAboutThat
wrote:
I was playing around with betterC, when I discovered, that if i
accidently forget to provide -betterC to the compiler, it will
still compile this, but, there will be no runtime bounds
checking occuring.
My question is: wh
On Thursday, 5 January 2023 at 11:55:33 UTC, thebluepandabear
wrote:
I am using CSFML D bindings and I have created my own sort of
UI library for drawing elements onto the screen.
One of the classes I've created is a `Button` class, which
contains a delegate called `onButtonClick` which is cal
On Thursday, 5 January 2023 at 22:49:01 UTC, thebluepandabear
wrote:
Have fun reading this :
https://issues.dlang.org/show_bug.cgi?id=21929
Thanks for the code suggestion although it still doesn't fix
the bug. I am curious as to what those brackets do as well.
Okay, my bad for writing the w
Sorry, I'm rather ignorant when it comes to this, but why can't
we use [pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D? Then we won't need a nogc compatible std
library and so many other things could get easier, like getting
legacy code to use Dlang. It might not b
On Thursday, 10 June 2021 at 16:50:41 UTC, evilrat wrote:
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
Sorry, I'm rather ignorant when it comes to this, but why
can't we use
[pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D? Then we won't need a nogc comp
On Thursday, 10 June 2021 at 16:49:59 UTC, Dukc wrote:
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
Sorry, I'm rather ignorant when it comes to this, but why
can't we use
[pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D? Then we won't need a nogc compati
On Wednesday, 16 June 2021 at 05:48:21 UTC, VitaliiY wrote:
On Tuesday, 15 June 2021 at 12:39:40 UTC, Dennis wrote:
On Tuesday, 15 June 2021 at 12:18:26 UTC, VitaliiY wrote:
[...]
```D
enum string ADDBITS(string a, string b) = `
{
bitbuffer = (bitbuffer<<(`~a~`))|((`~b~`)&((1<<`~a~`)-1));
On Wednesday, 23 June 2021 at 15:31:04 UTC, vit wrote:
Hello,
I am implementing @nogc string struct similar to c++
std::basic_string (link
https://code.dlang.org/packages/basic_string).
C++ string has methods front, back and pop_back
returning/deleting code units.
D strings has functions (s
On Tuesday, 6 July 2021 at 10:06:11 UTC, Jack Applegame wrote:
Here's another way using ``` std.typecons ```
```d
import std.stdio;
import std.typecons;
alias input = Typedef!int; //new code
struct Field {
void opAssign(int a) {
writefln("Field.opAssign(%s)", a);
}
}
struct R
On Wednesday, 7 July 2021 at 19:14:52 UTC, Kevin Bailey wrote:
I'm trying to use some fairly simple template argument
deduction, but
maybe I'm not getting the syntax correct. C++ doesn't event
blink at
something like this, but D is giving me:
temptest.d(18): Error: template temptest.func canno
Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { &Employee::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;
```
What is the equivalent D code?
Ditto for pointer to class instances:
```
int (Employee
On Thursday, 8 July 2021 at 11:53:42 UTC, Tejas wrote:
Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { &Employee::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;
```
What is the equivalent D code?
On Thursday, 8 July 2021 at 12:04:01 UTC, Paul Backus wrote:
https://digitalmars.com/articles/b68.html
Thank you very much :D
On Wednesday, 14 July 2021 at 10:07:38 UTC, wjoe wrote:
I'm want to do something like this
```D
part_int_t!(1,2,3) i;
auto x = -i[0];
--i[1]; // 1
i[1]++; // 2
```
I think the operator I need to overload would be opIndexUnary
which I did.
(1) compiles.
(2) doesn't - the compiler complains tha
On Wednesday, 14 July 2021 at 12:35:07 UTC, wjoe wrote:
On Wednesday, 14 July 2021 at 11:31:36 UTC, Tejas wrote:
``` {auto a = i[1] , ++i[1] , a} //note the , not the ;```
Sorry I can't provide something even more concrete.
Yes I saw that, and I suppose it would work just fine if it
were re
On Wednesday, 14 July 2021 at 11:31:36 UTC, Tejas wrote:
On Wednesday, 14 July 2021 at 10:07:38 UTC, wjoe wrote:
I'm want to do something like this
```D
part_int_t!(1,2,3) i;
auto x = -i[0];
--i[1]; // 1
i[1]++; // 2
```
I think the operator I need to overload would be opIndexUnary
which I di
On Wednesday, 14 July 2021 at 13:09:56 UTC, vit wrote:
On Wednesday, 14 July 2021 at 12:49:58 UTC, Tejas wrote:
On Wednesday, 14 July 2021 at 12:35:07 UTC, wjoe wrote:
On Wednesday, 14 July 2021 at 11:31:36 UTC, Tejas wrote:
``` {auto a = i[1] , ++i[1] , a} //note the , not the ;```
Sorry I
On Wednesday, 14 July 2021 at 14:39:03 UTC, vit wrote:
On Wednesday, 14 July 2021 at 13:16:49 UTC, Tejas wrote:
On Wednesday, 14 July 2021 at 13:09:56 UTC, vit wrote:
On Wednesday, 14 July 2021 at 12:49:58 UTC, Tejas wrote:
[...]
From doc: https://dlang.org/spec/operatoroverloading.html
Post
On Wednesday, 14 July 2021 at 15:23:05 UTC, vit wrote:
On Wednesday, 14 July 2021 at 15:19:03 UTC, vit wrote:
```d
import std.stdio;
struct abc{
int[100] a;
struct Proxy{
abc* ptr;
const int index;
int opUnary(string op : "++")(){
return ++pt
On Wednesday, 14 July 2021 at 15:23:05 UTC, vit wrote:
On Wednesday, 14 July 2021 at 15:19:03 UTC, vit wrote:
```d
import std.stdio;
struct abc{
int[100] a;
struct Proxy{
abc* ptr;
const int index;
int opUnary(string op : "++")(){
return ++pt
On Wednesday, 14 July 2021 at 15:08:56 UTC, wjoe wrote:
On Wednesday, 14 July 2021 at 14:50:01 UTC, Mike Parker wrote:
On Wednesday, 14 July 2021 at 12:35:07 UTC, wjoe wrote:
[...]
It's how the contract of post-inc/dec work---pre-inc/dec
return the modified value, post-inc/dec return the ori
On Wednesday, 14 July 2021 at 17:42:03 UTC, Ali Çehreli wrote:
On 7/14/21 9:13 AM, Tejas wrote:
> ref/*notice this ref*/ int opIndex(int
index)return/*NOTICE THE
> RETURN*/ {
Indeed... I cover that 'ref' here:
http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.r
On Wednesday, 14 July 2021 at 17:52:16 UTC, sclytrack wrote:
Would reference counted classes by default be too much of a
change? Is it a bad idea? Currently there a changes in the
language where you can avoid the reference count, right?
This isn't happening until DIP 1000 passes successfully(w
On Wednesday, 14 July 2021 at 18:04:59 UTC, IGotD- wrote:
On Wednesday, 14 July 2021 at 17:52:16 UTC, sclytrack wrote:
Would reference counted classes by default be too much of a
change? Is it a bad idea? Currently there a changes in the
language where you can avoid the reference count, right?
On Wednesday, 14 July 2021 at 20:55:32 UTC, wjoe wrote:
On Wednesday, 14 July 2021 at 16:13:35 UTC, Tejas wrote:
[...]
Congratulations:) Unfortunately I haven't got anything I could
return by ref so I can't take advantage of a low hanging fruit.
In my book overloading operators is no fun - at
On Wednesday, 14 July 2021 at 20:55:32 UTC, wjoe wrote:
In my particular case the compiler can rule out ```opIndex```
so why does it abort instead of trying ```opIndexUnary``` ? Or
was it trying and it didn't work ? If that's the case I'd like
to know the reason why it discarded ```opIndexUnar
On Thursday, 15 July 2021 at 11:02:17 UTC, wjoe wrote:
On Thursday, 15 July 2021 at 04:07:49 UTC, Tejas wrote:
Your code
```d
auto x = i[1]++;
```
Expands to:
```d
auto x = (auto e = i[1]/*notice opIndex*/, ++i[1]/* notice
opIndexUnary*/, return e;);
```
This doesn't happen with pre increment
On Thursday, 15 July 2021 at 13:28:19 UTC, wjoe wrote:
On Thursday, 15 July 2021 at 12:09:20 UTC, Tejas wrote:
[...]
The only way, for me, to explain the error message ```opIndex
isn't an lvalue and can't be modified.``` for ```i[1]++``` is
that the compiler rewrites to
```D
(auto e = i.opI
I can do it like this in C++:
```
template
class def
{
friend typename abc;
}
```
I am just hopelessly confused on how to achieve the same in D.
On Thursday, 15 July 2021 at 17:26:41 UTC, Adam D Ruppe wrote:
On Thursday, 15 July 2021 at 17:21:45 UTC, Tejas wrote:
I can do it like this in C++:
You don't just put class def and class abc in the same module
and you get the same effect though.
I really should've just posted the whole thi
If, however, you're trying to inject friend access to something
outside def's module, then you might want to reconsider what
you're trying to accomplish and whether it can be done
differently.
Was just dreaming of how to transpile C++ code to D :(
Curiously enough, friend injection w
On Thursday, 15 July 2021 at 17:30:05 UTC, jfondren wrote:
On Thursday, 15 July 2021 at 17:21:45 UTC, Tejas wrote:
I can do it like this in C++:
```
template
class def
{
friend typename abc;
}
```
I am just hopelessly confused on how to achieve the same in D.
Uncharitably: D is a friendle
On Thursday, 15 July 2021 at 18:11:30 UTC, evilrat wrote:
On Thursday, 15 July 2021 at 17:49:06 UTC, Tejas wrote:
I'm sorry, I should've explicitly mentioned I'm interested in
learning how to do friend injection in D.
I know that access specifiers operate at module scope, seen a
few posts
On Thursday, 15 July 2021 at 18:06:26 UTC, Steven Schveighoffer
wrote:
On 7/15/21 1:43 PM, Tejas wrote:
How do you write the equivalent of that in D? Is the answer
still the same? Manually keep it in the same module, or is
there a programmatic way of converting this to D?
Functions in the sa
On Thursday, 15 July 2021 at 18:08:45 UTC, Scotpip wrote:
Hi folks
Settling down to write my first app but have come to a grinding
halt. This is my first system-level language so I'm afraid I'll
be asking some naïve questions.
All I'm trying to do is read a text file with Windows line
endin
On Monday, 19 July 2021 at 10:49:56 UTC, kinke wrote:
On[snip]
Is LDC still compatible with GDC/GCC inline asm? I remember Johan
saying they will break compatibilty in the near future...
On Monday, 19 July 2021 at 16:05:57 UTC, kinke wrote:
On Monday, 19 July 2021 at 11:16:49 UTC, Tejas wrote:
On Monday, 19 July 2021 at 10:49:56 UTC, kinke wrote:
On[snip]
Is LDC still compatible with GDC/GCC inline asm? I remember
Johan saying they will break compatibilty in the near future.
The following doesn't work:
```d
import std;
int opBinary(string s:"+")(int a, int b){
int result;
ab? (result = 1): (result = 0);
return result;
}
void main(){
int f = 1 + 5;
writeln(f);
}
```
It outputs 6
But if I manually write it as
```d
int f = opBinary!"+"(1,5);
```
It w
On Tuesday, 20 July 2021 at 06:30:56 UTC, Mike Parker wrote:
On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote:
Why isn't it working by default?
Initially, I was trying to create the spaceship operator of
C++, but we aren't allowed to create new operators, it seems.
Then I just wanted to
On Tuesday, 20 July 2021 at 06:34:45 UTC, vit wrote:
On Tuesday, 20 July 2021 at 06:20:34 UTC, Tejas wrote:
...
Initially, I was trying to create the spaceship operator of
C++, but we aren't allowed to create new operators
...
D has spaceship operator: opCmp
(https://dlang.org/spec/operator
On Tuesday, 20 July 2021 at 18:32:26 UTC, Ali Çehreli wrote:
On 7/19/21 11:20 PM, Tejas wrote:
> trying to create the spaceship operator of C++
Just to make sure, D's opCmp returns an int. That new C++
operator was added to provide the same semantics.
Ali
I know. As I already mentioned, I
On Thursday, 22 July 2021 at 05:57:02 UTC, jfondren wrote:
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote:
... it compiles no-more: Error: found `End of File` when
expecting `}` following compound statement
... what I am doing wrong ?
You'll get the same error from this code:
```d
On Thursday, 22 July 2021 at 18:06:07 UTC, Paul Backus wrote:
On Thursday, 22 July 2021 at 17:38:09 UTC, Tejas wrote:
Why does this work?
```d
import std;
void main()
{
mixin("int") a;
writeln(a);
}
```
You can mix in a type:
https://dlang.org/spec/type.html#mixin_types
Looks like
On Friday, 23 July 2021 at 20:24:02 UTC, Jim wrote:
Hello,
I've been playing with D and trying to understand how to work
with @nogc. I must be doing something wrong, because even
though I tagged the destructor for my class `@nogc`, I'm
getting the following error: `.\min.d(27): Error: "@nogc"
```d
import std;
import core.thread.osthread;
void delegate() f;
void main()
{
void func(){}
f = &func;
createLowLevelThread(&func, 2<<30);//works
createLowLevelThread(f, 2<<30);// doesn't work!!
}
```
Can someone help?
On Monday, 26 July 2021 at 15:42:44 UTC, Paul Backus wrote:
On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:
```d
import std;
import core.thread.osthread;
void delegate() f;
void main()
{
void func(){}
f = &func;
createLowLevelThread(&func, 2<<30);//works
createLowLevelThre
1 - 100 of 254 matches
Mail list logo