digitalmars.D - Alternative typeof syntax
- bearophile <bearophileHUGS lycos.com> May 17 2010
- "Nick Sabalausky" <a a.a> May 17 2010
- Clemens <eriatarka84 gmail.com> May 18 2010
- "Nick Sabalausky" <a a.a> May 18 2010
- Ary Borenszweig <ary esperanto.org.ar> May 18 2010
- Clemens <eriatarka84 gmail.com> May 19 2010
What do you think about the the syntax x.typeof instead of typeof(x) ?
There are situations where you will need to parenthesize anyway, for example:
import std.stdio;
void main() {
int x = 1;
float y = 1.5;
writeln(typeid(typeof(x + y)));
}
You have to write:
(x + y).typeof
But in many situations you don't need the ().
And it gets more similar/uniform to the x.sizeof syntax too (that is sizeof(x)
in C).
Bye,
bearophile
May 17 2010
"bearophile" <bearophileHUGS lycos.com> wrote in message news:hss6b6$aep$1 digitalmars.com...What do you think about the the syntax x.typeof instead of typeof(x) ? There are situations where you will need to parenthesize anyway, for example: import std.stdio; void main() { int x = 1; float y = 1.5; writeln(typeid(typeof(x + y))); } You have to write: (x + y).typeof But in many situations you don't need the (). And it gets more similar/uniform to the x.sizeof syntax too (that is sizeof(x) in C).
vote++ Anything that reduces parenthesis-hell without inviting ambiguities in either the compiler or the "human-eye parser" is good by me :) Besides, I love member access syntax in general. In addition to (safely) reducing parenthesis, it also sidesteps the oddity that nested function calls are written/read *backwards* from the order of execution (ie, "A(B(C()))" means "call C, then B, then A"). I've even been toying with the idea of a language design that places primary emphasis on member-call syntax and consistent left-to-right ordering.
May 17 2010
Nick Sabalausky Wrote:Besides, I love member access syntax in general. In addition to (safely) reducing parenthesis, it also sidesteps the oddity that nested function calls are written/read *backwards* from the order of execution (ie, "A(B(C()))" means "call C, then B, then A"). I've even been toying with the idea of a language design that places primary emphasis on member-call syntax and consistent left-to-right ordering.
You mean like Smalltalk?
May 18 2010
"Clemens" <eriatarka84 gmail.com> wrote in message news:hstgm2$2pr6$1 digitalmars.com...Nick Sabalausky Wrote:Besides, I love member access syntax in general. In addition to (safely) reducing parenthesis, it also sidesteps the oddity that nested function calls are written/read *backwards* from the order of execution (ie, "A(B(C()))" means "call C, then B, then A"). I've even been toying with the idea of a language design that places primary emphasis on member-call syntax and consistent left-to-right ordering.
You mean like Smalltalk?
Not really sure. All I remember from when I looked into Smalltalk was that even the most basic logic constructs were forced into being objects/classes, which make their use needlessly awkward.
May 18 2010
Clemens wrote:Nick Sabalausky Wrote:Besides, I love member access syntax in general. In addition to (safely) reducing parenthesis, it also sidesteps the oddity that nested function calls are written/read *backwards* from the order of execution (ie, "A(B(C()))" means "call C, then B, then A"). I've even been toying with the idea of a language design that places primary emphasis on member-call syntax and consistent left-to-right ordering.
You mean like Smalltalk?
You mean like Ruby? :-)
May 18 2010
Ary Borenszweig Wrote:Clemens wrote:Nick Sabalausky Wrote:Besides, I love member access syntax in general. In addition to (safely) reducing parenthesis, it also sidesteps the oddity that nested function calls are written/read *backwards* from the order of execution (ie, "A(B(C()))" means "call C, then B, then A"). I've even been toying with the idea of a language design that places primary emphasis on member-call syntax and consistent left-to-right ordering.
You mean like Smalltalk?
You mean like Ruby? :-)
Heh, yes ;) Of course Smalltalk was there first, prior art and all that. I had some fun with it again over the weekend... it's a really neat language, a shame that it never really caught on in a big way. Perhaps the whole image-based development thing was just too different from how everyone was/is working. By the way, another interesting (though less widely known) language that also builds upon that legacy is Io: http://www.iolanguage.com/
May 19 2010









"Nick Sabalausky" <a a.a> 