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));
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
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
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
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
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
On Thursday, 8 July 2021 at 12:04:01 UTC, Paul Backus wrote:
https://digitalmars.com/articles/b68.html
Thank you very much :D
Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { ::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;
```
What is the equivalent D code?
Ditto for pointer to class instances:
```
int
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 { ::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;
```
What is the equivalent D code?
Ditto
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
On Sunday, 22 August 2021 at 01:14:08 UTC, Alexey wrote:
On Saturday, 21 August 2021 at 20:35:43 UTC, Alexey wrote:
Hello
```D
interface Int
{
void coolFunc();
}
class C1
{
void coolFunc()
{
return;
}
}
class C2 : C1, Int
{
}
void main()
{
auto c = new C2;
}
```
On Friday, 20 August 2021 at 05:43:49 UTC, evilrat wrote:
On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote:
On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote:
On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote:
As the topic says:
Is there an equivalent to C++'s
On Sunday, 15 August 2021 at 16:23:25 UTC, Ali Çehreli wrote:
On 8/15/21 2:10 AM, Alexandru Ermicioi wrote:
>> This may be useful in some cases but in general, these
colatteral
>> exceptions don't carry much information and I don't think
anybody
>> looks at them. Usually, the first one is the
On Friday, 13 August 2021 at 08:25:33 UTC, JG wrote:
Suppose one has a pointer p of type T*.
Can on declare variable a of type T which is stored in the
location pointed to by p?
As an example if we have:
struct S
{
int x = 1234;
}
void main() {
S s;
On Monday, 16 August 2021 at 06:36:02 UTC, james.p.leblanc wrote:
On Monday, 16 August 2021 at 06:20:11 UTC, Tejas wrote:
Maybe just write `T[]` in code rather than making it happen
via the colon?
I also have similar troubles, removing the default value
always helped me.
Can you show the
On Monday, 16 August 2021 at 05:47:10 UTC, Mathias LANG wrote:
On Monday, 16 August 2021 at 05:36:07 UTC, Tejas wrote:
That is why I was using heapAllocate, because using `new` on
scope allocates exception on stack, and if you exit, then the
exception is basically freed before it even gets
On Monday, 16 August 2021 at 06:17:22 UTC, Alexandru Ermicioi
wrote:
On Monday, 16 August 2021 at 06:12:14 UTC, Tejas wrote:
...
Fyi, check out std.exeprimental.allocator package. You can use
allocators from there to do allocation of exceptions, on the
heap or any other region.
Yes, I
On Monday, 16 August 2021 at 06:49:08 UTC, james.p.leblanc wrote:
On Monday, 16 August 2021 at 06:42:48 UTC, Tejas wrote:
If the code works, what's the problem?
Hej Again,
I was able to construct the working code shown above from help I
obtained here in the forum and other resources.
My
On Sunday, 15 August 2021 at 20:23:03 UTC, Paul Backus wrote:
On Sunday, 15 August 2021 at 18:47:27 UTC, Tejas wrote:
Do you see anything wrong with the following
`emplace`-allocated, RAII following exceptions:
[...]
Is this good enough for general use now? Any other drawbacks?
It only
On Sunday, 15 August 2021 at 20:23:03 UTC, Paul Backus wrote:
On Sunday, 15 August 2021 at 18:47:27 UTC, Tejas wrote:
Do you see anything wrong with the following
`emplace`-allocated, RAII following exceptions:
[...]
Is this good enough for general use now? Any other drawbacks?
It only
On Monday, 16 August 2021 at 06:12:42 UTC, james.p.leblanc wrote:
On Monday, 16 August 2021 at 05:26:00 UTC, Tejas wrote:
If you're finding the spec too hard, please try Ali's book.
I'm sharing the part on operator overloading below:
http://ddili.org/ders/d.en/operator_overloading.html
On Sunday, 15 August 2021 at 20:41:51 UTC, james.p.leblanc wrote:
Greetings,
I have been trying to get a working example of slice assignment
operator
overloading ... and am befuddled. From the spec (section
20.6.2), the
code below appears:
struct A
{
int opIndexAssign(int
On Wednesday, 18 August 2021 at 05:33:13 UTC, james.p.leblanc
wrote:
On Tuesday, 17 August 2021 at 20:28:20 UTC, Alexandru Ermicioi
wrote:
On Tuesday, 17 August 2021 at 19:53:52 UTC, james.p.leblanc
wrote:
Wow! That is absolutely beautiful ... I had never seen (or
even
imagined) a recursive
On Saturday, 14 August 2021 at 09:40:54 UTC, kdevel wrote:
Today I stumbled across three issues with partial
initialization of "static" arrays:
~~~i1.d
void main ()
{
char [7] b = [ 1: 'x' ]; // okay
char [7] a = [ 0: 'x' ]; // i1.d(4): Error: mismatched array
lengths, 7 and 1
}
~~~
On Saturday, 14 August 2021 at 11:41:36 UTC, Tejas wrote:
What is the drawback of the following "simple" ```@nogc```
exception creation technique?
```d
import std;
void main()@nogc
{
try{
__gshared a = new Exception("help");
scope b = a;
throw b;
}
On Saturday, 14 August 2021 at 14:04:47 UTC, kdevel wrote:
On Saturday, 14 August 2021 at 13:01:13 UTC, frame wrote:
I would say case [...] 3 is not [a bug]. It's just the element
type conversion and mismatched lengths of the ranges.
~~~
char [7] d7 = "x"; // okay
string s = "x";
On Saturday, 14 August 2021 at 08:23:20 UTC, user1234 wrote:
On Saturday, 14 August 2021 at 04:09:34 UTC, Tejas wrote:
[...]
Oh right, the ```.``` operator will reference variable in the
_module_ scope, not just the _immediate outer scope_,
you can use the module name to disambiguate as
What is the drawback of the following "simple" ```@nogc```
exception creation technique?
```d
import std;
void main()@nogc
{
try{
__gshared a = new Exception("help");
scope b = a;
throw b;
}
catch(Exception e){
printf("caught");
}
}
```
On Saturday, 14 August 2021 at 13:01:13 UTC, frame wrote:
On Saturday, 14 August 2021 at 09:40:54 UTC, kdevel wrote:
Shall I file them to bugzilla?
I would say case 2 and 3 are not bugs. It's just the element
type conversion and mismatched lengths of the ranges.
Not sure about the first
On Saturday, 14 August 2021 at 14:33:42 UTC, kdevel wrote:
On Saturday, 14 August 2021 at 14:18:57 UTC, Tejas wrote:
On Saturday, 14 August 2021 at 14:04:47 UTC, kdevel wrote:
On Saturday, 14 August 2021 at 13:01:13 UTC, frame wrote:
I would say case [...] 3 is not [a bug]. It's just the
On Saturday, 14 August 2021 at 04:01:31 UTC, Mike Parker wrote:
On Saturday, 14 August 2021 at 03:47:05 UTC, Tejas wrote:
```d
import std;
auto abc(T)(auto ref T a, auto ref T b){
return a+b;
}
auto def(T)(auto ref T a, auto ref T b){
return a*b;
}
alias macro_1 = abc;
void main()
```d
import std;
auto abc(T)(auto ref T a, auto ref T b){
return a+b;
}
auto def(T)(auto ref T a, auto ref T b){
return a*b;
}
alias macro_1 = abc;
void main()
{
writeln(macro_1(15, 20));
alias macro_1 = def;// is this NOT considered variable
shadowing?
On Saturday, 14 August 2021 at 15:28:36 UTC, Alexandru Ermicioi
wrote:
On Saturday, 14 August 2021 at 13:24:22 UTC, Tejas wrote:
...
I don't think there are any gotchas here. The problem with this
technique, is when your exceptions aren't just simple labels
but also carry some additional
On Saturday, 21 August 2021 at 06:58:47 UTC, Ali Çehreli wrote:
On 8/20/21 11:19 PM, Tejas wrote:
[...]
Yes. 'static foreach' does not introduce scope, which can be
pretty useful. For example, one can define functions at module
scope.
The subtle differences between 'static foreach' and
On Saturday, 21 August 2021 at 06:03:33 UTC, Ali Çehreli wrote:
On 8/20/21 10:37 PM, Alexandru Ermicioi wrote:
[...]
Cool! Much better. :)
I could not do
[...]
Did you use that double curly bracket in `static foreach` so that
you don't get error for declaring stuff inside `static
On Thursday, 19 August 2021 at 09:39:26 UTC, evilrat wrote:
On Thursday, 19 August 2021 at 08:25:23 UTC, Bienlein wrote:
Oops, I just realized that you can also not call emplace when
@nogc is present. Well that is at least consistent with not
either being able to call destroy ;-).
So, I
On Saturday, 21 August 2021 at 13:45:59 UTC, Ali Çehreli wrote:
On 8/21/21 1:31 AM, Tejas wrote:
> I was more impressed that you found that hack in the first
place
I can't take credit. :) 'static foreach' had that difference
since its inception. The spec says "If a new scope is desired
for
On Sunday, 15 August 2021 at 08:51:19 UTC, rempas wrote:
On Sunday, 15 August 2021 at 08:47:39 UTC, jfondren wrote:
dup() isn't aware of the NUL since that's outside the slice of
the string. It only copies the chars in "John". You can use
toStringz to ensure NUL termination:
On Thursday, 19 August 2021 at 18:11:20 UTC, Paul Backus wrote:
On Thursday, 19 August 2021 at 18:04:58 UTC, Tejas wrote:
On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote:
On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote:
As the topic says:
Is there an equivalent to
As the topic says:
Is there an equivalent to C++'s `explicit` keyword in D?
On Thursday, 19 August 2021 at 17:43:59 UTC, Paul Backus wrote:
On Thursday, 19 August 2021 at 17:38:14 UTC, Tejas wrote:
As the topic says:
Is there an equivalent to C++'s `explicit` keyword in D?
No, because all constructors are explicit in D.
Oh... then I guess I'll have to manually
On Sunday, 15 August 2021 at 00:15:32 UTC, Ali Çehreli wrote:
On 8/14/21 4:41 AM, Tejas wrote:
> [...]
exception
> [...]
So, there would be many exception objects one for each place
that an exception can be thrown. Functions like enforce() would
have to take a reference to the exception
On Sunday, 15 August 2021 at 03:45:07 UTC, Mathias LANG wrote:
On Sunday, 15 August 2021 at 02:09:08 UTC, Tejas wrote:
[...]
You can't really have `@nogc` allocated Exception without
circumventing the type system. Personally I gave up on `@nogc`
just because of how inconvenient it is.
On Saturday, 14 August 2021 at 23:14:51 UTC, Paul Backus wrote:
On Saturday, 14 August 2021 at 15:58:17 UTC, Tejas wrote:
If you're willing to help further, would you please tell me
why there is a GC allocation in the code below that uses
```emplace```? Will such code truly work if GC is never
On Sunday, 15 August 2021 at 02:09:08 UTC, Tejas wrote:
On Sunday, 15 August 2021 at 00:15:32 UTC, Ali Çehreli wrote:
On 8/14/21 4:41 AM, Tejas wrote:
> [...]
exception
> [...]
So, there would be many exception objects one for each place
that an exception can be thrown. Functions like
On Thursday, 9 September 2021 at 05:32:29 UTC, Tejas wrote:
On Tuesday, 7 September 2021 at 17:47:15 UTC, james.p.leblanc
wrote:
[...]
from what I understand you want to change the aligned data that
you're referring to at runtime.
```d
void main()
{
import
On Tuesday, 7 September 2021 at 17:47:15 UTC, james.p.leblanc
wrote:
On Tuesday, 7 September 2021 at 17:33:31 UTC, Adam D Ruppe
wrote:
On Tuesday, 7 September 2021 at 17:24:34 UTC, james.p.leblanc
wrote:
If you want to do a runtime lookup, you need to separate the
two pieces. This pattern
On Monday, 13 September 2021 at 18:42:47 UTC, Steven
Schveighoffer wrote:
On 9/13/21 1:54 PM, eugene wrote:
[...]
The GC only scans things that it knows about.
Inside your EventQueue you have this code:
[...]
Umm is it okay that he declared variables `init` and `idle` of
type `Stage`
On Wednesday, 15 September 2021 at 19:59:43 UTC, james.p.leblanc
wrote:
Dear All,
In attempting to learn and use code generation, it
would be useful to be able to view the source code
that gets generated.
However, with various combinations of templates, UDAs, and
mixins it has not been easy.
On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc
wrote:
Dear All,
In searching through the forum archives (going back to 2013,
2016
etc), and experiments, it **appears to me** that LDC does indeed
respect the standard "align" properties. (Meaning: proper
alignment
for using
On Wednesday, 8 September 2021 at 04:43:31 UTC, Tejas wrote:
On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc
wrote:
[...]
Yes you are correct (to my understanding)
DMD only respects `align` keyword upto the value 16,ie, until
`align(16)`, the code behaves the way you expect
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
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
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
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
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 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
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:
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 -
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
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
On Monday, 2 August 2021 at 15:10:06 UTC, vit wrote:
On Monday, 2 August 2021 at 11:28:46 UTC, Tejas wrote:
[...]
Try this:
```d
void main(){
fp = cast(typeof(fp)) //fails
}
```
Agh, stupid me.
You the man!!
On Monday, 14 June 2021 at 13:31:51 UTC, baby_tiger wrote:
this used work for me, after upgrade I get this error. how to
fix it ?
import std.traits;
enum LogLevel : ubyte {
INFO = 0,
WARN,
ERROR,
On Tuesday, 3 August 2021 at 12:23:38 UTC, frame wrote:
On Tuesday, 3 August 2021 at 11:55:51 UTC, Paul Backus wrote:
You can't assign a `ref` to a variable; if you try, a copy is
created.
What you can do instead is use a pointer:
```d
Unique!myType* rs = ();
```
Thanks. I feared that. So
On Tuesday, 10 August 2021 at 05:03:12 UTC, nov wrote:
every time i try to use templates, i have problems :(
That is why C++ introduced concepts. Wonder when D will be
getting them :(
What exactly does the above statement mean?
Also, I have read here a principle that
**If it looks like C, it behaves like C**
How true is that for C++? Does code that look like C++(minus
obvious syntax differences) behave like C++?
Does having the same memory model help?
Thanks for
On Thursday, 5 August 2021 at 17:02:33 UTC, Tejas wrote:
On Thursday, 5 August 2021 at 16:28:35 UTC, Jack Stouffer wrote:
[...]
I also can't find anything... until someone else comes with a
better answer, maybe you can do this:
Use the ```-H``` compiler flag to generate ```.di``` files.
On Thursday, 5 August 2021 at 16:28:35 UTC, Jack Stouffer wrote:
I need to generate plain C99 .h files from a D module's
extern(C) declarations, so that I can link a DMD generated .o
file with a C code base. Are there any automated tools which do
this?
I know the compiler has C++ header
On Friday, 6 August 2021 at 22:15:00 UTC, Paul Backus wrote:
On Friday, 6 August 2021 at 19:03:53 UTC, Tejas wrote:
Stealing Paul's answer now:
```d
import std;
enum your_max_length = 1000;
enum your_align = 256;
struct MySlice(T/*, size_t maxLength*/)
{
private align(your_align)T
On Saturday, 7 August 2021 at 13:36:52 UTC, james.p.leblanc wrote:
On Saturday, 7 August 2021 at 12:08:00 UTC, Paul Backus wrote:
[...]
**First, thanks all for helping with this question!**
The simple desire to arbitrarily align an array is certainly
looking non-trivial.
Below is a simple
On Saturday, 7 August 2021 at 13:36:52 UTC, james.p.leblanc wrote:
On Saturday, 7 August 2021 at 12:08:00 UTC, Paul Backus wrote:
[...]
**First, thanks all for helping with this question!**
The simple desire to arbitrarily align an array is certainly
looking non-trivial.
Below is a simple
On Saturday, 7 August 2021 at 15:21:01 UTC, Paul Backus wrote:
On Saturday, 7 August 2021 at 14:34:49 UTC, Tejas wrote:
[...]
For the array as a whole to be aligned, not only must the
spacing between the elements respect the alignment, but
starting address of the array itself must be a
On Saturday, 7 August 2021 at 19:07:04 UTC, Paul Backus wrote:
On Saturday, 7 August 2021 at 15:41:24 UTC, Tejas wrote:
On Saturday, 7 August 2021 at 15:21:01 UTC, Paul Backus wrote:
[...]
Oh wow, and here I thought I was being smart :(
So, how can we work around this without assembly
On Tuesday, 10 August 2021 at 13:18:24 UTC, Paul Backus wrote:
On Tuesday, 10 August 2021 at 11:05:53 UTC, Tejas wrote:
Also, I have read here a principle that
**If it looks like C, it behaves like C**
How true is that for C++? Does code that look like C++(minus
obvious syntax differences)
On Tuesday, 10 August 2021 at 18:07:35 UTC, Bastiaan Veelo wrote:
On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote:
there's casting away const, a clearly seperate language
feature which has no equivalent in D;
You *can* cast away `const` in D: https://run.dlang.io/is/sWa5Mf
—
```d
import std;
void main()
{
int[40] staticA;
auto c = staticA[0..50];//mistake
}```
results in:
```d
core.exception.RangeError@onlineapp.d(5): Range violation
??:? _d_arrayboundsp [0x55db29a0b645]
./onlineapp.d:5 _Dmain [0x55db29a0ae8c]
```
Is there a way to make
On Tuesday, 10 August 2021 at 21:19:39 UTC, Bastiaan Veelo wrote:
On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote:
Basically, what are the subtle gotcha's in the differences
between C++ and D code that looks similar
The only gotcha that comes to my mind is that `private` means
On Wednesday, 11 August 2021 at 06:46:34 UTC, Stefan Koch wrote:
On Wednesday, 11 August 2021 at 06:29:40 UTC, Tejas wrote:
```d
import std;
void main()
{
int[40] staticA;
auto c = staticA[0..50];//mistake
}```
results in:
```d
core.exception.RangeError@onlineapp.d(5): Range violation
On Thursday, 12 August 2021 at 11:54:22 UTC, Learner wrote:
On Thursday, 12 August 2021 at 10:10:17 UTC, rikki cattermole
wrote:
On 12/08/2021 9:36 PM, Learner wrote:
It seems that there is no easy way to transition from a
postblit to a copy constructor, no?
struct Foo {
this(ref
On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote:
On Thursday, 12 August 2021 at 14:57:16 UTC, Steven
Schveighoffer wrote:
[...]
It is not clear to me why the inout generated copy constructor
of the B structure is not able to copy the A structure.
[...]
Why will copy
On Thursday, 12 August 2021 at 12:28:32 UTC, Learner wrote:
On Thursday, 12 August 2021 at 12:22:22 UTC, Tejas wrote:
On Thursday, 12 August 2021 at 12:19:56 UTC, Tejas wrote:
[...]
Works with ```@safe``` as well
Paul was just trying to make that other answer work, you don't
have to make
On Thursday, 12 August 2021 at 12:19:56 UTC, Tejas wrote:
On Thursday, 12 August 2021 at 11:54:22 UTC, Learner wrote:
[...]
Just add ```inout``` inside ```this(ref inout/*notice the
inout*/ Foo other) inout/*notice the inout*/```
Example code:
```d
struct Foo {
this(ref inout Foo
On Thursday, 12 August 2021 at 18:11:20 UTC, nayy wrote:
Hi
I cannot seems to be able to join the discord server
It gives me the following error: "unable to accept invit"
Is the invitation link expired?
https://dlang.org/community.html https://discord.gg/bMZk9Q4
I joined last week with the
On Saturday, 31 July 2021 at 13:57:40 UTC, kinke wrote:
This is possible via:
```
__dtor();
super.__dtor();
```
WHOO YEAH!!!
THANK YOU SO MUCH :D
```d
class A{
~this(){}
destructA(){
~this()
}
}
class B:A{
~this(){}
destructB(){
~this();
~super();
}
}
```
This could allow ```@nogc``` crowd to run destructors without
calling ```destroy```.
Yes, derived to base conversion is still a thing and
On Saturday, 31 July 2021 at 13:34:25 UTC, user1234 wrote:
On Saturday, 31 July 2021 at 13:12:21 UTC, Tejas wrote:
```d
class A{
~this(){}
destructA(){
~this()
}
}
class B:A{
~this(){}
destructB(){
~this();
~super();
}
}
```
This could allow
On Saturday, 31 July 2021 at 12:03:49 UTC, DLearner wrote:
Hi
This may be due to Windows, not DMD.
Please see code below (held in test.d):
```
void main() {
import std.stdio;
writeln("Test");
assert(false, "TestAssert");
}
```
`
dmd -i -run test.d
`
results in both "Test" and the
On Saturday, 31 July 2021 at 13:34:25 UTC, user1234 wrote:
On Saturday, 31 July 2021 at 13:12:21 UTC, Tejas wrote:
```d
class A{
~this(){}
destructA(){
~this()
}
}
class B:A{
~this(){}
destructB(){
~this();
~super();
}
}
```
This could allow
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote:
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
[...]
`char data[]` in the C struct is not a pointer, but actually a
[C99 flexible array member][1], and does not count towards the
struct's `sizeof`.
D does not have
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote:
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote:
[...]
`char data[]` in the C struct is not a pointer, but actually a
[C99 flexible array member][1], and does not count towards the
struct's `sizeof`.
D does not have
On Friday, 6 August 2021 at 10:50:19 UTC, james.p.leblanc wrote:
I am aware of the "capacity" concept with slices.
But, I would like to know if it is possible to set a
hard limit on a slice size.
I prefer it to error and crash instead of a doing an
extension or reallocation.
I understand my
On Friday, 6 August 2021 at 16:32:59 UTC, james.p.leblanc wrote:
On Friday, 6 August 2021 at 11:58:59 UTC, Paul Backus wrote:
struct MySlice(T, size_t maxLength)
{
private T[] payload;
invariant(payload.length <= maxLength);
this(T[] slice) { payload = slice; }
T opIndex(size_t
On Friday, 6 August 2021 at 17:16:28 UTC, Tejas wrote:
On Friday, 6 August 2021 at 16:32:59 UTC, james.p.leblanc wrote:
On Friday, 6 August 2021 at 11:58:59 UTC, Paul Backus wrote:
[...]
```
Paul,
Thanks very much for your reply. I understand only
a fraction of the suggested solution. I
On Friday, 6 August 2021 at 18:02:01 UTC, james.p.leblanc wrote:
mes
On Friday, 6 August 2021 at 17:25:24 UTC, Tejas wrote:
Okay we were overthinking the solution.
Just use a static array
```d
int[your_max_length]/*or whatever type*/ var;
```
You're good to go!
I almost feel stupid now lol
On Wednesday, 11 August 2021 at 19:04:50 UTC, Ali Çehreli wrote:
This is an interesting thread but "memory model" does not cover
or mean all of the points discussed here. I can't define it
precisely, so I'm leaving it to interested parties to search
for themselves. :)
Ali
A little bit of
On Wednesday, 11 August 2021 at 19:27:34 UTC, Ali Çehreli wrote:
On 8/11/21 12:19 PM, Tejas wrote:
Atleast leave some pointers on where to start :(
I DuckDuckGo'ed it for you. :)
https://en.cppreference.com/w/cpp/language/memory_model
Then looked it up at Wikipedia too:
On Monday, 20 September 2021 at 13:48:01 UTC, Tejas wrote:
On Monday, 20 September 2021 at 12:23:00 UTC, Learner wrote:
[...]
I think it *is* being called:
```d
import std.stdio;
struct S
{
int a;
this(int param){
a = param;
}
~this()
{
On Monday, 20 September 2021 at 12:23:00 UTC, Learner wrote:
I was expecting something like going out of scope for that
```(D)
import std.stdio;
struct S
{
~this()
{
writeln("S is being destructed");
}
}
void main()
{
S[int] aa;
aa[1] = S();
aa.remove(1);
On Monday, 20 September 2021 at 14:03:09 UTC, Tejas wrote:
On Monday, 20 September 2021 at 13:48:01 UTC, Tejas wrote:
On Monday, 20 September 2021 at 12:23:00 UTC, Learner wrote:
[...]
I think it *is* being called:
```d
import std.stdio;
struct S
{
int a;
this(int param){
On Saturday, 25 September 2021 at 08:18:49 UTC, Elronnd wrote:
(Not saying @live isn't useless, just that this doesn't
indicate that.)
Must we continue hurting Walter's feelings :(
1 - 100 of 253 matches
Mail list logo