FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How close to ECMAscript 3 is MiniD?

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
inteja



Joined: 02 Jun 2005
Posts: 2

PostPosted: Thu Sep 27, 2007 1:47 am    Post subject: How close to ECMAscript 3 is MiniD? Reply with quote

I know MiniD is closer to D that ECMAScript but I was wondering how close it actually is to the ECMAScript 3 specification, that is, could MiniD be modified to bring it closer to ECMAScript? Is there some fundamental architectural difference that would make it problematic?

I realize there is DMDScript and Walnut but I gather the former is difficult to extend/integrate and incompatible with the latest D1 and the latter is inactive/incomplete.

I'd love to use MiniD as is, but it is important for my project to support ECMAScript.
Back to top
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Thu Sep 27, 2007 7:16 am    Post subject: Reply with quote

There are some pretty major differences. Here's what I've been able to come up with from my (limited) experience with ECMAScript and a look over the ECMAScript 3 spec.

  • MiniD uses a simple class-style OOP model, while ECMAScript uses prototype-based OOP. Most cases of prototype code can be pretty easily converted to class-style, but not always. For example, in MiniD, you declare all your members and methods in the class, and when you create an instance of that class, you cannot add any more members or methods to the instance, unlike in ECMAScript.
  • There are a few minor lexical differences. For example MiniD uses single quotes to indicate character literals, while ECMAScript uses single quotes as an alternative way to quote strings. ECMAScript also has Regex literals, MiniD does not.
  • Some syntactic differences. ECMAScript allows omission of semicolons, MiniD does not. MiniD allows multiple assignment, ECMAScript not. By extension, assignments of any kind in MiniD do not have any value, whereas they do in ECMAScript, meaning any expression with an assignment in it in ECMAScript is valid, but not in MiniD (so "x = y++;" is invalid MiniD code). MiniD doesn't have labels.
  • ECMAScript has just a Number type, which is a double-precision IEEE 754 float. MiniD has that (the float type), as well as the int type, which is (as of now) defined as a 32-bit int. This might be changed to be "the native int size for the platform MiniD was compiled on" sometime in the future.
  • ECMAScript's Objects map to tables, classes, and instances in MiniD. Some really tricky manual conversion has to happen here.
  • ECMAScript's function environments are different. Locals are kept in an object, meaning that eval() can use variables from the immediately surrounding function. In MiniD, locals are kept on the stack, and cannot be accessed by code in eval() (although globals can be). ECMAScript's scoping rules are also different because of this.
  • Both MiniD and ECMAScript pass a 'this' value to every function, method or not. However MiniD uses different rules to pass the 'this' parameter; 'this' can never be null in MiniD unless explicitly passed as so by using the 'with' keyword ("f(with null)"). In ECMAScript, 'null' is passed to 'this' when the function is not being called as a method, but in MiniD, the function's environment is passed instead.
  • MiniD distinguishes between concatenation (~ and ~=) and addition (+ and +=). ECMAScript uses the addition operators for both operations.
  • MiniD uses 'is' and '!is' instead of '===' and '!=='. They do virtually the same thing, however.
  • MiniD has no 'with' statements.
  • MiniD has a module and import system, ECMAScript does not.


So probably the most important differences are a completely different OOP model and a completely different scoping/local declaration model. There are similarities, but you'd have to change an awful lot to make MiniD ECMAScript 3-compliant.
Back to top
View user's profile Send private message
inteja



Joined: 02 Jun 2005
Posts: 2

PostPosted: Thu Sep 27, 2007 4:58 pm    Post subject: Reply with quote

JarrettBillingsley wrote:
So probably the most important differences are a completely different OOP model and a completely different scoping/local declaration model. There are similarities, but you'd have to change an awful lot to make MiniD ECMAScript 3-compliant.


Thanks so much for your comprehensive answer!

It looks like I'll need to revisit DMDScript or Walnut then. It's probably easier getting them to compile with D1 than hacking MiniD. However, I'd certainly like to add MiniD as an alternate scripting engine to my project. It looks very impressive!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group