Boost logo

Boost :

From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2002-10-13 12:37:01


Daniel Frey <daniel.frey_at_[hidden]> writes:

| > We're specifically talking of *iterators* I've yet to see an
| > implementation of an iterator where your example would be any
| > improvement.
|
| I was talking about returning T or const T in general.

May I recall that the message with
  
  Message-ID: <m3bs5ytp0f.fsf_at_[hidden]>

you were replying to was concerned with *iterators*?

| > | To me, it is something that I can read.
| >
| > Interesting. So you can read a reference. How?
|
| I knew it was going in the wrong direction :) I mean the sematic of
| "value" against the semantic of "object". I don't refer to the standard

Me neither. I was talking of how I perceive what functions do --
and I don't think of references as values, when using C++.

[...]

| > | It's different from an "object", which is something you can change.
|
| An example: 42 is a value.

42 is an integer literal, of type int.

| An 'int' which holds the value 42 is an
| "object", as you can modify it.

That drives to confusion: 42 is certainly of type 'int' and holds the
value 42. Or, we'll have to be careful about "hold" :-)

Well, the point is that the distinction would be at level of literal
vs. objects instead of value vs. object.

| You modify the object so it represents a
| different value. Hm... it hard to express what I mean as english is not
| my native language, but I hope you get the idea anyway :)

I'm not sure it really has to do with English -- my native language is
really far different from English, but that is driving us to
distraction.

The distinction you're trying to make isn't that easy if some
confusions aren't cleared out.

[...]

| It seems that I mean (ii) to be called an object and (iii) a value. I
| know these may not be the correct technical terms. Anyway I don't want
| to say the all functions should return values, but I mean that functions
| should decide on (ii) or (iii) based on the sematic. When you implement
| a function which semantically return (ii), you return a T. If you have a
| function which semantically returns (iii), it can be 'const T' or 'const

I can't follow. If the function is returning (iii), then there are
things I can do with it I can't do with a 'const T' -- taking its
address for example. So replacing a reference with 'const T' is a
semantic shift -- not something transparent. If I return a reference,
I mean it.

-- Gaby


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