Re: Is there such concept of a list in D?

2022-12-19 Thread Mike Parker via Digitalmars-d-learn
On Monday, 19 December 2022 at 22:22:11 UTC, thebluepandabear 
wrote:


No worries, hopefully a mod will explain why. I don't like when 
posts get removed for no reason :|


I received a report of a possible troll in the forums. Looking at 
the posts collectively, I agreed, so deleted all of them. 
Whenever we delete a post, we delete subsequent posts that quote 
them as well.


Please take any further discussion on moderation policies to a 
new thread in the General forum and let's take this thread back 
on topic. Thanks!


Re: Preventing nested struct destructor accessing stack frame

2022-12-19 Thread ag0aep6g via Digitalmars-d-learn

On 16.12.22 14:07, Nick Treleaven wrote:

This seems to work:

     ~this() @trusted { if ( > cast(void*)1024) i++; }

It would be better if there was a struct property to get the context 
pointer though.


A quick test suggests that the context pointer is the last item in 
`tupleof`. So this might do the trick:


~this() { if (this.tupleof[$ - 1] !is null) i++; }

I don't know if it's guaranteed to work though. Might be an 
implementation detail.


Re: Is there such concept of a list in D?

2022-12-19 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 19 December 2022 at 22:22:11 UTC, thebluepandabear 
wrote:


No worries, hopefully a mod will explain why. I don't like when 
posts get removed for no reason :|


AI surround us in forum. People want to video chat now. In the 
time we live in, you can't be sure what to trust!


SDB@79


Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn



No worries, hopefully a mod will explain why. I don't like when 
posts get removed for no reason :|


Re: Is there such concept of a list in D?

2022-12-19 Thread Ali Çehreli via Digitalmars-d-learn

On 12/19/22 14:14, thebluepandabear wrote:

> Yeah I am sure it was on this thread. One of the posts was at
> https://forum.dlang.org/post/kzvnajixjdnlcupsl...@forum.dlang.org, it
> now shows 'Not Found'.

Then I don't know. (?)

However, I realize my ThunderBird "evidence" is useless because if the 
disapparance happened before my ThunderBird connected since its last 
time, it wouldn't have a copy of the posts.


(My ThunderBird does not connect automatically especially when the 
laptop lid is closed. :) )


Ali



Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn

On Monday, 19 December 2022 at 22:07:15 UTC, Ali Çehreli wrote:

On 12/19/22 13:45, thebluepandabear wrote:
> On Monday, 19 December 2022 at 21:41:45 UTC, thebluepandabear
wrote:
>> Why did my replies here to someone else get deleted?
>
> Myself and this other person's reply to this thread randomly
got removed
> for no reason, I would appreciate an explanation 

Are you sure it was this thread? What were in those posts? 
Perhaps they were posted on another thread?


I follow these newsgroups with ThunderBird, which naturally 
keeps local copies of the posts. I've just gone through all 
posts in this thread and I see no difference between 
ThunderBird's cache and the forum interface's cache.


Note that ThunderBird does not delete any post even if a 
moderator removes a posting from the newsgroup. For example, 
when a spam gets posted, my ThunderBird will show the post even 
after it's been deleted from the newsgroup server.


Ali


Yeah I am sure it was on this thread. One of the posts was at 
https://forum.dlang.org/post/kzvnajixjdnlcupsl...@forum.dlang.org, it now shows 'Not Found'. I just replied to this person who was asking whether or not I was talking about C's `union` type (I was not), and his post and my reply seems to have magically disappeared.


Re: _Symbols _with _leading _underscores

2022-12-19 Thread Paul via Digitalmars-d-learn

Much appreciated...


Re: Is there such concept of a list in D?

2022-12-19 Thread Ali Çehreli via Digitalmars-d-learn

On 12/19/22 13:45, thebluepandabear wrote:
> On Monday, 19 December 2022 at 21:41:45 UTC, thebluepandabear wrote:
>> Why did my replies here to someone else get deleted?
>
> Myself and this other person's reply to this thread randomly got removed
> for no reason, I would appreciate an explanation 

Are you sure it was this thread? What were in those posts? Perhaps they 
were posted on another thread?


I follow these newsgroups with ThunderBird, which naturally keeps local 
copies of the posts. I've just gone through all posts in this thread and 
I see no difference between ThunderBird's cache and the forum 
interface's cache.


Note that ThunderBird does not delete any post even if a moderator 
removes a posting from the newsgroup. For example, when a spam gets 
posted, my ThunderBird will show the post even after it's been deleted 
from the newsgroup server.


Ali



Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn
On Monday, 19 December 2022 at 21:41:45 UTC, thebluepandabear 
wrote:

Why did my replies here to someone else get deleted?


Myself and this other person's reply to this thread randomly got 
removed for no reason, I would appreciate an explanation 


