Improve search in digitalmars.com/d (Was: foreach)

Ary Borenszweig ary at esperanto.org.ar
Sun Nov 23 09:14:27 PST 2008


Sam S E escribió:
> Jarrett Billingsley Wrote:
> 
>> On Sun, Nov 23, 2008 at 10:48 AM, Sam S E <asdf at mailinator.com> wrote:
>>> Jarrett Billingsley Wrote:
>>>
>>>> On Sat, Nov 22, 2008 at 11:40 PM, Sam S E <eisenstat.aa at sympatioco.ca> wrote:
>>>>> Does foreach use delegates? Isn't that unnecessary overhead?
>>>>> --Sam
>>>> It does use delegates, for iterating over most types.  When iterating
>>>> over arrays, the compiler turns it into a sort of for loop instead.
>>>>
>>>> Is it unnecessary overhead?  It's not always as fast as it could be,
>>>> but unless someone can figure out some other way of implementing it,
>>>> it's pretty much the best we can get.
>>>>
>>>> How about iterator objects, like in C++ or Java?  Are they unnecessary
>>>> overhead?  ;)
>>> Why not just use a normal for loop; wouldn't it be almost as simple as token substitution? By 'most types,' do you mean associative arrays or am I forgetting something? As a mainly C(++) programmer, I don't use iterators when I don't need to. I don't even use classes when I don't need to.
>> How do you use a for loop to iterate over an associative array whose
>> implementation is hidden, or a binary tree, or any arbitrary
>> container, or a sequence or words in a file, or the zipped contents of
>> two lists, or...
>>
>> The point of foreach isn't performance, it's flexibility and
>> abstraction.  As long as you can make an opApply or function which
>> takes a delegate, you can use the foreach loop with it.  Not
>> everything is an array.
> 
> Where are the docs on opApply?

Search opApply in http://www.digitalmars.com/d/1.0/statement.html

Can't the search in digitalmars.com/d be improved? Searching for 
"opApply" you get ten results which are just questions in the 
newsgroups, and just in the second page you can see the result you 
probably are looking for.

I suggest improving it in this way:
1. Have a map of obvious keywords that people will look for, to precise 
urls. Some examples are: delegate, function, override, virtual, class, 
struct, union, interface, pointer, op*, operator overloading, 
inheritance, final, const, invariant, etc.
2. If the search is exactly one of the keywords, use the map above.
3. Else, use Google Search Engine.

The list might be big, but it can be done if the community helps, and I 
think it will improve a lot the usability of the site.

Actually, the map can be [keyword -> list of urls]. For example, for 
invariant it should point the invariant attribute as well as invariant 
classes.

And don't point me to

http://www.wikiservice.at/wiki4d/wiki.cgi?LanguageSpecification/KeywordIndex

I know it exists, but people how enter the D site (and the above is not 
the D site) will use the search box. Who uses indexes these days when 
you can search and find what you want?



More information about the Digitalmars-d mailing list