iterators again
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sat Jun 2 10:56:40 PDT 2007
Walter Bright wrote:
> Bruno Medeiros wrote:
>> For example, in their proposal, I still don't what is the
>> typeof(fooptr) as in the code below:
>> final foo;
>> auto fooptr = &foo;
>> even though I asked 2 or 3 times now.
>
> It'll be an error, since there's no way to deduce the type of foo. But
> let's rewrite it as:
> final int foo;
> auto fooptr = &foo;
> Since foo cannot change its value, then fooptr must be an invariant(int)*.
>
>
Duh, yes, I forgot the type.
Anyways, you've said before that invariant, like const, only applies to
referenced data, and not to the immediate value. Such that const or
invariant on primitive types has no effect:
const int a; // no effect, same as a normal int.
If that is the case, then do invariant(int) and invariant(const), as in
the fooptr example above, have different semantics? Do they apply to the
immediate value when used with that parenthesis syntax? Meaning that the
following two vars would have different constraints? :
invariant(int) i1;
invariant int i2;
Second, let's change the first example, let's have a Foo instead of an int:
final Foo foo;
auto fooptr = &foo;
What would be the type of fooptr? Would it also be invariant(Foo)* ?
What would be the type of *fooptr? Would it be invariant(Foo) ?
If so, would that mean that the following would not be allowed:
(*fooptr).membervar = 42 ;
even though this is:
foo.membervar = 42;
?
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list