Delight

Leandro Lucarella llucax at gmail.com
Sat Sep 27 15:45:38 PDT 2008


Johan Granberg, el 25 de septiembre a las 22:33 me escribiste:
> bearophile wrote:
> 
> > Mosfet:
> >> Is there any performance loss from compared to D language ?
> > 
> > No, it's just D1 resyntaxed. That is, it generally improves on the
> > old-school syntax of D ;-)
> > 
> > Bye,
> > bearophile
> 
> How complet is the page? From wath I read there was several good features
> missing from D1 and if it's just a resyntax thats a shame :)
> 
> The most notisable was that I found no mention of an equvivalent to this
> 
> foreach(i,x;collection)
>         doSuff(i,x);

Loops

There are various different constructs for loops:

# Iterate over a sequence
for x in ["red", "green", "blue"]:
	stdout.formatln("Next is {}", x)

# Iterate over a sequence backwards
for x in ["red", "green", "blue"] reversed:
	stdout.formatln("Next backwards is {}", x)

# Get the index as well as the value
for i, x in ["red", "green", "blue"]:
	stdout.formatln("Item #{} = {}", i, x)

# Get all key/value pairs from an associative array
for key, value in dictionary:
	stdout.formatln("{} -> {}", key, value)

# A C-style for loop
for (int i = 1; i < 10; i++):
	stdout.formatln("i = {}", i)

# A C-style while loop
int j = 10
while j > 0:
	stdout.formatln("j = {}", j)
	j--

(http://delight.sourceforge.net/syntax.html)


-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Con todas las manos que me acogotan, no puedo respirar
Con todos sus dedos me haría una torta, para festejar
Que no me estoy yendo solo de este lugar


More information about the Digitalmars-d-announce mailing list