Pal: A problem with this translation is that the semantics of C++ const is unclear.
On Thu, Mar 24, 2011 at 3:02 PM, Pal Engstad <[email protected]>wrote: > Interesting. A conversion to C++ shows that C++ will not accept it. > > #include <iostream> > > struct S { > const int a; > const S *n; > S(const int a_, const S * n_) > : a(a_), n(n_) > {} > }; > > struct C { > S s; > C(S s_) : s(s_) {} > }; > > void test(const S *c, S *m) > { > auto cont = new C(S(5, NULL)); > auto chain = new S(4, &cont->s); > // cont->s = S(6, new S(7, NULL)); // non-static const member const > int S::a, can't use default assignment operator > // cont->s.a = 6; // assignment of read-only > data-member S::a > cont->s.n = new S(7, NULL); > } > > ________________________________________ > From: [email protected] [[email protected]] On > Behalf Of Pal Engstad [[email protected]] > Sent: Thursday, March 24, 2011 2:40 PM > To: Discussions about the BitC language > Subject: Re: [bitc-dev] Mutability, again > > I meant pointer-to-const, but I think I got it the wrong way: > > void f(const Pair *a, const Pair *b); > void g(Pair *a, Pair *b); > > void test(const Pair *c, Pair *m) > { > f(c, m); // No error or warning. > g(c, m); // Error > } > > const.cc:11: error: invalid conversion from const Pair* to Pair* > const.cc:11: error: initializing argument 1 of void g(Pair*, Pair*) > > PKE. > ________________________________________ > From: [email protected] [[email protected]] On > Behalf Of Jonathan S. Shapiro [[email protected]] > Sent: Thursday, March 24, 2011 2:26 PM > To: Discussions about the BitC language > Subject: Re: [bitc-dev] Mutability, again > > On Thu, Mar 24, 2011 at 1:53 PM, Pal Engstad <[email protected] > <mailto:[email protected]>> wrote: > Well, the problem is akin to using a pointer as an argument to a function > accepting a const-pointer (in C++), which is an error. I would expect BitC > to be at least as stringent! > > const pointer or pointer to const? > > _______________________________________________ > bitc-dev mailing list > [email protected] > http://www.coyotos.org/mailman/listinfo/bitc-dev > > _______________________________________________ > bitc-dev mailing list > [email protected] > http://www.coyotos.org/mailman/listinfo/bitc-dev > >
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
