Fiber.yield with call scope guard

2017-12-29 Thread ChangLong via Digitalmars-d-learn
I am look a method like Fiber.yieldAndThrow, but also call all scopeguard. I am hack Fiber into struct with no throw, try to use it on network project with high performance. I use scopeguard to auto release memory or resource, but when I call Fiber .yieldAndThrow the scopeguard chain will

Re: why @property cannot be pass as ref ?

2017-12-29 Thread ChangLong via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 18:43:21 UTC, Ali Çehreli wrote: Thanks to Mengü for linking to that section. I have to make corrections below. Ali Thanks for explain, Ali And Mengu. What I am try to do is implement a unique data type. (the ownership auto moved into new handle)

Re: What could this OptLink Error mean?

2017-12-29 Thread user1234 via Digitalmars-d-learn
On Friday, 29 December 2017 at 16:11:20 UTC, Dukc wrote: I was building one example of DLangUi (dub build --build-mode=allAtOnce --build=debuglinker) and it did compile but the linker started to complain. I did notice it seemed to be related to the standard library, so I updated it and

Re: Slices and Dynamic Arrays

2017-12-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 29, 2017 22:32:01 Tony via Digitalmars-d-learn wrote: > In DLang Tour:Arrays > https://tour.dlang.org/tour/en/basics/arrays > > there is: > --- > int size = 8; // run-time variable > int[] arr = new int[size]; > > The type of arr is

Re: Slices and Dynamic Arrays

2017-12-29 Thread Muld via Digitalmars-d-learn
On Friday, 29 December 2017 at 22:32:01 UTC, Tony wrote: In DLang Tour:Arrays https://tour.dlang.org/tour/en/basics/arrays there is: --- int size = 8; // run-time variable int[] arr = new int[size]; The type of arr is int[], which is a slice.

Re: Slices and Dynamic Arrays

2017-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 29 December 2017 at 22:32:01 UTC, Tony wrote: Based on those two web pages it appears that the name for a dynamic array in D is "slice". That is, anytime you have a dynamic array (even a null reference version) it is called a slice. Is that correct? Not exactly, but

Slices and Dynamic Arrays

2017-12-29 Thread Tony via Digitalmars-d-learn
In DLang Tour:Arrays https://tour.dlang.org/tour/en/basics/arrays there is: --- int size = 8; // run-time variable int[] arr = new int[size]; The type of arr is int[], which is a slice. --- In "D Slices"

Re: Is Nullable supposed to provide Optional semantics?

2017-12-29 Thread vit via Digitalmars-d-learn
On Friday, 29 December 2017 at 21:43:25 UTC, Chris Paulson-Ellis wrote: On Friday, 29 December 2017 at 21:34:27 UTC, vit wrote: use: n = Nullable!Object.init; //doesn't call destroy instead of: n.nullify(); Only nullify() can make isNull return true again. I need that semantic.

Re: Is Nullable supposed to provide Optional semantics?

2017-12-29 Thread Dukc via Digitalmars-d-learn
On Friday, 29 December 2017 at 21:43:25 UTC, Chris Paulson-Ellis wrote: Only nullify() can make isNull return true again. I need that semantic. Quick idea without much afterthought: instead of Nullable, use pointer to o?

Re: Is Nullable supposed to provide Optional semantics?

2017-12-29 Thread Chris Paulson-Ellis via Digitalmars-d-learn
On Friday, 29 December 2017 at 21:34:27 UTC, vit wrote: use: n = Nullable!Object.init; //doesn't call destroy instead of: n.nullify(); Only nullify() can make isNull return true again. I need that semantic.

Re: Is Nullable supposed to provide Optional semantics?

2017-12-29 Thread vit via Digitalmars-d-learn
On Friday, 29 December 2017 at 20:52:51 UTC, Chris Paulson-Ellis wrote: I've been bitten by trying to use Nullable(T) on class types. Minimal example... [...] use: n = Nullable!Object.init; //doesn't call destroy instead of: n.nullify();

Is Nullable supposed to provide Optional semantics?

2017-12-29 Thread Chris Paulson-Ellis via Digitalmars-d-learn
I've been bitten by trying to use Nullable(T) on class types. Minimal example... import std.typecons : Nullable; void main() { auto o = new Object(); o.toString(); Nullable!Object n = o; o.toString(); n.nullify(); o.toString(); // SegV! } The SEGV is caused by

Re: How do you safely deal with range.front?

2017-12-29 Thread Dukc via Digitalmars-d-learn
On Friday, 29 December 2017 at 19:38:44 UTC, aliak wrote: So when I'm dealing with ranges, there're a number of times where I get the front of the returned result of a set of operations, but of course there is no front so you get an runtime access error. This could be what you want: auto

Re: How do you safely deal with range.front?

2017-12-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 29, 2017 19:38:44 aliak via Digitalmars-d-learn wrote: > Hi, > > So when I'm dealing with ranges, there're a number of times where > I get the front of the returned result of a set of operations, > but of course there is no front so you get an runtime access > error. You don't

Re: How do you safely deal with range.front?

2017-12-29 Thread Seb via Digitalmars-d-learn
On Friday, 29 December 2017 at 19:38:44 UTC, aliak wrote: Hi, So when I'm dealing with ranges, there're a number of times where I get the front of the returned result of a set of operations, but of course there is no front so you get an runtime access error. [...] Do you know about the

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Mengu via Digitalmars-d-learn
On Friday, 29 December 2017 at 13:08:38 UTC, rikki cattermole wrote: On 29/12/2017 12:59 PM, rjframe wrote: On Fri, 29 Dec 2017 12:39:25 +, Nicholas Wilson wrote: [...] I've actually thought about doing this to get rid of a bunch of if qualifiers in my function declarations. `static

How do you safely deal with range.front?

2017-12-29 Thread aliak via Digitalmars-d-learn
Hi, So when I'm dealing with ranges, there're a number of times where I get the front of the returned result of a set of operations, but of course there is no front so you get an runtime access error. In some other languages the concept of "front" or "first" returns a safe referece, or

Re: how to localize console and GUI apps in Windows

2017-12-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 29, 2017 at 10:35:53AM +, Andrei via Digitalmars-d-learn wrote: > On Thursday, 28 December 2017 at 18:45:39 UTC, H. S. Teoh wrote: > > On Thu, Dec 28, 2017 at 05:56:32PM +, Andrei via Digitalmars-d-learn > > wrote: > > ... > > The string / wstring / dstring types in D are

Re: Difference in reduce in std and mir

2017-12-29 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 16:12:07 UTC, Seb wrote: On Tuesday, 26 December 2017 at 15:56:19 UTC, Vino wrote: Hi All, What is the difference between std.algorithm.reduce and mir.ndslice.algorithm.reduce. From, Vino.B Mir's reduce works on Slices whereas Phobos's reduce works on

What could this OptLink Error mean?

2017-12-29 Thread Dukc via Digitalmars-d-learn
I was building one example of DLangUi (dub build --build-mode=allAtOnce --build=debuglinker) and it did compile but the linker started to complain. I did notice it seemed to be related to the standard library, so I updated it and DRuntime to the lastest master, rebuilt them and replaced

Digital mars QT interface?

2017-12-29 Thread dark777 via Digitalmars-d-learn
I would like to know if there is any repository that uses QT to create QT creator-style programs with buttons and combobox cute?

Re: DMD Windows 64bit target - how to setup the environment?

