Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 07, 2012 Remus | ||||
---|---|---|---|---|
| ||||
Hi, I'd like to present you Remus. First things first. What is Remus? Remus is a (Pre)Compiler for D. It adds D or rather the natural Syntax of D through various things, which are at the moment only offered by library solutions or not at all. This includes: - Not null references - Stack instances (also known as scope instances) - Namespaces - Safe Null invocation Planned further still: memoize for functions and methods as well as ref counted instances. Here's one code example of what already works: http://dpaste.dzfl.pl/bc50f081 Why did I do that? Many library solutions from D are for me (and probably for many others here) essentially built (built in) missing features that can't be missing. An example would be not null references: Not Null references doesn't exist and are not intended for D. They are at least a structure / library solution. Remus instead provides a simple, clear syntax. There is certainly more to say about the other features, but I'm not fond of many words: Try it out, or leave it. It's your choice, but I will use it in future for myself, my fellow students and my university stuff. Nevertheless I am thankful for suggestions and feedback. You can download Remus here: http://rswhite.de/?q=downloads. This is my own little website (however, in German) on where I give you some informations, details and features about Remus as well as how you install it: http://rswhite.de/?q=remus. I advise you to try reading some of the remus chapters to understand what's working and what doesn't and for what reason. On this page there will soon (about 2 - 4 weeks) be released the Beta-version of my 2D game framework called Dgame. This builds on the SDL and OpenGL and should become a worthy substitute to SFML from C++. It already has been tested enough in 2-3 simulations. Even an Pong Clone has been developed by it. But what's missing is an adequate documentation. So much of me. Greetings and in advance: sorry for my english ;) |
October 07, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | Namespace:
> - Not null references
> - Stack instances (also known as scope instances)
> - Namespaces
> - Safe Null invocation
>
> Planned further still: memoize for functions and methods as well as ref counted instances.
Similar efforts are useful almost as the Haskell GHC compiler extensions: to allow the community to try to use features not yet present in the language, to judge them better, allowing to understand if they are worth putting in the language, and trying few alternative implementation ideas looking for the best one of them.
But to do this well, people need to understand such extensions very well. So instead of just offering the source code and one uncommented example, I suggest to explain each feature, why they are present, what design choices you have taken and why, and how to use them in some common cases, with few specific examples.
This will make your work useful for the development of the mainstream D too.
Bye,
bearophile
|
October 07, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | I have, but until now only in german. If you understand german, you could read it on my website on the remus chapter. I'm going to translate and explain it more detailed this week. :) |
October 07, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | On 2012-10-07 19:32, Namespace wrote: > Hi, > > I'd like to present you Remus. > First things first. What is Remus? > Remus is a (Pre)Compiler for D. It adds D or rather the natural Syntax > of D through various things, which are at the moment only offered by > library solutions or not at all. > > This includes: > > - Not null references > - Stack instances (also known as scope instances) > - Namespaces > - Safe Null invocation This looks cool, especially not null references and stack instances. But as bearophile said, it would be nice with some explanation of the features. -- /Jacob Carlborg |
October 07, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Sunday, 7 October 2012 at 19:41:30 UTC, Jacob Carlborg wrote:
> On 2012-10-07 19:32, Namespace wrote:
amazing, good work...! what license is this under, is it allowed to be used commercially?
|
October 08, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tove | On Sunday, 7 October 2012 at 20:54:28 UTC, Tove wrote:
> On Sunday, 7 October 2012 at 19:41:30 UTC, Jacob Carlborg wrote:
>> On 2012-10-07 19:32, Namespace wrote:
>
> amazing, good work...! what license is this under, is it allowed to be used commercially?
LGPL or zlib (but then with copyleft as addtion), isn't clear right now.
|
October 09, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | As promised, a little description of Remus. :) Not Null references: I chose this syntax: int& b = a; because I like it in C++. This syntax is recognized by Remus and is converted to: Ref!(int) b = a; If you must give a reference to a function or other things like that, you can write: [code] Foo obj = new Foo(); some_function(@obj) [/code] instead of [code] Foo obj = new Foo(); { Foo& robj = obj; some_function(robj); } [/code] Namespaces: You can declare a namespace this way: [code] namespace io { void print() { writeln("foo"); } } [/code] you _cannot_ use it without explicit "use" statement (will maybe change). So you must write [code]use io;[/code] to use _all_ methods from "io", or, like import, [code]use io : print[/code] or [code]use io : write = print;[/code] "use" statements are converted to one or more alias' and namespaces to (mixin) templates. not null safe invocation: If you have an object which can be null, you can write: obj?.print(); the print method is only called, if obj is not null. It works even with more than one '?': obj?.getOtherObj?.print(); but then you have to take care of some special weakneses: Until now you can not write obj?.getOtherObj()?.print() because the parent's aren't recognized as valid identifiers for '?'. So you must use properties or this workaround: [code] Foo otherObj = obj?.getOtherObj(); // otherObj is null if obj is null otherObj.print(); [/code] Furthermore you cannot use '?' in the middle or end, or with breaks. So these are valid: a?.b.c and this a?.b?.c but these a.b?.c and a?.b.c?.d not. I described some more examples, do's and don't's on my website. Stack Instances: There aren't many words for: if you need a stack instance, write: local Foo f = new Foo(); it's more or less the same as scope. My next version will contain the elvis operator: [code] Foo obj = otherObj.get() ?: null; if otherObj.get() is _not_ null, it will assign to obj, otherwise obj will be assigned with null. [/code] And maybe cast's with 'as'. But my main interests are to fix the bugs and weakneses. That's it. Sorry for the few words, but I'm a bit busy right now. If you have questions or suggesstions you can write it here, I will read it every evening. |
October 09, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | Namespace: > Not Null references: > I chose this syntax: int& b = a; because I like it in C++. This syntax is recognized by Remus and is converted to: Ref!(int) b = a; > If you must give a reference to a function or other things like that, you can write: > [code] > Foo obj = new Foo(); > some_function(@obj) > [/code] > instead of > [code] > Foo obj = new Foo(); > { > Foo& robj = obj; > some_function(robj); > } This seems far from being well designed not-nullable pointers/class references :-( > [/code] > Namespaces: You can declare a namespace this way: > [code] > namespace io { > void print() { > writeln("foo"); > } > } > [/code] > you _cannot_ use it without explicit "use" statement (will maybe change). So you must write > [code]use io;[/code] to use _all_ methods from "io", or, like import, [code]use io : print[/code] or [code]use io : write = print;[/code] > "use" statements are converted to one or more alias' and namespaces to (mixin) templates. But what are they useful for? > Stack Instances: > There aren't many words for: if you need a stack instance, write: local Foo f = new Foo(); it's more or less the same as scope. scope was removed for certain reasons, are those reasons not valid for "local"? Bye, bearophile |
October 10, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | On Tuesday, 9 October 2012 at 19:34:01 UTC, Namespace wrote:
> Stack Instances:
> There aren't many words for: if you need a stack instance, write: local Foo f = new Foo(); it's more or less the same as scope.
What's the difference between this and std.typecons.scoped, except for alignment and syntax?
|
October 10, 2012 Re: Remus | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > This seems far from being well designed not-nullable pointers/class references :-(
And why not? In my test cases, they fulfilled their task / purpose very well.
And you ask for what namespaces are usefull? Aren't you miss them? I do, and so I implement them. You can already write "namespaces" in D, but you must use a (mixin) template (so you have these ugly parents) and for using you have to write: alias tpl_nspace!().print print or directly: tpl_nspace!().print. And that's ugly (because of '!()') and annoying IMO.
For what local is good for and whats the differences between my version and scoped from dmd I will tell later, but as you can see: you have to write: local Foo f = new Foo(); what is more intuitive as Scoped! Foo f = scoped!Foo(); IMO.
|
Copyright © 1999-2021 by the D Language Foundation