Adding Unicode operators to D
Simen Kjaeraas
simen.kjaras at gmail.com
Thu Oct 23 13:48:58 PDT 2008
On Thu, 23 Oct 2008 00:27:58 +0200, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Please vote up before the haters take it down, and discuss:
>
> http://www.reddit.com/r/programming/comments/78rjk/allowing_unicode_operators_in_d_similarly_to/
>
>
> Andrei
I really like the idea of having more unicode in the language, but I feel
these should be fairly limited.
There are times I feel that more operators (especially, as has been
mentioned, opCross and opDotProduct) would be nice to have, but it's just
sugar, really.
As an example, while I'd enjoy seeing code like this, I'm not sure I'd
enjoy writing it (Note that I am prone to exaggerations):
int a = ∅; //empty set, same as "= void"
int[] b = [1,2,3,4,5,6];
a = readInt();
if (a ∈ b) // Element of - "in"
{
float c = 2.00001;
float d = readInt();
writefln(c ≈ ⌈d⌉ ); // Approximately equal, ceil
myClass c = getInstance();
if (∃c) // c exists, i.e. "!is null"
{
writefln(√(c.foo)); // I thought this should work in D today, using
"alias sqrt √;", but it seems the compiler chokes on it. :(
}
∀element∈b // New foreach syntax!
{
element *= ¼;
}
}
--
Simen
More information about the Digitalmars-d-announce
mailing list