Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2004-01-07 04:33:09


"Andy Little" <andy_at_[hidden]> wrote in message
news:btgigm$bfq$1_at_sea.gmane.org...
>
> "Daniel Frey" <daniel.frey_at_[hidden]> wrote
>
> > > Speed s = 2 m / s;
> [...]
> q_velocity::m_div_s s(2);

If I had to choose between the two, I'd pick the first one, hands down.
Why? Well, it all goes back to expressing the solution in the language
of the problem domain. Granted, this is an extreme (ab)use of
operator overloading, but if it lets us write expressions that almost
look natural, why shouldn't we take advantage? The second form
reminds me too much of Java's "iterators", where 'i++' is spelled
'next(i)'.

> [...]
> Unless I'm missing something it is also as legible if not more so

Perhaps that's due to author bias. ;)

> [...]
> Alternatively if operator *() does not mean multiplication in the top
> example, then it is rather a misuse of the operator IMO.

I take it you haven't seen Spirit. ;)

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk