Topic: return storage class and rl value specialization


Author: "terminator(jam)" <farid.mehrabi@gmail.com>
Date: Tue, 9 Oct 2007 12:10:37 CST
Raw View
Since delaration of C++ the r/l-valueness of objects has been source
of confusion there are some actions that can perform on lvalues but
not on rvalues , especifically on initrinsic types .BTW the programmer
is not capable of defining special interface for classes based on the
r/l-valueness of the object(the way we do for const/volatile).Move
proposal - about Hot(rvalue) refernce - has been an attempt to get
that different behavior at reference level with the focus on
constructors.I am going to make a more general offer which may affect
the proposed syntax for rvalue references .We can assume that rvalues
have a distinct storage class (say temporary or 'return'
storage),which is different in lifetime from 'auto' storage class.We
can assume that normal automatic variables have anti-return
('~return') storage:

struct A {
 A();
 A(A return&);//move constructor
 A(const A &);//copy constructor
 void either_side();//operates on both r and l value.
 void rvalue() return;//operate on rvalues.
 void const_lvalue() const ~return;//operate on const lvalues.
};

struct B {
 void F1();//provided for all objects
 void F1() return;//specialized for rvalues

 void F2();//provide for all objects
 void F2() ~return;//specialized for lvalues

 void F3() return;//specialized for rvalues
 void F3() ~return;//specialized for lvalues
};

Since it is meaningless to declare a value as rvalue,pointers and
objects cannot be declared as rvalue but refrences can,and casting
references from r to l or the vice-versa can be performed via side
casting:

return_cast<~return&> (return_cast<return&> (object));

for further keword extentions in language I suggest separating the
prefix from cast operators and declaring them as following macros in a
popular header:

//cast.h
#ifndef CAST_H
#define CAST_H

#define static_cast  static cast
#define dynamic_cast  dynamic cast
#define const_cast  const cast
#define reinterpret_cast do cast
#define return_cast  return cast

#endif

since const , static , do and return are existing keywords ,We have
produced five compound keywords declaring only two actual keywords,
this releases the dynamic keyword for later language extention.

regards,
FM.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]