Interactive D?

Oskar Linde oskar.lindeREM at OVEgmail.com
Tue Feb 26 04:54:46 PST 2008


Jari-Matti Mäkelä wrote:
> 
> 
> On Fri, 22 Feb 2008, Oskar Linde wrote:
> 
>> I got the idea to investigate the possibility of an interactive D 
>> interpreter. A lazy afternoon of hacking resulted in a proof of 
>> concept, and what follows is a short demo.
>>
>> Could there be any interest in pursuing this?
> 
> I've been waiting for a repl for years. Great work.
> 
> Some further ideas:
> 
> catching exceptions, displaying the values and types of structs/classes 
> and their members recursively (if the default uses toString) -- 
> hopefully this will encourage Walter to fix some of the unspecified 
> behavior with .stringof, exporting the current state to a file, locating 
> symbol definitions.

Catching exceptions actually already work:

 >>> a = [1,2,3][]

  a = [1,2,3] (int[])

 >>> a[3] = 4

ArrayBoundsError input(1)

 >>> a ~= 4

  ans = [1,2,3,4] (int[])

Regarding stringof. The following is irritating, given:

template A(T) { struct A {} }
template B(T) { struct A {} struct B {} }

A!(int) a;
B!(int).B b;

How do I reliably get the string representation of the type of a and b?

There are two ways that I know of:

1. typeid(typeof(x)).toString
2. typeof(x).stringof

The problem is that the results are:

1A: test.A!(int).A	WRONG
1B: test.B!(int).B	CORRECT

2A: A!(int) 		CORRECT (although not fully qualified)
2B: B 			WRONG

So neither way works for both cases...

Your other points are interesting and useful, but some of them are quite 
hard. I can't do much more than the D compiler can do at compile + 
runtime together.

-- 
Oskar



More information about the Digitalmars-d mailing list