2017-12-29 Thread realhet via Digitalmars-d-learn
Thank You for fast help! I just reply late because I wanted to try out many things. With Benjamin's list it was indeed easy to set up the environment. I also installed LDC and it worked without problems too. Made some tests about sse vectorization and it turned out that I'm in love with LDC

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Random D user via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: In C#, structs can inherit from and implement interfaces. Is that simply because it hasn't been implemented or suggested yet for D, or was there a deliberate design decision? Thanks for your insight, Mike I think it's

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 December 2017 at 13:08:38 UTC, rikki cattermole wrote: On 29/12/2017 12:59 PM, rjframe wrote: On Fri, 29 Dec 2017 12:39:25 +, Nicholas Wilson wrote: On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: The problem is that interfaces are a runtime thing (e.g.

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/12/2017 12:59 PM, rjframe wrote: On Fri, 29 Dec 2017 12:39:25 +, Nicholas Wilson wrote: On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: The problem is that interfaces are a runtime thing (e.g. you can cast a class to an interface) structs implement compile time

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Basile B. via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: In C#, structs can inherit from and implement interfaces. using System; interface IPrint { void Print(); } struct MyStruct : IPrint { public void Print() { Console.WriteLine(ToString()); } } public

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread rjframe via Digitalmars-d-learn
On Fri, 29 Dec 2017 12:39:25 +, Nicholas Wilson wrote: > On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: > > The problem is that interfaces are a runtime thing (e.g. you can cast a > class to an interface) > structs implement compile time interfaces via template duck typing

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 29, 2017 12:18:57 Mike Franklin via Digitalmars-d-learn wrote: > On Friday, 29 December 2017 at 12:11:46 UTC, rikki cattermole > > wrote: > > Structs are structs, classes are classes. > > I'm talking about interfaces, which are neither structs nor > classes. Interfaces are

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread thedeemon via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: Is that simply because it hasn't been implemented or suggested yet for D, or was there a deliberate design decision? It's a design decision. Look carefully at structs vs. classes here: https://dlang.org/spec/struct.html There

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: In C#, structs can inherit from and implement interfaces. using System; interface IPrint { void Print(); } struct MyStruct : IPrint { public void Print() { Console.WriteLine(ToString()); } } public

Re: Adding Toc for the "longish" spec pages.

2017-12-29 Thread Seb via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:13:02 UTC, Mike Franklin wrote: On Friday, 29 December 2017 at 12:06:12 UTC, tipdbmp wrote: It seems to me that some of the language reference/spec pages that are somewhat long, could provide a Toc (Table of contents) which should help users see an overview of

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Mike Franklin via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:11:46 UTC, rikki cattermole wrote: Structs are structs, classes are classes. I'm talking about interfaces, which are neither structs nor classes. C++ had the mixed model similar to what you suggested, we got it right and kept it nice and separate. This was

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread Seb via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:03:59 UTC, Mike Franklin wrote: In C#, structs can inherit from and implement interfaces. using System; interface IPrint { void Print(); } struct MyStruct : IPrint { public void Print() { Console.WriteLine(ToString()); } } public

Re: structs inheriting from and implementing interfaces

2017-12-29 Thread rikki cattermole via Digitalmars-d-learn
Structs are structs, classes are classes. C++ had the mixed model similar to what you suggested, we got it right and kept it nice and separate. This was done on purpose.

Re: Adding Toc for the "longish" spec pages.

2017-12-29 Thread Mike Franklin via Digitalmars-d-learn
On Friday, 29 December 2017 at 12:06:12 UTC, tipdbmp wrote: It seems to me that some of the language reference/spec pages that are somewhat long, could provide a Toc (Table of contents) which should help users see an overview of what's there and improve the searchability and the navigation of

Adding Toc for the "longish" spec pages.

2017-12-29 Thread tipdbmp via Digitalmars-d-learn
It seems to me that some of the language reference/spec pages that are somewhat long, could provide a Toc (Table of contents) which should help users see an overview of what's there and improve the searchability and the navigation of the content. The 'Functions' page has a Toc already.

structs inheriting from and implementing interfaces

2017-12-29 Thread Mike Franklin via Digitalmars-d-learn
In C#, structs can inherit from and implement interfaces. using System; interface IPrint { void Print(); } struct MyStruct : IPrint { public void Print() { Console.WriteLine(ToString()); } } public class Program { public static void Main() {

Re: how to localize console and GUI apps in Windows

2017-12-29 Thread zabruk70 via Digitalmars-d-learn
On Friday, 29 December 2017 at 10:35:53 UTC, Andrei wrote: Though it is not suitable for GUI type of a Windows application. AFAIK, Windows GUI have no ANSI/OEM problem. You can use Unicode. For Windows ANSI/OEM problem you can use also https://dlang.org/phobos/std_windows_charset.html

Re: how to localize console and GUI apps in Windows

2017-12-29 Thread Andrei via Digitalmars-d-learn
On Thursday, 28 December 2017 at 18:45:39 UTC, H. S. Teoh wrote: On Thu, Dec 28, 2017 at 05:56:32PM +, Andrei via Digitalmars-d-learn wrote: ... The string / wstring / dstring types in D are intended to be Unicode strings. If you need to use other encodings, you really should be using

Re: Finding unsafe line of code

2017-12-29 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 29 December 2017 at 10:23:24 UTC, codephantom wrote: On Friday, 29 December 2017 at 09:38:50 UTC, Vino wrote: Let me re-frame the question with an example, as the Dsafe the below line of code is considered as unsafe(Pointer arithmetic), ... ini[10] a; int* p = [0]; for

Re: Finding unsafe line of code

2017-12-29 Thread codephantom via Digitalmars-d-learn
On Friday, 29 December 2017 at 09:38:50 UTC, Vino wrote: Let me re-frame the question with an example, as the Dsafe the below line of code is considered as unsafe(Pointer arithmetic), so let imagine that we have several similar line of code, how do we find such unsafe line, does the

Re: Finding unsafe line of code

2017-12-29 Thread Vino via Digitalmars-d-learn
On Friday, 29 December 2017 at 09:19:13 UTC, codephantom wrote: On Friday, 29 December 2017 at 08:21:10 UTC, Vino wrote: Hi All, Is there a way to find or test which line of a give code is not safe(possible memory corruption). From, Vino.B That question needs to be refined ;-) Hi,

Re: Finding unsafe line of code

2017-12-29 Thread codephantom via Digitalmars-d-learn
On Friday, 29 December 2017 at 08:21:10 UTC, Vino wrote: Hi All, Is there a way to find or test which line of a give code is not safe(possible memory corruption). From, Vino.B That question needs to be refined ;-)

Finding unsafe line of code

2017-12-29 Thread Vino via Digitalmars-d-learn
Hi All, Is there a way to find or test which line of a give code is not safe(possible memory corruption). From, Vino.B