41 ms·
Yes, but that (specific) example is a great example of a waste of space in the vast, vast, vast majority of cases. Let me show you examples of code that hides t
by pnathan 15y ago
Yes, but that (specific) example is a great example of a waste of space in the vast, vast, vast majority of cases.
Let me show you examples of code that hides that whole iterator groadyness:
Python
for foo in Foos:
baz(foo)
Common Lisp:
(loop for foo in Foos
do
(baz foo))
Perl:
foreach my $foo (@Foos)
{
baz(foo);
}
C++ has a foreach construct as well, but it's a bit shoehorned. I'm relatively certain C# has some shorthand here for the same thing, and IIRC, it flows nicely.
There is no "Most likely", no "exception", it's very straightforward.
Rarely - very rarely - I care about the mechanisms of initialization, nexting, and termination. The rest of the time, (loop for var in list do) gets me by just fine.
* Macros change your program logically (as in not just perf improvements) prior to compilation. Not-macros do not. That's a big difference.*
It's no different than hunting through framework documentation.
- jbooth 15y agoUh. Java has a foreach operator. Has had it for almost a decade now. Almost the same as the C# operator. You might want to consider dialing down your self-assuredness if you don't know the basic commands in the language being discussed. And macros are vastly different from hunting through framework documentation, that's not the same ballpark or even the same sport. If you want macro-like behavior in Java, you can always break out AspectJ, which I strongly recommend against doing due to my biases against code that changes in between me typing it and it running.
- pnathan 15y agoNo, it's exactly the same. It's reading the things you are using to understand what they do.
- peteretep 15y agoIn Perl you'd be more likely to write: bar($_) for @Foos;