Groovy
Thomas Kuehne
thomas-dloop at kuehne.cn
Sun Dec 31 09:31:19 PST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Groovy(http://groovy.codehaus.org/) is a dynamic language implemented on
the Java VM with strong Java integration. As Groovy's roots and
aims partially overlap with D's, some solutions might be interesting.
DISCLAIMER: I'm not a Groovy expert.
1) ranges
Groovy:
#
# assert (x in 2 .. 5);
#
# switch(y) {
# case 1: break;
# case 1900 .. 2006: break;
# }
#
current D:
#
# assert((2 <= x) && (x <= 5));
#
# switch(y) {
# case 1: break;
# default:
# if((1900 <= y) && (y <= 2006)){
# break;
# }
# }
Especially the ranges support for switch/case is very useful.
2) literals for associative arrays
Groovy:
#
# def map = ['a': 1, 'b': 2, 'c': 3]
#
current D:
#
# int[char] map;
# map['a'] = 1;
# map['b'] = 2;
# map['c'] = 3;
#
Other useful features of Groovy depend too much on the VM
(e.g. dynamic extending of classes) for integration into D.
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFmACaLK5blCcjpWoRAgKqAJ9BZIaQcCAux4EJn8ZHD4MyJdpn8QCfTb0N
iq1UGHbq25cNJCN8ZPv+RnY=
=IPRp
-----END PGP SIGNATURE-----
More information about the Digitalmars-d
mailing list