Language concept.
Posted: Sun Sep 06, 2009 3:42 pm
I have this idea for a programming language similar to JavaScript and Objective-C. I'd like to know what you think, and maybe you could point out some issues with it.
Codename for the idea right now is Dao.
The main idea I have right now is that every statement is a call to a method of the global object. So, like how window. is prefixed to every variable in javascript, god. is prefixed to every statement in Dao (god doesn't necessarily have to be what the global object is called, I haven't yet decided). define is a method of the global object that takes one argument, the name of the property to define.
So this is actually a global object method being called. Notice how there are no (parenthesis) to call a function/method. Method's are called by simply passing an argument to them. Arguments are comma delimited.
There are hardly any operators in Dao. Rather there are just methods/functions. Every newly define variable is an object with a default set of properties.
Notice how there are two semi-colons on the last statement. This is because there are actually two statements there. The first being foo.equals ...;. The second being foo.minus 12;, which is passed as the first argument to the first statement. Think of a statement as just a value returned. Every statement returns a value so can then be passed as a value to a method.
The statement terminator operator not only ends the statement but is used as a delimiter too. It can act like a , (comma). For example:
is in javascript:
Also I'm thinking of being able to use the name of a parameter as a label for the argument. This way the order of the arguments doesn't matter:
As you can see this is a very powerful concept. It is also possible to pass as many arguments to a method as you want, whether the method excepts these arguments is another thing.
This is all I have so far. I have yet to define the syntax involved for defining methods (eek, that's sounds a bit confuzling :S). Let me know what you think, and if you have any questions.
Philosophy: (now for some blab; you don't need to understand this)
left-to-right-ism: Basically the philosophy is that we write from left to right so we should program from left to right. So the code shouldn't force you to use the arrow keys much. I'm not sure how I'm going to accomplish this, but it seems like I'm doing okay at it.
self-programmable: I want the language to be very flexible, so flexible that perhaps able to program itself thus altering the language a bit. Kinda like how JavaScript is so flexible that we can actually create our own patterns. Kinda how jQuery has altered the pattern in which we access the DOM, I want Dao to be able to be extended in that way but not limited to that way.
I'm thinking of containing the entire language within the god object, or something. An example of this is would be that every literal would be an property of the god object, and it would be an object itself:
Codename for the idea right now is Dao.
The main idea I have right now is that every statement is a call to a method of the global object. So, like how window. is prefixed to every variable in javascript, god. is prefixed to every statement in Dao (god doesn't necessarily have to be what the global object is called, I haven't yet decided). define is a method of the global object that takes one argument, the name of the property to define.
Code: Select all
define "foo";Code: Select all
method arg1, arg2, arg3, ...;Code: Select all
define "foo"; //Creates the property foo
foo.equals 23; //foo now equals 23
foo.plus 9; //foo remains 23, rather this statement returns (foo + 9) which is 32
foo.equals foo.minus 12;; //foo = foo - 12 = 11
The statement terminator operator not only ends the statement but is used as a delimiter too. It can act like a , (comma). For example:
Code: Select all
method 1, method 1, 2, 3; 2, 3;Code: Select all
method(1, method(1, 2, 3), 2, 3);Code: Select all
method arg1:1, arg2: 2, arg3: 3;
method arg2:2, arg3:3, arg1:1;
method arg3:3;This is all I have so far. I have yet to define the syntax involved for defining methods (eek, that's sounds a bit confuzling :S). Let me know what you think, and if you have any questions.
Philosophy: (now for some blab; you don't need to understand this)
left-to-right-ism: Basically the philosophy is that we write from left to right so we should program from left to right. So the code shouldn't force you to use the arrow keys much. I'm not sure how I'm going to accomplish this, but it seems like I'm doing okay at it.
self-programmable: I want the language to be very flexible, so flexible that perhaps able to program itself thus altering the language a bit. Kinda like how JavaScript is so flexible that we can actually create our own patterns. Kinda how jQuery has altered the pattern in which we access the DOM, I want Dao to be able to be extended in that way but not limited to that way.
I'm thinking of containing the entire language within the god object, or something. An example of this is would be that every literal would be an property of the god object, and it would be an object itself:
Code: Select all
11.plus 12; //Would return 23
//We could go crazy with methods for the literal classes
23.each method; //calls method 23 times
"foo".reverse null; //returns the string "foo" reversed "oof". We pass null as the first parameter just to call the function. It could of easily have been 0 or any value.