Original Post
Hi, I am making a programming language. I have the , operator which is the tupling operator so that a,b is a tuple of a and b. I also have the boxing operator [ ] so that [a,b] is not a tuple. The [ ] boxes it into a single value. I added this operator to make it so that I can easily make templated containers. For example the list template takes a type as a template parameter for its element type. Using the boxing operator allows you to store boxed tuples in a list. Now I am considering making boxed variable declarations == class literals. So here is some code with tuples: int x , int y; (x,y)=(5,6); Now here is how some boxed code looks: [int,int] m; m = [5,6]; Now what if boxed declarations become class literals? [int x, int y] a; [int w, int z] b; a.x=5; a.y=6; a=[5,6]; //[5,6] is of type [int,int] which is convertable b=[5,6]; //also legal b=a; //illegal since a and b are different types Now I guess in this case the box would make it so that x and y are not independant; you have to prepend a. to get at them, because they are members. Ok now for handling inheritance I have been thinking of doing something like this class A = B += (int x, int y); //B is the superclass class A = B&&C += (int x, int y); //B and C are superclasses class A = B||C += (int x, int y); //the superclass of A is the common root of B and C, which will often be the empty class, which contains all objects. This would also allow you to create classes on the fly: A&&B ab; //ab is both an A and a B Now this would be useless in most languages but because in my language non-member functions are virtual (member functions never are, as there is no "this" pointer) it would be a useful feature, at least sometimes. Ok so now what happens when we bring class literals and set operators together? [int w, int x] && [int y, int z] my_object; my_object has four members: x, y, and z This makes compete sense and so far there are no problems. However boxes aren't limited to class literals. What should the meaning of this operation be: [5,6]&&[7,8] should it then be [5,6,7,8]? It would have to be, so that you can assign it to my_object above. Afterall those boxes do not represent lists or tuples. They do not represent sets. If you have four sets and you do this: (r,s)&&(t,u) the result will be: (r&&t,s&&u) which makes complete sense and is intuitive. Anyway, what about this: [int x, int y] && [int y, int z] or this: [int x, int y] && [int,int] I am inclined to think of [int,int] as a type literal, but not a class literal. Thus it would not have the && operator, but what about the first? Those aren't the same y. Now what if it went like this: class A = [int a]; class B = A + [int b]; class C = A + [int c]; class D = B&&C now obviously D should have a, b, and c members. Those are the same "a". It comes from B||C. So, your thoughts?