Delight

Thomas Leonard talex5+d at gmail.com
Sun Oct 26 08:10:13 PDT 2008


On Sun, 12 Oct 2008 09:56:56 -0400, bearophile wrote:
> More things from the site:

> Thomas Leonard:
>>- anonymous functions work ("function(int x): x + 1"). This is like
> lambda in Python.<
> 
> Note that D1 and D2 already support this syntax: (int x, float y) {
> return x+y; }

Unfortunately, the corresponding syntax is ambiguous:

  while 1 + (something): ...

Is something an expression or a list of arguments? D just looks after the 
closing ) and sees that the next character is a block start, but that 
only works because it always has an extra outer pair of ().

We could do something like:

  map( (int x) -> x + 1, [1,2,3])

But I don't really like having to look ahead to work out what it is. 
Having 'function' or 'delegate' come first makes parsing easier (e.g. for 
syntax highlighters, etc).

>>- any object can be implicitly cast to Object (D doesn't allow this)<
> 
> Is this good? (just asking)

I've now adding a 'linkage' field to interfaces. You can cast any 
interface to Object iff it has D linkage. So COM objects can't be 
accidentally treated as D objects again, but it's still convenient
in the common case.

I don't use COM, but I needed this when adding GObject linkage:

  http://delight.sourceforge.net/gtk.html
 
>>Statements end at the end of a line. Semi-colons are not required.<
> 
> Is the \ syntax possible for too much long lines, as in Python?

Currently you need some kind of brackets, but I'll add \ at some point.


More information about the Digitalmars-d-announce mailing list