The way I would describe my concept language is a mix between C++ and Java, with more emphasis on OOP than Java and a few extra features.
First and foremost is the paradigm: Everything save keywords and syntax is an inheritable type, including functions, pointers, references, built-in types, and even the object's type. Some of the built-in types I've thought of so far are:
complex - 9i would return complex(0,9)
double
float
long - 8 bytes long
int
short
char
wchar - same as wchar_t
byte - this is one of 3 types that aren't defined in an automatically included file
void
any - like boost::any, except that its type is the type of the object it's holding (1 of the 3 types not defined)
array - a multi-dimensional array, 1 of the 3... (takes place of new[] and delete[]) - this type is returned by {values,...}
string - an array optimized for characters (returned by "value")
typeid - I wasn't sure what to call it, so I went with the C++ standard. This is an objects type, returned by typeof(). Also, you can use this to cast objects.
function - an array optimized for commands. It can be defined 2 ways:
1 2 3
|
function<rettype> foo(T param1,U param2,...)={/*code*/}
//or this, for familiarity
rettype foo(T param1,U param2,...){/*code*/}
|
va_list - like the C++ va_list, except that it stores the type and number of parameters
pointer - an optimized array of bytes that stores an address (same overloads as C++ pointer)
reference - same as pointer, but the syntax is like a C++ reference
New keywords:
addressof(object) - returns the address of an object (pointer)
typeof(object/class) - returns the type of an object (typeid)
sizeof(object/class) - returns the size of an object (int)
dereference(pointer) - returns the object at the address (this is used in the pointer and reference classes)
execute(function) - runs an array of commands and stops at the end (used by function)
extend - used to extend the definition of a class:
1 2
|
extend classname{
type newmember;};
|
alias - takes the place of typedef
rename - renames a class or object (the old name is no longer valid)
undefine - undefines a class or class member
redefine - more of a shortcut because the same thing can be achieved with undefine and extend, but this redefines a class or class member
lexical_cast - same as boost::lexical_cast
self - self=*this
I don't think I'm going to include goto, register, union, auto, const_cast,
Changes to operators:
No new[] or delete[] (handled by array)
operator. is now overloadable
Changes to syntax:
I don't really like how case, public, protected, and private are used. If I were to make this language, instead of public: it would be public{/*members*/}
Preprocessors:
include <filename>- the same as #include, except it always appends a newline to the file being copied
link <DLLname> <Library name> - link the file to a DLL
I'm debating whether a macro preprocessor should be included
Also, I was thinking that a repeat(numtimes) control structure would be cool
So, what do you guys think?