Oi! I've been searching and searching unable to find where to get my question answered so I decided to give a shot here.
I've created a language that I call Madness Script and is a hobby project. Now I've tried to find some way to classify it though with no prevail. I know it's dynamic typed and safe-typed. It's partly objective based on Ruby's version of Smalltalk messaging. With partly objective I mean that there exists objects and you can send a "message" to the object by a dot-notation to invoke a method.
So far I got it covered but then here comes the tricky part. Control-structures like if or while exists as objects which can be attained and used like this:
This will loop 5 times print the numbers of i. As far as I know it, my language is the only one that has it like this. There exists control structures that is part of the syntax, but these work more like goto statements and the Loop object uses those internally.Code:loop = Kernel.NewLoop(#i = 0#) loop < Kernel.PrintLine(i) loop < i = i + 1 // += is not implemented yet loop.While(#Compare.LessThan(i 5)#)
Creating classes and methods at runtime in code also works like this.
Going into detail how it works can be a little messy and hope this is enough. There are some other stuff I am uncertain of, but this is the main thing that is bugging me. The best I can come up with is saying that it is... eer "Variable-based" or something like that? Since what normal languages see as part of the syntax is instead variables/objects/instances and function calls.Code:Person = Kernel.NewDynamicClass("Person") PersonInit = Person.NewInstanceMethod("@init" "n") PersonInit < self.AddInstanceVariable("name" n) PersonGetName = Person.NewInstanceMethod("GetName") PersonGetName < name p = Person.New("John Doe") p_name = p.GetName() Kernel.PrintLine(p_name)
Then there is the "reflective" part. the <-operator allows to insert code into an object and you can access the inheritance table and the associated methods to each class trough methods of the objects of either the instance or the class.
I might be very wrong about some parts. I do not go to any computer-science classes or anything like that. Everything I know has been learnt by hand trough books or internet.
I hope I didn't post this under the wrong category and any help or comment is appreciated. If you think my language is ineffective in it's syntax/structure then I want you to keep in mind that as I told you before, it's a hobby project and is not meant to be able to compete with real languages.
If you need more information you can most probably find it on my website but since I have a post count less than 10, it doesn't let me post the link.
It looks like it's an object-oriented scripting language. It doesn't quite feel like it's a functional language. Clearly, it's as seems to have structured/procedural language support as well.
The only real critique I can see is your mechanism for declaring methods of classes. I would think something like this would be clearer:
Code:Person = Kernel.NewDynamicClass("Person") Person < Init = Person.NewInstanceMethod("@init" "n") Person < Init < self.AddInstanceVariable("name" n) Person < GetName = Person.NewInstanceMethod("GetName") Person < GetName < name p = Person.New("John Doe") p_name = p.GetName() Kernel.PrintLine(p_name)
Hmm I like the idea! Though it would mean that you have to at the end tell the object to "compile" the code that is in it's scope. It's something that I didn't explain as I didn't see the need for it. Every object got it's own scope (Like in C++ you got Global scope and function scope) and the <-operator let's you put some code into that scope but it won't be executed until explicitly told to run it(Compare with the loop example) So something like?
Thanks for the reply. What do you mean with this?Code:Person = Kernel.NewDynamicClass("Person") Person < Init = Person.NewInstanceMethod("@init" "n") Person < Init < self.AddInstanceVariable("name" n) Person < GetName = Person.NewInstanceMethod("GetName") Person < GetName < name Person.Compile() p = Person.New("John Doe") p_name = p.GetName() Kernel.PrintLine(p_name)
Is that like, how C is?it's as seems to have structured/procedural language support as well.
C++ is an example of a multi-paradigm language. The code within a function/method is procedural (or structured). Support for classes makes it OOP. Support for templates makes it generic. C is a good example of procedural but not OOP/generic. Haskell would be an example of functional.
Okay. So you could say that it follows C++ example? Except for being Generic. I don't feel the need for generic paradigm. Since the type is determined at run-time and all objects inherit from "Object".
Having the syntax minimal and keeping common syntax structures as variables/objects doesn't change anything? All syntax will in the next version also be capable of being overridden by objects making it possible to rewrite the whole language if wanted trough the actual script-language without writing anything in the source code of the interpreter.
Redefining the language could be interesting.
Yeah thought so too. It would be something like this (I'm currently working on the details so this is just a draft)
@ signifies private methods normally in my language so I thought that it would also be suitable to represent other internal things of objects. So a '@operator'-method is applied to all operations internally while a 'operator'method is only applied to operations concerning the object.Code:EqualOverride = self.NewMethod("@=" "value" "newValue") < newValue // Since we override the = sign we need to make it first return the newValue to get the normal operation EqualOverride < Kernel.PrintLine(value " = " newValue) EqualOverride < newValue var = 5 // Will print out '(nil) = 5' var = var + 1 // Will print out '5 = 6' PlusOverride = self.NewMethod("+" "value") // This will print out '(nil) = <LoadedFile.+:0xAdress>' PlusOverride < Kernel.PrintLine(self " + " value) self + 5 // This will print out '<LoadedFile:file.script> + 5'
Now.. what kind of paradigm is this? Is there even a paradigm for this? If not what could it be called? Variable-syntax paradigm?
** EDIT **
Forgot that this applies to literal values too like numbers and strings. So objects can override these too. This applies to ALL syntax in the language and not just some operators which I demonstrates.
Last edited by Groogy; 05-23-2009 at 06:53 AM.
C++ has limited operator-overloading. You can't redefine default operator definitions or create new operators. It sounds like a language feature rather than a paradigm.
Hmm okay. Well I hoped it would fall into some kind of category under metaprogramming or something like that.
Does its category really matter? >.> <.<
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks