Re: Proposal: __traits(code, ...) and/or .codeof

2012-10-11 Thread luka8088
On Tuesday, 9 October 2012 at 19:29:34 UTC, F i L wrote: On Tuesday, 9 October 2012 at 13:28:55 UTC, luka8088 wrote: Is this at least similar to what you had in mind ? [ ..code.. ] Yes, I realized, a bit after I originally posted that, that my suggestion was already possible if BankType

Re: Proposal: __traits(code, ...) and/or .codeof

2012-10-09 Thread luka8088
Is this at least similar to what you had in mind ? http://dpaste.dzfl.pl/a5dc2875 module program; import std.stdio; mixin template BankAccount () { public int amount; void deposit (int value) { this.amount += value; } void withdraw (int value) { this.amount -= value; } auto

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-24 Thread deadalnix
Le 22/03/2012 19:06, Felix Hufnagel a écrit : in addition to .codeof, let's think about .astof returning an abstract syntax tree. WAY better !

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-24 Thread deadalnix
Le 22/03/2012 17:00, F i L a écrit : So the discussions about Attributes and Aspect Oriented Programming (AOP) got me thinking... Basically AOP requires injecting code fragments together in a comprehensible way. Similarly, Attributes that go beyond @note (such as @GC.NoScan) need similar

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-23 Thread Timon Gehr
On 03/23/2012 12:33 AM, F i L wrote: Timon Gehr wrote: We have the macro keyword. I envision something like: macro replaceAggregate(macro newAggregate, macro loop : foreach(x; aggr){statements}, macro x, macro aggr, macro statements) { foreach(x; newAggregate){statements} } void main(){ int[]

Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread F i L
So the discussions about Attributes and Aspect Oriented Programming (AOP) got me thinking... Basically AOP requires injecting code fragments together in a comprehensible way. Similarly, Attributes that go beyond @note (such as @GC.NoScan) need similar ability. D already has the ability to

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread F i L
ps. Mono-C#'s NRefactory, and Microsoft .Net's forthcoming Roslyn Project are the only comparable infrastructures I can think of with this level of reflection, and they're the foundation to some pretty innovative new development tools. NRefactory: http://wiki.sharpdevelop.net/NRefactory.ashx

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread CTFE-4-the-win
On Thursday, 22 March 2012 at 16:55:34 UTC, F i L wrote: ps. Mono-C#'s NRefactory, and Microsoft .Net's forthcoming Roslyn Project are the only comparable infrastructures I can think of with this level of reflection, and they're the foundation to some pretty innovative new development tools.

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread Felix Hufnagel
in addition to .codeof, let's think about .astof returning an abstract syntax tree.

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread F i L
On Thursday, 22 March 2012 at 18:06:24 UTC, Felix Hufnagel wrote: in addition to .codeof, let's think about .astof returning an abstract syntax tree. I agree, as stated on the IRC, .astof (and therefor .astof.toString()) is a much better concept.

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread F i L
On Thursday, 22 March 2012 at 18:06:24 UTC, Felix Hufnagel wrote: in addition to .codeof, let's think about .astof returning an abstract syntax tree. I haven't really looked at DMD's AST structure, but I assume we could just duplicate that minus any CTFE stuff or codegen stuff.

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread Paulo Pinto
Am 22.03.2012 19:06, schrieb Felix Hufnagel: in addition to .codeof, let's think about .astof returning an abstract syntax tree. Would this not require something similar to the expression trees in .NET? http://msdn.microsoft.com/en-us/library/bb397951.aspx -- Paulo

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread Paulo Pinto
Am 22.03.2012 18:34, schrieb CTFE-4-the-win: On Thursday, 22 March 2012 at 16:55:34 UTC, F i L wrote: ps. Mono-C#'s NRefactory, and Microsoft .Net's forthcoming Roslyn Project are the only comparable infrastructures I can think of with this level of reflection, and they're the foundation to

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread Timon Gehr
On 03/22/2012 07:08 PM, F i L wrote: On Thursday, 22 March 2012 at 18:06:24 UTC, Felix Hufnagel wrote: in addition to .codeof, let's think about .astof returning an abstract syntax tree. I agree, as stated on the IRC, .astof (and therefor .astof.toString()) is a much better concept. I think

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread F i L
Timon Gehr wrote: I think that would necessitate the addition of AST macros. You mean passing DMD's actual AST tree object? Only a stripped down version?

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread Timon Gehr
On 03/22/2012 08:12 PM, F i L wrote: Timon Gehr wrote: I think that would necessitate the addition of AST macros. You mean passing DMD's actual AST tree object? Only a stripped down version? We have the macro keyword. I envision something like: macro replaceAggregate(macro newAggregate,

Re: Proposal: __traits(code, ...) and/or .codeof

2012-03-22 Thread F i L
Timon Gehr wrote: We have the macro keyword. I envision something like: macro replaceAggregate(macro newAggregate, macro loop : foreach(x; aggr){statements}, macro x, macro aggr, macro statements) { foreach(x; newAggregate){statements} } void main(){ int[] a = [1,2,3]; int[] b =