Mimicking Java's Type Erasure

2019-11-03 Thread Superstar64 via Digitalmars-d-learn
Consider the following Java code. -- import java.util.function.Function; public class Main{ //basic Rank2 type static interface Stringer{ String show(Function type, A that); } static class Say implements Stringer { public String show(Function type, A that){

Re: Mimicking Java's Type Erasure

2019-11-03 Thread Superstar64 via Digitalmars-d-learn
On Monday, 4 November 2019 at 01:25:36 UTC, Heromyth wrote: On Monday, 4 November 2019 at 00:16:53 UTC, Superstar64 wrote: Consider the following Java code. -- import java.util.function.Function; public class Main{ //basic Rank2 type static interface Stringer{ String show(Funct

Allocating an empty non null associative arary

2020-03-30 Thread Superstar64 via Digitalmars-d-learn
I want to be modify an associative array by reference from another function. However null associative arrays are pass by value. How do I generically create an empty associative array? --- import std.stdio; void addElement(int[int] data){ data[0] = 0; } void nonempty() { int[in

Re: Allocating an empty non null associative arary

2020-03-31 Thread Superstar64 via Digitalmars-d-learn
On Tuesday, 31 March 2020 at 06:51:16 UTC, WebFreak001 wrote: This doesn't only happen with null, you will notice that that function will eventually not add anything if you only add values. This is because by adding values you might reallocate the map at some other place in memory and because i

overriding alias symbols

2016-10-12 Thread Superstar64 via Digitalmars-d-learn
I'm trying to use mixin templetes to provide generic default implementations. Something like this: --- abstract class MyAbstractClass { void myAbstractMethod(); } mixin template defaultImplentation(alias Method, T...) { override void Method() { } } class MyClass : MyAbstractClas

Re: overriding alias symbols

2016-10-12 Thread Superstar64 via Digitalmars-d-learn
On Wednesday, 12 October 2016 at 22:46:14 UTC, Stefan Koch wrote: override void mixin (__traits(identifier, Method)) ... ? Doesn't work: test.d(8): Error: no identifier for declarator void test.d(9): Error: found '{' when expecting ')' test.d(10): Error: found '}' when expecting ';' I could mak

Re: overriding alias symbols

2016-10-12 Thread Superstar64 via Digitalmars-d-learn
On Wednesday, 12 October 2016 at 22:14:32 UTC, Superstar64 wrote: ... Nevermind I just realized I can do this: --- abstract class MyAbstractClass { void myAbstractMethod(); } void defaultImplentation(T...) { } class MyClass : MyAbstractClass { override void myAbstractMethod() {