Re: Any way to override base type with dervived in derived type

2018-05-24 Thread IntegratedDimensions via Digitalmars-d-learn
On Friday, 25 May 2018 at 01:42:48 UTC, Basile B. wrote: On Friday, 25 May 2018 at 01:17:45 UTC, IntegratedDimensions wrote: On Friday, 25 May 2018 at 01:02:00 UTC, Basile B. wrote: On Friday, 25 May 2018 at 00:15:39 UTC, IntegratedDimensions wrote: On Thursday, 24 May 2018 at 23:31:50 UTC, Al

Re: Any way to override base type with dervived in derived type

2018-05-24 Thread Basile B. via Digitalmars-d-learn
On Friday, 25 May 2018 at 01:17:45 UTC, IntegratedDimensions wrote: On Friday, 25 May 2018 at 01:02:00 UTC, Basile B. wrote: On Friday, 25 May 2018 at 00:15:39 UTC, IntegratedDimensions wrote: On Thursday, 24 May 2018 at 23:31:50 UTC, Alex wrote: On Thursday, 24 May 2018 at 20:24:32 UTC, Integ

Re: Any way to override base type with dervived in derived type

2018-05-24 Thread IntegratedDimensions via Digitalmars-d-learn
On Friday, 25 May 2018 at 01:02:00 UTC, Basile B. wrote: On Friday, 25 May 2018 at 00:15:39 UTC, IntegratedDimensions wrote: On Thursday, 24 May 2018 at 23:31:50 UTC, Alex wrote: On Thursday, 24 May 2018 at 20:24:32 UTC, IntegratedDimensions wrote: class T; class TT : T; interface I { @pro

Re: Any way to override base type with dervived in derived type

2018-05-24 Thread Basile B. via Digitalmars-d-learn
On Friday, 25 May 2018 at 00:15:39 UTC, IntegratedDimensions wrote: On Thursday, 24 May 2018 at 23:31:50 UTC, Alex wrote: On Thursday, 24 May 2018 at 20:24:32 UTC, IntegratedDimensions wrote: class T; class TT : T; interface I { @property T t(); } abstract class A { T _t; @property T

Re: Any way to override base type with dervived in derived type

2018-05-24 Thread IntegratedDimensions via Digitalmars-d-learn
On Thursday, 24 May 2018 at 23:31:50 UTC, Alex wrote: On Thursday, 24 May 2018 at 20:24:32 UTC, IntegratedDimensions wrote: class T; class TT : T; interface I { @property T t(); } abstract class A { T _t; @property T t() { return _t; } } class C : A { // Stuff below uses t as TT

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 25, 2018 00:09:28 SrMordred via Digitalmars-d-learn wrote: > On Friday, 25 May 2018 at 00:04:10 UTC, Adam D. Ruppe wrote: > > On Thursday, 24 May 2018 at 23:55:24 UTC, SrMordred wrote: > >> //Error: @nogc delegate onlineapp.main.__lambda1 cannot call > >> non-@nogc function std.range

Re: Why char[] is not @nogc on this case

2018-05-24 Thread SrMordred via Digitalmars-d-learn
Because arrays of char and wchar are treated as ranges of dchar. That part that I didnt know, thanks! :)

Re: Why char[] is not @nogc on this case

2018-05-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 25 May 2018 at 00:04:10 UTC, Adam D. Ruppe wrote: On Thursday, 24 May 2018 at 23:55:24 UTC, SrMordred wrote: //Error: @nogc delegate onlineapp.main.__lambda1 cannot call non-@nogc function std.range.chain!(char[], char[]).chain.Result.front Why? phobos automatically decodes utf8

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 24, 2018 23:55:24 SrMordred via Digitalmars-d-learn wrote: > int[] a; > int[] b; > > ()@nogc { > foreach(v ; chain( a,b ) ) printf("%d\n", v); > }(); > > //Ok, everything fine; > > char[] a; > char[] b; > > ()@nogc { > foreach(v ; chain( a,b ) ) printf("%c\n", v); > }(); >

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 May 2018 at 23:55:24 UTC, SrMordred wrote: //Error: @nogc delegate onlineapp.main.__lambda1 cannot call non-@nogc function std.range.chain!(char[], char[]).chain.Result.front Why? phobos automatically decodes utf8 into dchars. This can throw a new utf exception.

Why char[] is not @nogc on this case

2018-05-24 Thread SrMordred via Digitalmars-d-learn
int[] a; int[] b; ()@nogc { foreach(v ; chain( a,b ) ) printf("%d\n", v); }(); //Ok, everything fine; char[] a; char[] b; ()@nogc { foreach(v ; chain( a,b ) ) printf("%c\n", v); }(); //Error: @nogc delegate onlineapp.main.__lambda1 cannot call non-@nogc function std.range.chain!(char[]

Re: Any way to override base type with dervived in derived type

2018-05-24 Thread Alex via Digitalmars-d-learn
On Thursday, 24 May 2018 at 20:24:32 UTC, IntegratedDimensions wrote: class T; class TT : T; interface I { @property T t(); } abstract class A { T _t; @property T t() { return _t; } } class C : A { // Stuff below uses t as TT but compiler, of course, treats t as T ... } Th

Re: Assigning a method name to a variable and then calling it with an object

2018-05-24 Thread aliak via Digitalmars-d-learn
On Thursday, 24 May 2018 at 23:08:29 UTC, Basile B. wrote: On Thursday, 24 May 2018 at 23:03:21 UTC, aliak wrote: Hi, I was essentially trying to do this: struct S { void f() {} } auto f = S.f; // f becomes void function(S) ?? S s; f(s); Is something like that possible? Cheers, - Ali Su

Re: Assigning a method name to a variable and then calling it with an object

2018-05-24 Thread Basile B. via Digitalmars-d-learn
On Thursday, 24 May 2018 at 23:03:21 UTC, aliak wrote: Hi, I was essentially trying to do this: struct S { void f() {} } auto f = S.f; // f becomes void function(S) ?? S s; f(s); Is something like that possible? Cheers, - Ali Sure: ``` import std.stdio; void main(string[] args) {

Assigning a method name to a variable and then calling it with an object

2018-05-24 Thread aliak via Digitalmars-d-learn
Hi, I was essentially trying to do this: struct S { void f() {} } auto f = S.f; // f becomes void function(S) ?? S s; f(s); Is something like that possible? Cheers, - Ali

Stateful modules and extern(C)

2018-05-24 Thread Arredondo via Digitalmars-d-learn
I want to call some of my D code from Python. I'm annotating the pertinent functions with extern(C) export, as in module foo; extern(C) export int initialize() { return 42; } I compile with: dmd -fPIC -shared ./foo.d From the Python end, I can load the library using ctypes and the call w

Re: UFCS syntax I never saw before.

2018-05-24 Thread aliak via Digitalmars-d-learn
On Thursday, 24 May 2018 at 22:03:38 UTC, aliak wrote: It feels like the only difference between a no-arg function that is @property and one that is not is that the former could be invoked with optional parentheses and the latter should be illegal with parentheses. Edit: err... other way arou

Re: UFCS syntax I never saw before.

2018-05-24 Thread aliak via Digitalmars-d-learn
On Tuesday, 22 May 2018 at 14:33:20 UTC, Jonathan M Davis wrote: A free function with a single argument works just fine as a setter property. e.g. you could do something like void env(Tuple!(string, string)[] str) { // set environment variables } env = [tuple("foo", "bar")]; is perfectly

Re: UFCS syntax I never saw before.

2018-05-24 Thread aliak via Digitalmars-d-learn
On Tuesday, 22 May 2018 at 13:59:16 UTC, Steven Schveighoffer wrote: The derailed plan was to leave alone the ability to call no-arg functions without parentheses, but to REQUIRE @property to call an argument-taking function with the assignment style. See the DIP here: https://wiki.dlang.org/D

Any way to override base type with dervived in derived type

2018-05-24 Thread IntegratedDimensions via Digitalmars-d-learn
class T; class TT : T; interface I { @property T t(); } abstract class A { T _t; @property T t() { return _t; } } class C : A { // Stuff below uses t as TT but compiler, of course, treats t as T ... } The issue is that I programmed the class C with a variable that directly

Re: try & catch / repeating code - DRY

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 24, 2018 19:39:07 Jacob Carlborg via Digitalmars-d-learn wrote: > On 2018-05-24 08:05, Robert M. Münch wrote: > > Hi, great! Thanks for the examples... BTW: Is there a place where such > > generic and fundamental examples are collected? > > Not as far as I know. > > >> void handle

Re: Conditionally set nothrow: for a block of code.

2018-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/18 2:51 PM, Mike Franklin wrote: Given that the PR above is for object.d, I can't turn the entire object.d source file into a string and conditionally mix that in.  Does anyone have a solution to this? My recommendation would have been the last one, but if that doesn't work, I don't

Conditionally set nothrow: for a block of code.

2018-05-24 Thread Mike Franklin via Digitalmars-d-learn
I'm trying to find a way to declare a block of code `nothrow:` when compiling with -betterC, but not `nothrow` when not compiling with -betterC. The solution is needed for this PR: https://github.com/dlang/druntime/pull/2184/files#r188627707 Attempt #1 -- void test() { } version(D_

Re: Translate C/C++ patern: return a pointer

2018-05-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-05-24 11:10, biocyberman wrote: Thanks for the hints. `Read` in C++ and D are both classes. And the function is inside the class definition itself. In that case specifying the type as `Read` is the correct thing to do. Note that `new` always allocates on the heap and returns a pointer

Re: try & catch / repeating code - DRY

2018-05-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-05-24 08:05, Robert M. Münch wrote: Hi, great! Thanks for the examples... BTW: Is there a place where such generic and fundamental examples are collected? Not as far as I know. void handleException1(alias dg)() { try dg(); catch (Exception e) { /* handle exception */ } } v

Re: return type of std.algorithm.mutation.reverse changed for good?

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Thursday, 24 May 2018 at 12:34:38 UTC, Steven Schveighoffer wrote: On 5/24/18 8:08 AM, rikki cattermole wrote: On 25/05/2018 12:06 AM, biocyberman wrote: I am testing with DMD 2.078.2 locally. This tiny snippet works on dlang's online editor: https://run.dlang.io/is/nb4IV4 But it does not

Re: return type of std.algorithm.mutation.reverse changed for good?

2018-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/18 8:08 AM, rikki cattermole wrote: On 25/05/2018 12:06 AM, biocyberman wrote: I am testing with DMD 2.078.2 locally. This tiny snippet works on dlang's online editor: https://run.dlang.io/is/nb4IV4 But it does not work on my local dmd. import std.algorithm.mutation; import std.stdio;

return type of std.algorithm.mutation.reverse changed for good?

2018-05-24 Thread biocyberman via Digitalmars-d-learn
I am testing with DMD 2.078.2 locally. This tiny snippet works on dlang's online editor: https://run.dlang.io/is/nb4IV4 But it does not work on my local dmd. import std.algorithm.mutation; import std.stdio; char[] arr = "hello\U00010143\u0100\U00010143".dup; writeln(arr.reverse); Error: templa

Re: return type of std.algorithm.mutation.reverse changed for good?

2018-05-24 Thread rikki cattermole via Digitalmars-d-learn
On 25/05/2018 12:06 AM, biocyberman wrote: I am testing with DMD 2.078.2 locally. This tiny snippet works on dlang's online editor: https://run.dlang.io/is/nb4IV4 But it does not work on my local dmd. import std.algorithm.mutation; import std.stdio; char[] arr = "hello\U00010143\u0100\U0001014

Re: Deleting a file with extsion *.FIFO in Windows

2018-05-24 Thread bauss via Digitalmars-d-learn
On Thursday, 24 May 2018 at 06:59:47 UTC, Vino wrote: Hi All, Request your help on how to delete a file which has the extension .fifo (.javast.fifo) in Windows. From, Vino.B What exactly is your issue with it?

Re: UDA and static struct fields

2018-05-24 Thread bauss via Digitalmars-d-learn
On Thursday, 24 May 2018 at 10:42:26 UTC, Andrea Fontana wrote: On Thursday, 24 May 2018 at 10:23:41 UTC, Andrea Fontana wrote: On Thursday, 24 May 2018 at 09:17:10 UTC, Alex wrote: On Thursday, 24 May 2018 at 08:48:30 UTC, Andrea Fontana wrote: This line: mixin("alias tmp = " ~ s ~ ";

Re: UDA and static struct fields

2018-05-24 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 24 May 2018 at 10:23:41 UTC, Andrea Fontana wrote: On Thursday, 24 May 2018 at 09:17:10 UTC, Alex wrote: On Thursday, 24 May 2018 at 08:48:30 UTC, Andrea Fontana wrote: This line: mixin("alias tmp = " ~ s ~ ";"); There's no mention of Symbol in there. If you change it to

Re: UDA and static struct fields

2018-05-24 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 24 May 2018 at 09:17:10 UTC, Alex wrote: On Thursday, 24 May 2018 at 08:48:30 UTC, Andrea Fontana wrote: This line: mixin("alias tmp = " ~ s ~ ";"); There's no mention of Symbol in there. If you change it to this: mixin("alias tmp = Symbol" ~ s ~ ";"); then sudden

Re: UDA and static struct fields

2018-05-24 Thread Alex via Digitalmars-d-learn
On Thursday, 24 May 2018 at 08:48:30 UTC, Andrea Fontana wrote: This line: mixin("alias tmp = " ~ s ~ ";"); There's no mention of Symbol in there. If you change it to this: mixin("alias tmp = Symbol" ~ s ~ ";"); then suddenly things work. -- Simen What? a dot is missing,

Re: Translate C/C++ patern: return a pointer

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Thursday, 24 May 2018 at 08:58:02 UTC, Nicholas Wilson wrote: On Thursday, 24 May 2018 at 08:16:30 UTC, biocyberman wrote: [...] it looks like Read is a D class? in which case it already returns by reference. If you make Read a struct then all you need do is change the function signature

Re: Translate C/C++ patern: return a pointer

2018-05-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 24 May 2018 at 08:16:30 UTC, biocyberman wrote: Some C and C++ projects I am working on use pointers and references extensively: to pass as function arguments, and to return from a function. For function argument I would use `ref`, but for return types, I can't use `ref` and can't

Re: Efficient idiom for fastest code

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 03:12:52 UTC, IntegratedDimensions wrote: On Wednesday, 23 May 2018 at 03:00:17 UTC, Nicholas Wilson wrote: [...] I knew someone was going to say that and I forgot to say DON'T! Saying to profile when I clearly said these ARE cases where they are slow is just mor

Re: UDA and static struct fields

2018-05-24 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 24 May 2018 at 07:59:08 UTC, Simen Kjærås wrote: On Thursday, 24 May 2018 at 07:47:54 UTC, Andrea Fontana wrote: Is this a bug or am I missing something? https://run.dlang.io/is/OGHJYX Andrea This line: mixin("alias tmp = " ~ s ~ ";"); There's no mention of Symbol in th

Translate C/C++ patern: return a pointer

2018-05-24 Thread biocyberman via Digitalmars-d-learn
Some C and C++ projects I am working on use pointers and references extensively: to pass as function arguments, and to return from a function. For function argument I would use `ref`, but for return types, I can't use `ref` and can't return a pointer. What should be the proper way to handle thi

Re: UDA and static struct fields

2018-05-24 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 24 May 2018 at 07:47:54 UTC, Andrea Fontana wrote: Is this a bug or am I missing something? https://run.dlang.io/is/OGHJYX Andrea This line: mixin("alias tmp = " ~ s ~ ";"); There's no mention of Symbol in there. If you change it to this: mixin("alias tmp = Symbol

UDA and static struct fields

2018-05-24 Thread Andrea Fontana via Digitalmars-d-learn
Is this a bug or am I missing something? https://run.dlang.io/is/OGHJYX Andrea

Deleting a file with extsion *.FIFO in Windows

2018-05-24 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to delete a file which has the extension .fifo (.javast.fifo) in Windows. From, Vino.B