Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 03:38:03 UTC, Mike Parker wrote: On Wednesday, 13 July 2016 at 02:49:54 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: What happens when you declare an interface that extends from IUnknown (and not extern(C++)), then cast

Re: C++ interface vs D and com

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:49:54 UTC, Adam Sansier wrote: On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: What happens when you declare an interface that extends from IUnknown (and not extern(C++)), then cast the pointer returned from the COM API? It should just work with

Re: adding toString to struct

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:29:12 UTC, Jesse Phillips wrote: On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: windows libs have a lot of structs and it would be nice to have the ability to convert them to a string to see them in the debugger(e.g., CLSID). Is there a way to d

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:34:14 UTC, Mike Parker wrote: On Tuesday, 12 July 2016 at 23:55:55 UTC, Adam Sansier wrote: Ok, Another hack: iInterface x; void** y = cast(void**)&x; *y = malloc(iInterface.sizeof);

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 02:25:35 UTC, Jesse Phillips wrote: On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link th

Re: core.stdc.config

2016-07-12 Thread Luís Marques via Digitalmars-d-learn
On Thursday, 30 January 2014 at 03:28:57 UTC, Craig Dillabaugh wrote: So, there is a module core.stdc.config (referenced here): http://dlang.org/interfaceToC.html That is presumably part of the D Standard library. I am curious to know why no mention of this library is included at: http://dl

Re: C++ interface vs D and com

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 23:55:55 UTC, Adam Sansier wrote: Ok, Another hack: iInterface x; void** y = cast(void**)&x; *y = malloc(iInterface.sizeof); x.__vptr = cast(immutable(void*)*)(*ptr); x.

Re: C++ interface vs D and com

2016-07-12 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link them up so I can call the functions? I marked the interface extern

Re: adding toString to struct

2016-07-12 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: windows libs have a lot of structs and it would be nice to have the ability to convert them to a string to see them in the debugger(e.g., CLSID). Is there a way to do this? I've tried to pull out the code from the libs but it if a

Re: how to mark an extern function @nogc?

2016-07-12 Thread anonymous via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:04:55 UTC, Seb wrote: D is entirely driven by highly motivated volunteers. (this will change soon with the new D foundation) With the fundation, volunteers wont be highly motivated anymore. Fundations are real motivation-killers.

Re: How to open file with exclusive lock?

2016-07-12 Thread Charles Hixson via Digitalmars-d-learn
On 07/12/2016 03:54 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jul 12, 2016 at 03:40:36PM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] OK. It's not possible without OS support. Agreed. And I don't want to get into C calls, but rather to use the mechanisms that D prov

Re: I can has @nogc and throw Exceptions?

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Friday, 13 February 2015 at 21:08:58 UTC, Marc Schütz wrote: On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath wrote: 1. Throw preallocated exceptions is the way to go ... and because noone has yet shown an explicit example: void myThrowingNogcFunc() @nogc { static c

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 22:55:05 UTC, Adam Sansier wrote: So, the problem now, is how to take the interface, which is simple, no implementation, and either create the implementation or create a sort of simple empty proxy that can be used to instantiate the interface? I mean automaticall

Re: how to mark an extern function @nogc?

2016-07-12 Thread sarn via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:04:55 UTC, Seb wrote: D is entirely driven by highly motivated volunteers. (this will change soon with the new D foundation) I for one welcome our new D Foundation overlords.

Re: How to open file with exclusive lock?

2016-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 12, 2016 at 03:40:36PM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] > OK. It's not possible without OS support. Agreed. And I don't want > to get into C calls, but rather to use the mechanisms that D provides. > And this *probably* won't cause any problems. But how sh

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
So, the problem now, is how to take the interface, which is simple, no implementation, and either create the implementation or create a sort of simple empty proxy that can be used to instantiate the interface? I mean automatically of course. I believe D already has some library solution for

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 22:01:41 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 21:21:04 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 15:12:21 UTC, Lodovico Giaretta wrote: I'm not an expert in this field, but did you read this[1]? [1] https://dlang.org/spec/interface.h

Re: How to open file with exclusive lock?

2016-07-12 Thread Charles Hixson via Digitalmars-d-learn
On 07/12/2016 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jul 12, 2016 at 11:54:18AM -0700, Charles Hixson via Digitalmars-d-learn wrote: I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode, and desir

