Sizinle Aynı İlgi Alanlarını Paylaşan Kişileri Bulun

2022-11-08 Thread sohbet via Digitalmars-d-learn
Yalnız hissettiğimiz ve düşüncelerimizi ve bakış açılarımızı 
biriyle paylaşmak istediğimiz çok zaman vardır.Yalnızlık, günümüz 
yaşamının bir yan ürünüdür.Çoğu zaman düşüncelerimizi analiz etme 
fırsatımız olmuyor.İnsanların anonim Sohbet odalarına 
başvurmasının nedeni budur. Gevezeyeri.CoM, herhangi bir konuda 
yabancılarla rahatça konuşmanıza izin veren böyle bir 
platformdur. https://www.gevezeyeri.com/sohbet.html


Rastgele insanlarla Sohbet edin, romantizm bulun, çevrimiçi 
arkadaşlığın tadını çıkarın veya daha önce hiç tanışmadığınız 
insanlarla 
sosyalleşin.https://www.gevezeyeri.com/mobil-sohbet.html





Re: My new programming book ...

2022-11-08 Thread zjh via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 13:55:44 UTC, Adam D Ruppe wrote:

It is on my list but minigui is a pretty simple class 
collection of basic widgets. It works pretty well now. I don't 
have too many intro examples yet though. My blog has one thing 
but it uses an experimental piece 
(http://dpldocs.info/this-week-in-d/Blog.Posted_2020_11_02.html) that isn't  really representative of the average program.


But if I make it to the dconf online I'll probably show off a 
minigui application there this year.



Thank you. I think `gui` is also suitable for d.



Re: Makefiles and dub

2022-11-08 Thread Mathias LANG via Digitalmars-d-learn

On Friday, 4 November 2022 at 23:19:17 UTC, Anonymouse wrote:
[#20699](https://issues.dlang.org/show_bug.cgi?id=20699) must 
be non-trivial to fix, so I'm exploring makefiles. If possible 
I'd like to keep dub for dependency management though, just not 
for actual compilation.


That bug is fixed for the last 3 releases (not including the 
current one in progress), that is, since v1.26.0.


Is it at all possible (or even desireable) to construct a 
makefile that builds dependencies from outside of the source 
tree (namely 
`$HOME/.dub/packages/package_with_unknown_version-1.2.[0-9]+/`)?


Does anyone have an example `Makefile` I could dissect?

Thanks.


In the past, I used https://github.com/sociomantic-tsunami/makd 
for building D code.
But it doesn't do dependency management like dub, as it expected 
libraries to be in `submodules/`.


Re: My new programming book ...

2022-11-08 Thread Adam D Ruppe via Digitalmars-d-learn

On Monday, 7 November 2022 at 06:10:46 UTC, zjh wrote:
How is your `minigui`? Please write an `introduction` when you 
have time.


It is on my list but minigui is a pretty simple class collection 
of basic widgets. It works pretty well now. I don't have too many 
intro examples yet though. My blog has one thing but it uses an 
experimental piece 
(http://dpldocs.info/this-week-in-d/Blog.Posted_2020_11_02.html) 
that isn't  really representative of the average program.


But if I make it to the dconf online I'll probably show off a 
minigui application there this year.


Re: My new programming book ...

2022-11-08 Thread Adam D Ruppe via Digitalmars-d-learn

On Monday, 7 November 2022 at 04:54:05 UTC, ikelaiah wrote:
I'm aware of the publication date. However, I find the content 
still highly relevant to many day-to-day tasks (my use case).


Yeah, I tried to focus more on the ideas behind it than the 
specifics of a library. My thought is if you understand what it 
is trying to do, the adjustments to bring it up to date shouldn't 
be too hard.


It took some effort to avoid talking more about my libraries 
though lol. I did do a few small examples near the end of the 
book, and some of those have had minor changes, like I've since 
renamed "import simpledisplay" to "import arsd.simpledisplay". 
But the rest of it should still work, i try to keep things pretty 
stable in my libs.


BTW one of the things in chapter 2 i found surprisingly popular 
was the talk about std.socket. I did write a follow-up to that in 
my blog here:

http://dpldocs.info/this-week-in-d/Blog.Posted_2019_11_11.html#sockets-tutorial

Since the socket api is the same as C, I assumed people would 
know it from other sources, but the C api isn't as common 
knowledge as it used to be. So this tries to explain (tho even 
there I didn't go into ipv6 fallbacks and whatnot but it still 
lays the foundation).


And of course always feel free to ask here or whatever about 
anything, if I'm online I try to answer things pretty quickly.


Re: Passing a string by reference

2022-11-08 Thread Alexander Zhirov via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 13:05:09 UTC, Ali Çehreli wrote:
Yes. Classes are reference types in D. Class variables are 
implemented as pointers. Their default value is null.


Ali


Thanks! 🙂


Re: Passing a string by reference

2022-11-08 Thread Ali Çehreli via Digitalmars-d-learn

On 11/8/22 04:53, Alexander Zhirov wrote:
> On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote:
>> Just use plain `string`.
>
> So it's always working with thick pointers?

Yes, D's arrays are fat pointers. strings are arrays of immutable(char).

>> nope, an object isn't created there at all. you should use `new C`.
>
> If I create just `A c`, then is it an empty pointer?

Yes. Classes are reference types in D. Class variables are implemented 
as pointers. Their default value is null.


Ali



Re: Passing a string by reference

2022-11-08 Thread Alexander Zhirov via Digitalmars-d-learn

Thanks for answers!

On Tuesday, 8 November 2022 at 12:43:47 UTC, Adam D Ruppe wrote:
You should almost never use `ref string`. Just use plain 
`string`.


So it's always working with thick pointers?

nope, an object isn't created there at all. you should use `new 
C`.


If I create just `A c`, then is it an empty pointer?


Re: Passing a string by reference

2022-11-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov 
wrote:
Do I understand correctly that in order for me to pass a string 
when creating an object, I must pass it by value?


You should almost never use `ref string`. Just use plain `string`.

In fact, ref in general in D is a lot more rare than in languages 
like C++. The main reason to use it for arrays is when you need 
changes to the length to be visible to the caller... which is 
fairly rare.


In the case of the variable `c`, a drop occurs. Why? An object 
is not being created on the stack?


nope, an object isn't created there at all. you should use `new 
C`.


Re: Passing a string by reference

2022-11-08 Thread Hipreme via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov 
wrote:
Do I understand correctly that in order for me to pass a string 
when creating an object, I must pass it by value? And if I have 
a variable containing a string, can I pass it by reference?


Should I always do constructor overloading for a type and a 
reference to it?
In the case of the variable `c`, a drop occurs. Why? An object 
is not being created on the stack?


```d
import std.stdio : writeln;

class A
{
private string str = "base";

this(ref string str)
{
writeln("type reference string");
this.str = str;
}

this(string str)
{
writeln("type string");
this.str = str;
}

this() {}

void print()
{
writeln(str);
}
}

void main()
{
auto a = new A("Hello, World!"); // this type string
a.print();
string text = "New string";
auto b = new A(text); // this type reference string
b.print();
A c;
c.print();  // segmentation fault! Why not "base"?
}

```



You forgot to assign "c" to anything, I think you meant:
`A c = b;`
Read that segmentation fault as null pointer exception.

Whenever you assign something to `ref type something`, it will 
basically be the same as writing `myVariable = *something;` in C 
code, so, in that case, it won't make any difference.


The `ref` attribute only means that if you change your string 
inside the code that takes by ref, it will reflect when 
returning, such as:

```d
void modifyString(ref string input)
{
   input~= "Now it is modified";
}
string text = "New string";
modifyString(text);
writeln(text); //"New stringNow it is modified"
```



Re: Passing a string by reference

2022-11-08 Thread novice2 via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov 
wrote:

A c;


this declaration not creates class instance. you should use "new".

btw, struct have other behavoiur



Passing a string by reference

2022-11-08 Thread Alexander Zhirov via Digitalmars-d-learn
Do I understand correctly that in order for me to pass a string 
when creating an object, I must pass it by value? And if I have a 
variable containing a string, can I pass it by reference?


Should I always do constructor overloading for a type and a 
reference to it?
In the case of the variable `c`, a drop occurs. Why? An object is 
not being created on the stack?


```d
import std.stdio : writeln;

class A
{
private string str = "base";

this(ref string str)
{
writeln("type reference string");
this.str = str;
}

this(string str)
{
writeln("type string");
this.str = str;
}

this() {}

void print()
{
writeln(str);
}
}

void main()
{
auto a = new A("Hello, World!"); // this type string
a.print();
string text = "New string";
auto b = new A(text); // this type reference string
b.print();
A c;
c.print();  // segmentation fault! Why not "base"?
}

```