Multiple alias this is coming.
I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it.
Re: Multiple alias this is coming.
On 18/09/2014 11:20 p.m., IgorStepanov wrote: I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it. Awesome was waiting for something like this! Also did we ever consider alias this = ...; syntax?
Re: Multiple alias this is coming.
On Thursday, 18 September 2014 at 12:51:48 UTC, Rikki Cattermole wrote: On 18/09/2014 11:20 p.m., IgorStepanov wrote: I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it. Awesome was waiting for something like this! Also did we ever consider alias this = ...; syntax? It clashes with (not yet supported) aliasing of constructors.
Re: 438-byte Hello, world Win32 EXE in D
On Thursday, 18 September 2014 at 04:50:52 UTC, dcrepid wrote: On Wednesday, 17 September 2014 at 20:49:37 UTC, Vladimir Panteleev wrote: Yes, sorry, that was the wrong command. Currently you have to also specify the full paths to the compiler on make's command line. I sent in two pull requests to document and simplify building phobos32mscoff.lib: https://github.com/D-Programming-Language/druntime/pull/960 https://github.com/D-Programming-Language/phobos/pull/2526 Thanks, I tried merging the modifications into the 'win32mscoff.mak' files I've made, since it seems like there's too much hacking to get this to work right, and why not just have a 3rd build option that reflects what it really makes? You mean yet another makefile? It's onerous enough already to duplicate all makefile changes across the current set. Yet another makefile for a rarely-used configuration wouldn't pull its own weight. Perhaps this is an issue with the current beta, but I'm not experienced enough with make files or versioning etc to make that determination. It sounds like whatever version you have doesn't yet have the necessary Phobos/Druntime changes. You should try building from the git version.
Re: Multiple alias this is coming.
On Thursday, 18 September 2014 at 18:38:57 UTC, Ali Çehreli wrote: On 09/18/2014 04:20 AM, IgorStepanov wrote: I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it. Awesome! This is the feature that I thought would never get implemented. :) Ali No, these are rvalue references. ;)
Re: Multiple alias this is coming.
IgorStepanov: I've created pull request, which introduces multiple alias this. Can someone show one or more usage cases? Thank you, bye, bearophile
Re: Multiple alias this is coming.
On Thursday, 18 September 2014 at 19:52:42 UTC, bearophile wrote: IgorStepanov: I've created pull request, which introduces multiple alias this. Can someone show one or more usage cases? Thank you, bye, bearophile Do you ask about alias this or about it multiple usage. Multiple usage is similar to single, but multiple:) struct Foo { string s; int i; alias s this; alias i this; } Foo f = {foo, 42}; string s = f; //s == foo int i = f; //i == 42 If there are many different ways to resolve alias this then error is raised: struct Bar { double d; int i; alias d this; alias i this; } Foo f = {1.0, 42}; double d = f; //Error: compiler doesn't know, f.d or f.i do you want. In the next expamle, compiler can resolve conflict: struct Base1 { int i; alias i this; } struct Base2 { int i; alias i this; } struct Derived { Base1 b1; Base2 b2; int i; alias b1 this; alias b2 this; alias i this; } Derived d = Derived(Base1(1), Base2(2), 3); int i = d; //i == 3; This done because Derived author know, how to cast his struct to int, and if he say alias i this; this alias hide aliases in base types. However, if base type contains alias this to another acceptable type, and derived typ hasn't exactly castable alias this then error will be raised: struct Base1 { short s; alias s this; } struct Base2 { int i; alias i this; } struct Derived { Base1 b1; Base2 b2; int i; alias b1 this; alias b2 this; alias i this; } Derived d = Derived(Base1(1), Base2(2), 3); int i = d; //Ok i == 3; long l = d; //Error: what do you want? d.i or d.b1.s? For additional info you can see examples in my pull request.
Re: Multiple alias this is coming.
On Thursday, 18 September 2014 at 11:20:49 UTC, IgorStepanov wrote: I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it. Exciting! What more good things than a better behaving Nullable(T) with T being a polymorphic class will this enable?
Re: Multiple alias this is coming.
IgorStepanov: Do you ask about alias this or about it multiple usage. Multiple usage is similar to single, but multiple:) I meant the multiple usage. And none of your examples here are use cases :-( I'd like to see one use case, or more. Bye, bearophile
Re: Multiple alias this is coming.
On 09/18/2014 12:52 PM, bearophile wrote: Can someone show one or more usage cases? I can't claim that I have experience with multiple alias this ;) but I like the following example that I had come up with: class TeachingAssistant { Student studentIdentity; Teacher teacherIdentity; this(string name, string subject) { this.studentIdentity = new Student(name); this.teacherIdentity = new Teacher(name, subject); } /* The following two 'alias this' declarations will enable * this type to be used both as a Student and as a Teacher. */ alias teacherIdentity this; alias studentIdentity this; } Ali [1] http://ddili.org/ders/d.en/alias_this.html
Re: Multiple alias this is coming.
On Thu, 18 Sep 2014 15:20:04 -0700 Ali Çehreli via Digitalmars-d-announce digitalmars-d-announce@puremagic.com wrote: [1] http://ddili.org/ders/d.en/alias_this.html heh, i just wanted to point at your book. ;-) signature.asc Description: PGP signature
Re: Multiple alias this is coming.
On Thursday, 18 September 2014 at 22:16:23 UTC, bearophile wrote: IgorStepanov: Do you ask about alias this or about it multiple usage. Multiple usage is similar to single, but multiple:) I meant the multiple usage. And none of your examples here are use cases :-( I'd like to see one use case, or more. Bye, bearophile For example, you can define struct (value-type with automatic storage class) which implements interfaces: intarface InputStream { ... } intarface OutputStream { ... } struct File { this(string name, string options) { impl = new FileImpl(name, options); } ~this() { impl.close(); } @property InputStream inputStream() { return new class(impl) InputStream { //InputStream implementation ... } } @property OutputStream outputStream() { return new class(impl) OutputStream { //OutputStream implementation ... } } alias inputStream this; alias seekable this; FileImpl* impl; } Record[] readData(InputStream); void storeData(OutputStream, Record[]); Record[] extractRecords() { File f = File(records.bin, rw); auto data = readData(f); ///split to extracted and remaining f.truncate(); writeData(f, remaining); return extracted; }
Digger 1.0
Most notable change since DConf is that on Windows, Digger can now build D from source (including x64 versions) without requiring Git or Visual Studio to be installed. It achieves this by downloading and locally installing (unpacking) all the software it needs. Windows binaries: https://github.com/CyberShadow/Digger/releases/tag/1.0 Digger is a tool for working with D's source code and its history. It can build D (including older D versions), customize the build with pending pull requests or forks, and find the exact pull request which introduced a regression (or fixed a bug). It comes together with a web interface which makes building D from source trivial even for people new to D, Git or the command line. https://github.com/CyberShadow/Digger
Re: Multiple alias this is coming.
On Thursday, 18 September 2014 at 11:20:49 UTC, IgorStepanov wrote: I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it. What is the policy to resolve conflict ? BTW, SDC already have multiple alias this :)