www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [NOTABLE PR] First step from traditional to generic runtime

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Worth a look: https://github.com/dlang/druntime/pull/1781. This moves 
comparison code away from tedious runtime-introspected routines to nice 
templates. -- Andrei
Mar 02
next sibling parent sarn <sarn theartofmachinery.com> writes:
On Thursday, 2 March 2017 at 19:32:23 UTC, Andrei Alexandrescu 
wrote:
 Worth a look: https://github.com/dlang/druntime/pull/1781. This 
 moves comparison code away from tedious runtime-introspected 
 routines to nice templates. -- Andrei
Great news :)
Mar 02
prev sibling next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 03/03/2017 8:32 AM, Andrei Alexandrescu wrote:
 Worth a look: https://github.com/dlang/druntime/pull/1781. This moves
 comparison code away from tedious runtime-introspected routines to nice
 templates. -- Andrei
If we end up full on templated TypeInfo that would be lovely. TypeInfo_Class clasz = TypeInfo_ClassT!Foo; class TypeInfo_ClassT(T) if(is(T == class)) { version(FullReflection) { string[] methodNames() { ... } } } But just a thought.
Mar 02
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Friday, 3 March 2017 at 02:59:57 UTC, rikki cattermole wrote:
 If we end up full on templated TypeInfo that would be lovely.

 TypeInfo_Class clasz = TypeInfo_ClassT!Foo;

 class TypeInfo_ClassT(T) if(is(T == class)) {
 	version(FullReflection) {
 		string[] methodNames() { ... }
 	}
 }
We already have the capability to do that with the existing dmd and druntime - RTInfo is a template instantiated for each type, linked into TypeInfo, so we can extend it... if we are willing to edit object.d. What is really nice about templating TypeInfo though is removing some annoying code from druntime and also being able to tweak that in constrained environments.... we can already add anything we want, being able to *remove* is what's going to be new.
Mar 02
parent rikki cattermole <rikki cattermole.co.nz> writes:
On 03/03/2017 4:06 PM, Adam D. Ruppe wrote:
 On Friday, 3 March 2017 at 02:59:57 UTC, rikki cattermole wrote:
 If we end up full on templated TypeInfo that would be lovely.

 TypeInfo_Class clasz = TypeInfo_ClassT!Foo;

 class TypeInfo_ClassT(T) if(is(T == class)) {
     version(FullReflection) {
         string[] methodNames() { ... }
     }
 }
We already have the capability to do that with the existing dmd and druntime - RTInfo is a template instantiated for each type, linked into TypeInfo, so we can extend it... if we are willing to edit object.d. What is really nice about templating TypeInfo though is removing some annoying code from druntime and also being able to tweak that in constrained environments.... we can already add anything we want, being able to *remove* is what's going to be new.
Yeah, once it is fully template based it gives us the ability to actually play with TypeInfo and not have to go modify the compiler on any set of changes. So while we do have RTInfo, we don't have this freedom to change and adapt it like we could and this PR moves us towards that hopefully.
Mar 02
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 3/2/2017 11:32 AM, Andrei Alexandrescu wrote:
 Worth a look: https://github.com/dlang/druntime/pull/1781. This moves
comparison
 code away from tedious runtime-introspected routines to nice templates. --
Andrei
It also moves logic from the compiler to druntime, where it becomes much more easily adapted to users' requirements.
Mar 02
prev sibling next sibling parent reply Dukc <ajieskola gmail.com> writes:
On Thursday, 2 March 2017 at 19:32:23 UTC, Andrei Alexandrescu 
wrote:
 Worth a look: https://github.com/dlang/druntime/pull/1781. This 
 moves comparison code away from tedious runtime-introspected 
 routines to nice templates. -- Andrei
This means that if I don't use the templated features, they don't affect my program size nor prevent compilation for platforms where they aren't implemented or have errors. Did I understand right?
Mar 02
parent Walter Bright <newshound2 digitalmars.com> writes:
On 3/2/2017 11:04 PM, Dukc wrote:
 On Thursday, 2 March 2017 at 19:32:23 UTC, Andrei Alexandrescu wrote:
 Worth a look: https://github.com/dlang/druntime/pull/1781. This moves
 comparison code away from tedious runtime-introspected routines to nice
 templates. -- Andrei
This means that if I don't use the templated features, they don't affect my program size nor prevent compilation for platforms where they aren't implemented or have errors. Did I understand right?
That's right. Of course, that was true before, too. What the templates do is put the ABI under user control.
Mar 03
prev sibling next sibling parent reply Kagamin <spam here.lot> writes:
Nitpick: object.d is for symbols visible to user code, but it's 
not necessary to provide these helper functions to used code, so 
they should be in a different module known to the compiler.
Mar 03
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2017-03-03 16:16, Kagamin wrote:
 Nitpick: object.d is for symbols visible to user code, but it's not
 necessary to provide these helper functions to used code, so they should
 be in a different module known to the compiler.
Exactly https://github.com/dlang/druntime/pull/1781#issuecomment-283904287 -- /Jacob Carlborg
Mar 03
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 3/3/17 10:16 AM, Kagamin wrote:
 Nitpick: object.d is for symbols visible to user code, but it's not
 necessary to provide these helper functions to used code, so they should
 be in a different module known to the compiler.
Fundamentally the code resulting from lowering must be in the standard language, i.e. no "magic" artifacts, no hidden symbols, no special rules. The lowering should be as if the user replaced the code with the lowered version by hand. -- Andrei
Mar 03
parent reply Kagamin <spam here.lot> writes:
v1==v2;

can be lowered as

{
   import rthelpers:cmp;
   cmp(v1,v2);
}

or something like that
Mar 06
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 3/6/17 8:42 AM, Kagamin wrote:
 v1==v2;

 can be lowered as

 {
   import rthelpers:cmp;
   cmp(v1,v2);
 }

 or something like that
Interesting idea, will keep it in mind. Thanks! -- Andrei
Mar 06
parent Kagamin <spam here.lot> writes:
On Monday, 6 March 2017 at 18:06:27 UTC, Andrei Alexandrescu 
wrote:
 On 3/6/17 8:42 AM, Kagamin wrote:
 v1==v2;

 can be lowered as

 {
   import rthelpers:cmp;
   cmp(v1,v2);
 }

 or something like that
Interesting idea, will keep it in mind. Thanks! -- Andrei
Even better: in object.d: --- public import _d_helpers=core.helpers; --- lowering: --- v1==v2 to _d_helpers.cmp(v1,v2) --- This has the best scalability and zero possibility of code breakage and probably can be done right now. Also since the renamed import must be referenced explicitly, it doesn't need to be processed until used.
Mar 16
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 03/02/2017 02:32 PM, Andrei Alexandrescu wrote:
 Worth a look: https://github.com/dlang/druntime/pull/1781. This moves
 comparison code away from tedious runtime-introspected routines to nice
 templates. -- Andrei
Another notable PR in the same vein: https://github.com/dlang/druntime/pull/1792. -- Andrei
Mar 15