Quote:
1. macros have many, many uses.
Yeah they do. But I haven't really had many situations that I felt needed macros, I believe that they subtract from readability - it is harder to understand the code.
From the examples that you have given, I think each one would be better implemented in the language.
Quote:
Macro EQ ==
Macro NEQ !=
There is no good reason to ever do an assignment in a conditional expression within a scripting language. C++ maybe for optimisation purposes, but scripting language - no. So why don't we just use "="? It makes more sense than two capital letters.
Quote:
Macro Set =
Why? There is already a perfectly good operator that means assignment. I would even choose Pascal's ":=" over a set keyword.
Quote:
Macro isint(X) (cint(x) eq x)
Macro issquare(x) isint((z set sqr(y)))
integer r = 5;if (r.isint()) ...if (r.issquare()) ...
Quote:
Macro msgbox(x) eventsend:Msgbox(cstring(x))
gui.msgbox()
(takes strings, overloaded to take integers, and other datatypes also user overrideable)Macros Compared to Functions
Generic Programming Using Cee Macros
If you have more arguments for the inclusion of macros I would like to hear them.
Quote:
Also try to make a simple vm first, its less then an hours work to make a real good one, and it'll help you later. (when your trying to code for something which doesn't exist, it is Not Nice.)
Good idea, I have been playing around with parsing for quite some time now. Would be good to have something that works, even if I have to hand code the bytecode.
Quote:
Most of it would happen at compile time.
Sometimes it would happen at run-time (but rarely would you need to). Doing so is quite easy,
Get code for function,
Allocate new memory (for each var in function)
Copy function to new spot on the object array
Change vars in function.
All in all quite a fast job.
I've always been wary when thinking about reallocating whole arrays. It doesn't sound good in my book.
I like static. I like the idea that once some classes have been definied that they aren't going to change.
Quote:
Also, What i try and do, is keep a smallish array (or vector, in c++), which contains the jump points. These are points where your code should go to.
Something like
jmp GUID_OF_FUNCTION, GUID_OF_OBJECT, Line number
-1 (or NULL) should be used to signify My. (current object).
If your not using guids, then shame on you!
Shame on me.
I have some idea of what a guid is, and I think I am going to use something similar but I would like some explanation if possible. Globally Unique Identifier?
Each of my methods has a unique offset based on the distance it is from the first method in object. Each sub-class of object increases this offset with the methods it adds.
Object 0 init() 1 istype(class type)Integer : Object 0 init() (inherited from object - can be overridden) 1 istype() (inherited from object - can be overridden, not a goot idea to though) - new methods start here - 2 issquare() 3 multiply(integer i)Decimal : Object 0 init() 1 istype() - new methods start here - 2 convert_to_integer() 3 multiply(decimal d)NewInteger : Integer : Object 0 init() (inherited from object - can be overridden) 1 istype() (inherited from object - can be overridden, not a goot idea to though) - integer methods start here - 2 issquare() 3 multiply(integer i) - newinteger methods start here - 4 do_wacky(string s)
Also how do you keep these guid's over multiple compile sessions? What I want to do is have the ability to have multiple bytecode files and include them all in the virtual machine.
Quote:
With lists,
Make it a data type, and make the list, a list of type datatype.
That would allow you to have lists of lists of lists of lists, ect.
maybe have a few methods in list, like concatinate, sort, split-at, ect. to make things easier.
I am thinking about using the same syntax that Groovy uses.
integer i[] = [1, 2, 3]
or
integer[] i = [1, 2, 3]
Quote:
Have namespaces, and allow them to be changed at runtime (which would make things a lot easier).
The package system is a sort of namespace convention. I personally don't think namespace changing is good - it means that what you are doing probably isn't object orientated.
Quote:
Function pointers! (you do not know how good these are, until your using a language which doesn't support them!)
Methods are just another object, like classes and objects. They all can be stored in a "type" container. There will be a way to do something like:
integer i = 5method(multiply(integer)) m = method(i.multiply())i = i.call(m(i))
Or something similar. Need to work out calling conventions (ie what it returns, the arguments etc).
Quote:
Also, it would be nice to have a flexable grammer and/or reprogrammable grammer. (currently my parser, (with a bit of extra taggery) will accept C style for loops, basic style for loops, and with a bit of persuading, probably a few more types too!)
Maybe something like a grammer define tag?
GRAMMER ; NEWLINE
I like the simplistic approach. Cluttering up a language with extra syntax seems too much. If there are multiple ways to do something then people will use these different ways. I like to be able to look at some code and be able to work out what it does easily. This is a similar argument to the one against macros.
I'm a bit of an advocate for Self Documenting Code.