Re: Is there such concept of a list in D?

2022-12-19 Thread thebluepandabear via Digitalmars-d-learn

Why did my replies here to someone else get deleted?




Re: No need opUnary

2022-12-19 Thread Ali Çehreli via Digitalmars-d-learn

On 12/18/22 08:21, Salih Dincer wrote:
> Don't you think it's interesting that it doesn't need unary operator
> overloading?

Yes, it is interesting. I put comments to explain it to myself:

import std.stdio;

struct S
{
int value;

/* The folowing declaration allows objects of this type to be
   implicitly convertible to 'int' (the return type of
   'opCall').

   In other words, since opCall returns 'int', now we know S
   objects can implicitly be used in place of an int. The
   value will be determined by calling opCall.

   For those of us who may not know opCall, it allows an
   object to be used as a function. For example, when you
   have an 'obj', you can do 'obj()'. (And as seen below, it
   returns 'int' for this struct.)

   (Note: It confused me for a bit because there are two
   opCall definitions below and they both return
   'int'. However, there is no ambiguity because the compiler
   picks the one that takes no parameter for the following
   alias this.)  */
   alias opCall this;

this(int i) {
value = i;
}

/* I didn't know one could do the following. You are giving a
   new name (opAssign) to opCall. I wonder whether the
   compiler considers opCall for the assignment operation or
   whether it looks for a proper opAssign definition. (Too
   lazy to check...)  */
alias opAssign = opCall;

/* This is the function call operator that takes an 'int',
  supporting usages like obj(42). */
@property opCall(int x) {
return value = x;
}

/* This is the function call opCall that takes nothing,
   supporting usages like obj(). */
@property opCall() inout {
return value;
}

/* This is the operator overload for usages like 'obj += 42'. */
@property opOpAssign(string op)(int x) {
write(":"); // came here before
mixin("return value"~op~"=x;");
}
// no need: opUnary(string op)();
}

void main()
{
/* Ok, this is regular object construction. */
S a = S(10),

/* Using a comma above is something I would never do but 'b' is
  another object being constructed regularly. */
  b = S(-1);

/* Since S does not define the '+' operation, I think the
   compiler looks and finds an implicit conversion, which
   happens to be to 'int'. I think the following expression
   is addition of two ints: 10 + (-1)' */
writeln(a + b); // 9

/* Although S does not support the ++ operator, the D
   compiler finds the += operation and replaces ++ with
   a+=1. And then a is implicitly converted to 'int', gets the
   value 11. Again, the expression is an int addition of 11 +
   (-1). */
writeln(++a + b); // :10

/* This uses opOpAssign. */
a += 10; // :

/* This result makes sense. */
assert(a == 21);

writeln("\n--");

writeln(-b); // 1
}

Ali



Re: Is there such concept of a list in D?

2022-12-19 Thread IGotD- via Digitalmars-d-learn

On Saturday, 10 December 2022 at 15:59:07 UTC, Ali Çehreli wrote:


There isn't a single point in favor of linked lists.


Yes there is, there are still special cases where linked lists 
can be a better alternative. Especially a version with intrusive 
members (with next/prev pointers as members in your object)


The intrusive linked list doesn't need any extra allocation apart 
from the object itself which means less fragmentation and small 
container allocations.


The double linked list has O(1) insert and delete, arrays has not.

The single linked list offer completely lockless variants, which 
is also completely unbounded.


The intrusive linked list has better performance with everything, 
except random access.


You can move/splice entire lists without copying.

The linked list performs equally well regardless of number of 
objects or object size. The performance of arrays depend on this.




As CPUs has progressed the array has become more favorable than 
the linked list type that is being offered by most standard 
libraries (the one that must allocate container objects, not 
intrusive). For most programming practices the array is usually 
the best. However, there are occasions where the linked list can 
be worth to be considered.






Re: No need opUnary

2022-12-19 Thread Salih Dincer via Digitalmars-d-learn

On Monday, 19 December 2022 at 07:32:02 UTC, j wrote:


Was my email deleted? Which compiler are you using?


Are you an AI engine?

SDB@79




Provisioning C libraries in Windows CI builds

2022-12-19 Thread Per Nordlöw via Digitalmars-d-learn

I just tried activating Linux and Windows CI for

https://code.dlang.org/packages/gmp-d

via

https://github.com/nordlow/gmp-d/.github/workflows/d.yml

Linux passes but the Windows builds all fail because `gmp.lib` is 
not provisioned in the Windows CI. This is new to me so I need 
some initial guidance as I'm suspecting there are multiple 
package managers or direct sources download methods available for 
getting gmp.lib provisioned locally so linking finds `gmp.lib`.


gmp is available via https://vcpkg.io/en/packages.html is that 
the preferred way?