Re: C++ interface vs D and com

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 21:21:04 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 15:12:21 UTC, Lodovico Giaretta wrote: I'm not an expert in this field, but did you read this[1]? [1] https://dlang.org/spec/interface.html#com-interfaces Yes, of course... Well, I asked because you s

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:13:02 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: I marked the interface extern(C++) so it's a C++ style interface. The first field of a COM object is a pointer to its vtable. If it is a COM interface, you should make

Re: C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:12:21 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link t

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 18:52:08 UTC, Meta wrote: On Tuesday, 12 July 2016 at 04:23:07 UTC, Adam Sansier wrote: Now, I could simply make Do a template method but then this prevents it being a virtual function. void Do(T)(T name) if (is(T == string) || is(T == int)) { Init_Data();

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 17:17:31 UTC, Kagamin wrote: On Tuesday, 12 July 2016 at 16:30:05 UTC, Adam Sansier wrote: Doesn't matter, it's not what I asked. Yeah, I'm not confident I understood your problem right. You can try to describe your problem better. Criteria: 1. At most 2 one par

Re: How to open file with exclusive lock?

2016-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 12, 2016 at 11:54:18AM -0700, Charles Hixson via Digitalmars-d-learn wrote: > I want to open a file with an exclusive lock. It would be important > that no other thread be able to access the file in write mode, and > desirable that no other thread be able to access the file in read >

Re: How to open file with exclusive lock?

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 18:54:18 UTC, Charles Hixson wrote: I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode, and desirable that no other thread be able to access the file in read mode. (Ditto for other proce

Re: Simple overloading without complications

2016-07-12 Thread Meta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 18:52:08 UTC, Meta wrote: On Tuesday, 12 July 2016 at 04:23:07 UTC, Adam Sansier wrote: Now, I could simply make Do a template method but then this prevents it being a virtual function. void Do(T)(T name) if (is(T == string) || is(T == int)) { Init_Data();

Re: Simple overloading without complications

2016-07-12 Thread Meta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 04:23:07 UTC, Adam Sansier wrote: Now, I could simply make Do a template method but then this prevents it being a virtual function. void Do(T)(T name) if (is(T == string) || is(T == int)) { Init_Data(); static if (is(T == string)) { ...Get index

How to open file with exclusive lock?

2016-07-12 Thread Charles Hixson via Digitalmars-d-learn
I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode, and desirable that no other thread be able to access the file in read mode. (Ditto for other processes.) stdio.file.lock (or is it stdio.file.File.lock?) seems t

Re: How can you call a stored function in an AA with proper number of arguments converted to the proper type?

2016-07-12 Thread Zekereth via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 08:34:03 UTC, Kagamin wrote: Store a wrapper instead of the actual function: void wrapper(alias F)(string[] args) { (convert args to F arguments) and invoke } cmd.func = &wrapper!someFunc; string[] args; cmd.func(args); Thanks that is clever. Never would have tho

Re: Simple overloading without complications

2016-07-12 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:30:05 UTC, Adam Sansier wrote: Doesn't matter, it's not what I asked. Yeah, I'm not confident I understood your problem right. You can try to describe your problem better.

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:42:52 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 16:30:05 UTC, Adam Sansier wrote: Doesn't matter, it's not what I asked. Trying to provide answers to a question that wasn't asked and was clearly stated I wasn't interested in those types of answers.

Re: Simple overloading without complications

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:27:52 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 13:54:16 UTC, Lodovico Giaretta Also note that yield semantics as available in various languages is much different from what you are proposing here. Not really. Yield is usually a break in flow, regardles

Re: Where does one post a proposal for a language change?

2016-07-12 Thread Mathias Lang via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:45:18 UTC, DLearner wrote: General/Issues/or... P.R. to this repository: https://github.com/dlang/DIPs

Where does one post a proposal for a language change?

2016-07-12 Thread DLearner via Digitalmars-d-learn
General/Issues/or...

Re: Simple overloading without complications

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:30:05 UTC, Adam Sansier wrote: Doesn't matter, it's not what I asked. Trying to provide answers to a question that wasn't asked and was clearly stated I wasn't interested in those types of answers. Every language has its own ways of solving various problems. We a

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 16:03:15 UTC, Kagamin wrote: On Tuesday, 12 July 2016 at 13:44:02 UTC, Adam Sansier wrote: I don't like it, creates an extra function for no apparent reason except to get around the problem of not having a yield type of semantic. Again, I wasn't asking for any ol' so

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 13:54:16 UTC, Lodovico Giaretta wrote: On Tuesday, 12 July 2016 at 13:44:02 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 08:52:26 UTC, Kagamin wrote: Extract functions for shared parts: void Do(string name) { DoStuff(); int i = find(name); DoStuf

Re: Simple overloading without complications

2016-07-12 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 13:44:02 UTC, Adam Sansier wrote: I don't like it, creates an extra function for no apparent reason except to get around the problem of not having a yield type of semantic. Again, I wasn't asking for any ol' solution, there are many ways to skin this cat. It's a no

Re: adding toString to struct

2016-07-12 Thread John via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:51:43 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 14:27:49 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: Is there a way to do this? write a new function that prints them and call that This doesn't work to disp

Re: [OT] Re: how to mark an extern function @nogc?

2016-07-12 Thread Seb via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:42:23 UTC, ag0aep6g wrote: On 07/12/2016 04:04 PM, Seb wrote: D is entirely driven by highly motivated volunteers. (this will change soon with the new D foundation) Does the foundation have plans to hire programmers? That's news to me. At the DConf16 Andrei

Re: structure alignment

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:08:29 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 14:54:25 UTC, Adam Sansier wrote: Um, because that's the way they were defined! So your telling me that D is going to make me mark every member align(n) when C++ has a global pragma align that does it for

Re: C++ interface vs D and com

2016-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: I marked the interface extern(C++) so it's a C++ style interface. The first field of a COM object is a pointer to its vtable. If it is a COM interface, you should make it a COM interface by inheriting from IUnknown. http://dlang

Re: C++ interface vs D and com

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote: So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link them up so I can call the functions? I marked the interface extern

C++ interface vs D and com

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
So, com throughs me a interface ptr and I need to map it to an interface. When I do, I get an access violation. I have an (com) ptr and an interface. How do I link them up so I can call the functions? I marked the interface extern(C++) so it's a C++ style interface. The first field of a COM

Re: structure alignment

2016-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:54:25 UTC, Adam Sansier wrote: Um, because that's the way they were defined! So your telling me that D is going to make me mark every member align(n) when C++ has a global pragma align that does it for all in the scope? This is trivial, just add it to the binding

Re: structure alignment

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:26:54 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 00:20:31 UTC, Adam Sansier wrote: I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous. Why are these structs needing t

Re: adding toString to struct

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 14:27:49 UTC, Adam D. Ruppe wrote: On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: Is there a way to do this? write a new function that prints them and call that This doesn't work to display them in visual D though. Requires a lot of hoops just to s

[OT] Re: how to mark an extern function @nogc?

2016-07-12 Thread ag0aep6g via Digitalmars-d-learn
On 07/12/2016 04:04 PM, Seb wrote: D is entirely driven by highly motivated volunteers. (this will change soon with the new D foundation) Does the foundation have plans to hire programmers? That's news to me.

Re: adding toString to struct

2016-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 05:16:30 UTC, Adam Sansier wrote: Is there a way to do this? write a new function that prints them and call that

Re: structure alignment

2016-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 00:20:31 UTC, Adam Sansier wrote: I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous. Why are these structs needing the alignment? From what I've read, align(n){ struct x; } only a

Re: how to mark an extern function @nogc?

2016-07-12 Thread Seb via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 00:17:32 UTC, Adam Sansier wrote: On Monday, 11 July 2016 at 15:54:02 UTC, Seb wrote: On Monday, 11 July 2016 at 01:59:51 UTC, Adam Sansier wrote: On Monday, 11 July 2016 at 01:58:23 UTC, Adam Sansier wrote: I'm using some win functions that don't use the gc and are

Re: Associative Array c'tor

2016-07-12 Thread ketmar via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 13:56:49 UTC, cym13 wrote: I'm with Steven here, that's definitely too surprising, initialization should not be linked to clear in any way. feel free to change/improve it. for me it is logical, but i'm often found that i am the only one who agrees with my logic. ;-)

Re: Associative Array c'tor

2016-07-12 Thread cym13 via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 13:01:20 UTC, ketmar wrote: On Tuesday, 12 July 2016 at 12:34:40 UTC, Steven Schveighoffer wrote: There was a suggestion to make .clear (a relatively new feature) actually preallocate if it's currently null, but I didn't want to do allocating in that method (too surp

Re: Passing ranges around

2016-07-12 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 12, 2016 at 06:37:35AM +, Mike Parker via Digitalmars-d-learn wrote: > On Tuesday, 12 July 2016 at 03:57:09 UTC, Bahman Movaqar wrote: > > What should be signature of `foo` in the following piece of code? > > > > auto foo(range r) { > > // do something with the `r` > >

Re: Simple overloading without complications

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 13:44:02 UTC, Adam Sansier wrote: On Tuesday, 12 July 2016 at 08:52:26 UTC, Kagamin wrote: Extract functions for shared parts: void Do(string name) { DoStuff(); int i = find(name); DoStuffWithIndex(i); } void Do(int name) { DoStuff(); DoStuffWith

Re: Simple overloading without complications

2016-07-12 Thread Adam Sansier via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 08:52:26 UTC, Kagamin wrote: Extract functions for shared parts: void Do(string name) { DoStuff(); int i = find(name); DoStuffWithIndex(i); } void Do(int name) { DoStuff(); DoStuffWithIndex(i); } I don't like it, creates an extra function for no

Re: Associative Array c'tor

2016-07-12 Thread ketmar via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 12:34:40 UTC, Steven Schveighoffer wrote: There was a suggestion to make .clear (a relatively new feature) actually preallocate if it's currently null, but I didn't want to do allocating in that method (too surprising). I do think it would be nice to have an initiali

Re: Associative Array c'tor

2016-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/16 5:42 AM, ketmar wrote: On Tuesday, 12 July 2016 at 03:38:44 UTC, Bahman Movaqar wrote: Now I understand. This is tricky --could introduce hard to find bugs. Is there anyway to make sure it doesn't happen? Such as giving the AA a default empty value on the declaration line --like `st

Re: Is this a bug ?

2016-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/16 1:31 AM, Chang Long wrote: On Tuesday, 12 July 2016 at 04:38:42 UTC, Chang Long wrote: test.d = template newType(size_t N){ class NewType { enum Type = N ; } } just find it should be this: template newType(size_t N){ cl

Re: sorting std.container

2016-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/16 1:05 AM, WhatMeWorry wrote: On Monday, 11 July 2016 at 19:07:51 UTC, ketmar wrote: list slices are not random-access ranges, thus they can't be sorted in-place (this is what std.algorithm.sort does). so the only way is to convert list to array, sort it, and make a list from sorted arr

Re: Docs for `Group` type

2016-07-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/12/2016 04:21 PM, Edwin van Leeuwen wrote: > On Tuesday, 12 July 2016 at 11:40:48 UTC, Bahman Movaqar wrote: >> On 07/12/2016 01:01 PM, Mike Parker wrote: >>> Do you have some sample code that shows the error? >> >> Yes. I'm working on Stockman[1] a playground to learn D. >> In file `etl.d`,

Re: aspects on methods?

2016-07-12 Thread ketmar via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 11:26:20 UTC, jj75607 wrote: you can't. there is no AST macros in D, so you can't rewrite parsed source.

Re: Docs for `Group` type

2016-07-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/12/2016 04:23 PM, ag0aep6g wrote: > On 07/12/2016 01:40 PM, Bahman Movaqar wrote: >> Yes. I'm working on Stockman[1] a playground to learn D. >> In file `etl.d`, line 110 [2], if I change the line to >> auto refInvoice = group[1].takeOne(); >> the file will not compile. I have attached

Re: Docs for `Group` type

2016-07-12 Thread ag0aep6g via Digitalmars-d-learn
On 07/12/2016 01:40 PM, Bahman Movaqar wrote: Yes. I'm working on Stockman[1] a playground to learn D. In file `etl.d`, line 110 [2], if I change the line to auto refInvoice = group[1].takeOne(); the file will not compile. I have attached the compile error to this message. Do you also ad

Re: Docs for `Group` type

2016-07-12 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 11:40:48 UTC, Bahman Movaqar wrote: On 07/12/2016 01:01 PM, Mike Parker wrote: Do you have some sample code that shows the error? Yes. I'm working on Stockman[1] a playground to learn D. In file `etl.d`, line 110 [2], if I change the line to auto refInvoice = g

Re: Docs for `Group` type

2016-07-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/12/2016 01:01 PM, Mike Parker wrote: > Do you have some sample code that shows the error? Yes. I'm working on Stockman[1] a playground to learn D. In file `etl.d`, line 110 [2], if I change the line to auto refInvoice = group[1].takeOne(); the file will not compile. I have attached the

Re: aspects on methods?

2016-07-12 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 11:26:20 UTC, jj75607 wrote: I want to use aspect-like annotations to transform @Lockable class Abc { @sync void f() { writeln("f"); } @shared void g() { writeln("g"); } } to something like: class Ab

aspects on methods?

2016-07-12 Thread jj75607 via Digitalmars-d-learn
I want to use aspect-like annotations to transform @Lockable class Abc { @sync void f() { writeln("f"); } @shared void g() { writeln("g"); } } to something like: class Abc { shared(ReadWriteMutex) _lock123; this()

Re: local const functions - bug ?

2016-07-12 Thread Marc Schütz via Digitalmars-d-learn
On Sunday, 10 July 2016 at 07:20:29 UTC, Meta wrote: On Friday, 8 July 2016 at 09:01:10 UTC, Marc Schütz wrote: `foo()` is effectively a delegate, therefore `const` applies to the context. AFAIK const on a function can only ever refer to the `this` pointer, but there is no `this` pointer. T

Re: @safe fun alayws call @system function?

2016-07-12 Thread Dsby via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 09:17:37 UTC, ag0aep6g wrote: On 07/12/2016 11:09 AM, Dsby wrote: How can i call @system function in a @safe function? You can't. You can mark the @safe function @trusted [1] instead. @trusted functions are considered memory-safe by the compiler and can be called

Re: Associative Array c'tor

2016-07-12 Thread ketmar via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 03:38:44 UTC, Bahman Movaqar wrote: Now I understand. This is tricky --could introduce hard to find bugs. Is there anyway to make sure it doesn't happen? Such as giving the AA a default empty value on the declaration line --like `string[int] a = []`? no. the onl

Re: @safe fun alayws call @system function?

2016-07-12 Thread ag0aep6g via Digitalmars-d-learn
On 07/12/2016 11:09 AM, Dsby wrote: How can i call @system function in a @safe function? You can't. You can mark the @safe function @trusted [1] instead. @trusted functions are considered memory-safe by the compiler and can be called from @safe code, but they can use @system features and call

@safe fun alayws call @system function?

2016-07-12 Thread Dsby via Digitalmars-d-learn
How can i call @system function in a @safe function?

Re: Simple overloading without complications

2016-07-12 Thread Kagamin via Digitalmars-d-learn
Extract functions for shared parts: void Do(string name) { DoStuff(); int i = find(name); DoStuffWithIndex(i); } void Do(int name) { DoStuff(); DoStuffWithIndex(i); }

Re: How can you call a stored function in an AA with proper number of arguments converted to the proper type?

2016-07-12 Thread Kagamin via Digitalmars-d-learn
Store a wrapper instead of the actual function: void wrapper(alias F)(string[] args) { (convert args to F arguments) and invoke } cmd.func = &wrapper!someFunc; string[] args; cmd.func(args);

Re: Passing ranges around

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 07:50:34 UTC, Bahman Movaqar wrote: On 07/12/2016 11:07 AM, Mike Parker wrote: auto foo(R)(R r) { ... } That did it. Thanks. Out of curiosity, does the same pattern apply to functions which take `tuple`s as input arguments? It's just a function template. It's w

Re: Docs for `Group` type

2016-07-12 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 08:03:53 UTC, Bahman Movaqar wrote: On 07/12/2016 11:06 AM, Mike Parker wrote: The 'Group' type is an implementation detail -- a type used internally -- that you aren't supposed to care about. All you need to care about is that it's a range. The documentation for ch

Re: Docs for `Group` type

2016-07-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/12/2016 11:06 AM, Mike Parker wrote: > The 'Group' type is an implementation detail -- a type used internally > -- that you aren't supposed to care about. All you need to care about is > that it's a range. The documentation for chunkBy [1] explains what the > return type is. > > [1] https://

Re: Passing ranges around

2016-07-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/12/2016 11:07 AM, Mike Parker wrote: > auto foo(R)(R r) { ... } That did it. Thanks. Out of curiosity, does the same pattern apply to functions which take `tuple`s as input arguments? -- Bahman