What does it take to make a language

Pages: 123
Uhh, that enum thing works if regValue is an int... just saying.
That interface stufff looks awesome, actually! I often have this problem where I want to avoid the deadly diamond but tere doesn't seem to be a way.
jsmith, I don't see how these interfaces would be different from base abstract classes. What would they allow you to do that is not possible in C++?
It would allow a programming to inherit a specific group of members that could be defined - when a class inherits from an abstract class, it gets all of its undefined members.

One thing that I don't like about that is that only a specific class can inherit those members - maybe you could name the interface and have classes inherit from it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Car {
	public{
		Car();
		interface Driver{
			bool StartEngine();
			void StopEngine();
			void ShiftGear( Gear newGear );}
		interface Passenger{
			void TurnOnRadio();
			void TurnOffRadio();}
		interface Mechanic{
			void PopHood();}}};

class driver:public Car,Car::Driver{
	public{
		int dostuff();}};

Also, I was looking at a wikipedia article (http://en.wikipedia.org/wiki/Diamond_problem) and I thought that the JavaFX method of handling it was a really good idea - what do you guys think?
A few new ideas:

Function, pointer, and typeid should be built-in types

I was thinking that it would be cool to borrow from python and have a class that has operator overloads for & and = that every class inherits from

Borrowing further from python, I like how I can make a substring using string[first:last], and a : operator could easily do that. If : is overloaded, then I don't think I'll keep bool?true:false.

I also like the idea of a tuple - maybe the class inherited by everything could include a , operator?

While I was thinking of a way to overload the () operator for the reference class, I thought of a really good idea - the () operator takes a va_list type, and the parameters that it's defined as having are just a shorthand for taking parameters out of the list:

1
2
3
4
5
6
7
8
//this
int add(int n1,int n2){
    return n1+n2;}
//is the same as this
int add(va_list& args){
    int n1=args.pop_front();
    int n2=args.pop_front();
    return n1+n2;}

One more thing: should I allow global variables as in C/C++, or require them to be encapsulated by a type as in Java?

What do you guys think?
Last edited on
Topic archived. No new replies allowed.
Pages: 123