Mid-term vision review

Dennis Ritchie via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 5 18:39:19 PDT 2015


On Friday, 3 April 2015 at 17:51:00 UTC, Andrei Alexandrescu 
wrote:
> On 4/3/15 4:04 AM, Dennis Ritchie wrote:
>> On Thursday, 2 April 2015 at 22:44:56 UTC, Andrei Alexandrescu 
>> wrote:
>>> It's the end of Q1. Walter and I reviewed our vision 
>>> document. We're
>>> staying the course with one important addition: switching to 
>>> ddmd,
>>> hopefully with 2.068.
>>>
>>> http://wiki.dlang.org/Vision/2015H1
>>>
>>>
>>> Andrei
>>
>> Are there any plans for the creation of a powerful AST-macro 
>> system in D?
>> http://wiki.dlang.org/DIP50
>
> Not for the time being. -- Andrei

Thanks. I hope that in the near future will be a powerful D 
macrosystem. If you ever start to create a macro system in D, 
then I suggest you explore approaches Lisp family of languages, 
because they have a very powerful macro-framework that allows 
modifying the language to suit your needs. In the family of Lisp 
contains a lot of powerful features that can once and for all to 
eclipse C++. It would be very nice if in the future you add these 
features in D. Sorry if I did something wrong said.

For Example,

D mixin's:
-----
import std.stdio;
import std.algorithm;

string print(string s)
{
	return `writeln(` ~ s ~ `);`;
}

void main()
{
	auto a = 3;
	auto arr = [1, 2, 3, 4, 5];
	
	mixin(print(`5`)); // prints 5
	mixin(print(`'c'`)); // prints c
	mixin(print(`"str"`)); // prints str
	mixin(print(`arr`)); // prints [1, 2, 3, 4, 5]
	mixin(print(`arr.map!(t => ++t)`)); // prints [2, 3, 4, 5, 6]
	mixin(print(`a`)); // prints 3
}
-----

Mixin, created by a powerful macro system Common Lisp:
-----
(defmacro mixin (f) (read-from-string (eval f)))

(defun pr (s)
   (format nil "(print ~A)" s))

(defun main (&aux (a 3) (arr '(1 2 3 4 5)))
   (mixin (pr "5"))
   (mixin (pr "#\\c"))
   (mixin (pr "\"str\""))
   (mixin (pr "arr"))
   (mixin (pr "(mapcar (lambda (x) (1+ x)) arr)"))
   (mixin (pr "a"))
   (values))
-----
CL-USER> (main)

5
#\c
"str"
(1 2 3 4 5)
(2 3 4 5 6)
3 ; No value


More information about the Digitalmars-d mailing list