Scripting Language

Everything about development and the OpenMW source code.
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

Just a question Zini. How do you mean to improve/fix the morrowind script language?

Do you want to add a new keyword to enable the improvements? Or something different?

E.g.

Code: Select all

%here scripting is insane morrowind default

braindead mode off

%here scripting is sane
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Scripting Language

Post by Zini »

Don't have the time to go into details now. After 1.0 I will post a design document that probably will span a thread with multiple postings. I can give you a few keywords:

- new script types
- new variable scopes
- new variable types
- new control structures
- controllable, deterministic throttling
- a function call mechanism
- a strict mode that takes care of most of the syntactic oddities
- adding missing operators
- adding missing functions
- fully forward and backward compatible by using a script version/flavour identifier at the top of each script (defaulting to vanilla scripts, if not present; automatically inserted by the editor for new scripts)

For the most part I have it already worked out. Just need to write it down.

The MW scripting language is actually easy to fix. The only thing we can't do much about is the verbosity. Everything else is a piece of cake.
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

Zini wrote:- fully forward and backward compatible by using a script version/flavour identifier at the top of each script (defaulting to vanilla scripts, if not present; automatically inserted by the editor for new scripts)
Thanks for the answer, I was just curious about the quoted point. My question was badly written, I did not mean to have a full-blown description of the improvements right now.
Yacoby
Posts: 119
Joined: 30 Sep 2011, 09:42

Re: Scripting Language

Post by Yacoby »

Zini wrote:The MW scripting language is actually easy to fix. The only thing we can't do much about is the verbosity. Everything else is a piece of cake.
As long as we agree designing a language is not easy or trivial and we steal ideas/concepts from other languages, maybe base it on Python as a fairly sane language.

What I mean is things like, if we are going to have functions it makes scene to at least give them a type so we can have higher order functions.

Better idea. Can we just have a simple versions of Haskells type system :P (This is semi serious, it is a far better type system than in C imho)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Scripting Language

Post by Zini »

The MW scripting language has a type system (although it doesn't have many types). I think we should generally go for the most easy and natural expansion of the language, which in this case means adding the missing types.

As for functions (actually scripts that are called as functions from other scripts), these obviously need typed argument and return value lists, that need to match with the call (which can be verified when compiling).
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

It is really soon to talk about this. But Python is an example of how do it right. Duck typing, strongly typed, everything is a class, passage only by reference, no implicit conversions.

In a scripting language I would avoid the immutable objects so there is no confusion with calls that look like pass-by-value.

Of course Python is meant to be easy to use for programmers, but definitely not easy for whom write interpreters or compilers... so I can understand if openmw will do differently.

What is really important is doing something that is reasonable and that avoids the original morrowind nonsense like ``x.y is a read-only reference''...
Yacoby
Posts: 119
Joined: 30 Sep 2011, 09:42

Re: Scripting Language

Post by Yacoby »

ezzetabi wrote:It is really soon to talk about this. But Python is an example of how do it right. Duck typing, strongly typed, everything is a class, passage only by reference, no implicit conversions.
Python is pass by value ;)

But I agree with Zini that if we are going to extend the language we should probably do so as a natural expansion of MW and the MW type system. I would just debate about where to go with the language.
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

It is debatable. Read the Martelli quote here:

http://bytes.com/topic/python/answers/3 ... -reference

Python is so ahead that even the terminology has problem following it :D
Yacoby
Posts: 119
Joined: 30 Sep 2011, 09:42

Re: Scripting Language

Post by Yacoby »

Python is pass by value. There is a subtle but important difference between passing by reference and passing references by value, but passing references by value doesn't make it pass by value. From a quick read of that thread they seem fairly confused as to what a value is in python and what is immutable and what isn't.

The simple test to see if a language is pass by reference is to see if you can write a simple swap function (One that doesn't involve looking at the stack frame). In python you can't. Hence is isn't pass by reference.
ezzetabi
Posts: 407
Joined: 03 Feb 2012, 16:52

Re: Scripting Language

Post by ezzetabi »

Post Reply