🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2027

Re: Making STL user-friendly?? [Re: STL find errorprone]

#2027
From: John Max Skaller
Date: Mon, 25 Sep 1995 01:59
52 lines
2717 bytes
martelli@cadlab.cadlab.it (Alex Martelli) wrote:
>
>Tony Cook <tony@online.tmx.com.au> writes:
>	...
>>I don't see any need to _remove_ the current begin/end idiom - as
>>you say it's useful - but to simply supply extra interfaces to
>>perform the most common functions in a more compact way -
>>specifically, operating on the whole container, and possibly
>
>I will agree on this one -- it IS going to be frequent, and:
>	find(container)
>IS a distinct enhancement over:
>	find(container.begin(), container.end())

    I DON'T agree. 

    It is crucial for orthogonality that the algorithm interfaces
are isolated from any notion of containers -- which is 
what the STL iterator architecture is for.

             ITERATORS
               ^    \-------------\------\---------... 
             /       \             \      \ 
            /         V             V      V
      ALGORITHMS     CONTAINERS DEVICES PROCESSES

    Providing standard algorithms taking container arguments
would destroy the essential independence of the notions
by introducing direct coupling. The _indirection_ provided
by iterators is what makes STL work so well.

    What makes STL such an excellent library is the
way iterators are used to interface containers and algorithms
by contracts on the intermediaries that service both --- iterators.
This leads to predictable orthogonal combination -- where
predictable refers not only to correctness, but also performance.

    There is nothing wrong with writing convenience
functions like "find(container, value)" --- the very ability to
do so in a few lines of code --- in several different ways ---
is exactly why this should NOT be standardised.
Put such a function in your own namespace, to avoid clashes.

-- 
John Max Skaller               voice: 61-2-566-2189
81 Glebe Point Rd              fax:   61-2-660-0850
GLEBE NSW 2037                 email: maxtal@suphys.physics.oz.au
AUSTRALIA                      email: skaller@maxtal.com.au
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4443c0$c0l@oznet03.ozemail.com.au>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <MATT.95Sep20214413@Austern> <MATT.95Sep23125702@Austern>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 25 Sep 95 01:59:41 GMT
Approved: fjh@cs.mu.oz.au
From: John Max Skaller <maxtal@suphys.physics.su.oz.au>
Newsgroups: comp.std.c++
Subject: Re: Making STL user-friendly?? [Re: STL find errorprone]
X-Original-Date: 24 Sep 1995 17:09:20 GMT
Organization: MAXTAL
Message-ID: <4443c0$c0l@oznet03.ozemail.com.au>
References: <MATT.95Sep20214413@Austern> <MATT.95Sep23125702@Austern>
X-Mailer: Mozilla 1.2b6 (Windows; I; 16bit)