foreach thoughts

Manu turkeyman at gmail.com
Tue Jan 14 01:21:48 PST 2014


On 14 January 2014 19:06, Jakob Ovrum <jakobovrum at gmail.com> wrote:

> On Tuesday, 14 January 2014 at 08:43:37 UTC, Ola Fosheim Grøstad wrote:
>
>> On Tuesday, 14 January 2014 at 08:36:53 UTC, Jakob Ovrum wrote:
>>
>>> You'll have to get used to the exclamation mark, otherwise you'll never
>>> be able to fully appreciate D's generic programming. I quite like it - I
>>> don't think there's anything objectively ugly about it.
>>>
>>
>> You subjectively think that there is nothing objectively ugly about it?
>> :-) It is objectively ugly because "!" implies a boolean expression, but
>> that is off-topic.
>>
>
> This argument is stupid. It's the same argument as the famous "Yeah, well,
> that's just, like, your opinion, man", or the "please put `I think...` in
> front of all your sentences!" argument.
>
> The burden of proof is on the person who first claims it's deficient.
> Saying that I can't think of anything objectively wrong with it serves the
> purpose of inviting Manu to provide some kind of argument, as I can't think
> of anything *obviously* wrong about it that goes unsaid.
>
> It's common to overload tokens in programming languages, and it's usually
> only a problem for beginners who aren't used to the particular language's
> choice of overloads yet (Ruby is good example of a language with rather
> extreme token reuse) - humans are pretty good at context-sensitive parsing.
> From a character-by-character perspective it's particularly common, with
> the bitwise shift operators having nothing to do with comparisons, bitwise
> xor having nothing to do with exponents etc.
>
> Regardless of whether binary ! is "ugly" or not, it's still better than
> introducing language features left and right to avoid templates, and it's
> still better than C++'s template instantiation syntax :)


Personally, I generally like the '!' syntax, except when it's in
conjunction with lambda's where it can kinda ruins the statements a bit.


 I agree that chaining of filters and sorting rules is a good solution,
>> provided that you have a high level optimizer capable of transforming the
>> chain into something optimal. You basically need some sort of
>> term-rewriting.
>>
>
> LDC and GDC are capable of unravelling the (fairly thin) abstraction. All
> it requires is the ability to inline direct function calls to small
> functions - the aforementioned compilers always have this capability for
> templated functions.
>
> DMD is hit and miss, but I think there was a recent improvement to its
> inliner... luckily this is still the domain of micro-optimization.
>

I'm quite concerned about unoptimised performance too. I know that's
unusual, but I'm often left wondering what to do about it.

Imagine, iterating over an array, if I use .filter(lambda) or something,
there's now an additional 2 function calls at least per iteration, as
opposed to the original zero. If this is idiomatic (I'd like to think it
should be since it's fairly tidy), then we commit to a serious performance
problem in unoptimised code. Liberal use of .empty and things too is a
problem in unoptimised code... :/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140114/ae14043a/attachment-0001.html>


More information about the Digitalmars-d mailing list