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

Classes in MiniD 2?

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



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Thu May 22, 2008 8:59 pm    Post subject: Classes in MiniD 2? Reply with quote

Hi,

From the MiniD 2 spec, it looks like classes aren't supported, and instead everything is prototype-based. Then, in order to get your modifications persisted when you clone one object, you have to override the clone method.

This seems like the worst of both worlds, though. I define an object, but in order to get the definition persisted, I have to duplicate everything in the clone method.

Am I just misunderstanding the examples?
Back to top
View user's profile Send private message AIM Address
JarrettBillingsley



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

PostPosted: Fri May 23, 2008 12:18 pm    Post subject: Reply with quote

You're probably just misunderstanding Smile

When you clone an object, the new object has the original object as its prototype and so it acts like it has all the same fields and methods. So any modifications you made to the source object will appear in the cloned object since, well, the cloned object points to the source object. Then if you modify the cloned object, it makes those modifications to itself.

Though maybe I'm not understanding what the problem is; could you give an example of what you think the problem is?
Back to top
View user's profile Send private message
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Fri May 23, 2008 5:26 pm    Post subject: Reply with quote

No, you're right, I was just misunderstanding.

Would there be any way to protect an object from being modified I'm interested in using MiniD for a MUD, and that involves access control. I don't want some random coder (or myself!) to accidentally or maliciously alter the Item prototype in the code for some random object.

I could probably recompile all referenced modules each time, which would be secure but wasteful. Or I could face reality, and realize that I'm the only one who's ever going to use the system, and not worry about it.
Back to top
View user's profile Send private message AIM Address
JarrettBillingsley



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

PostPosted: Fri May 23, 2008 6:35 pm    Post subject: Reply with quote

You'll have to face reality Wink because the language doesn't provide any mechanisms for preventing modifications of objects. Even if you compile a module to a binary file, that's not really doing anything special -- it's just saving you the compilation step the next time. Binary modules are just a dump of what's in memory after you compile a module.

In fact I switched from class-based OO to prototypes partly because they were more flexible and dynamically modifiable. So.. yeah.

If you're worried about the security of the scripts (i.e. someone modifying Object.clone so that it would erase the hard drive), it's simple to prevent stuff like that -- just don't provide potentially harmful functionality to the scripts. As long as your host program caught scripting exceptions, the worst someone could do would be to crash a script, which isn't all that bad. I mean, in comparison to possible security holes.
Back to top
View user's profile Send private message
dhasenan



Joined: 03 Feb 2005
Posts: 73
Location: New York

PostPosted: Fri May 23, 2008 8:10 pm    Post subject: Reply with quote

I'm more concerned about someone modifying BaseSword to do 5000000 damage or some such foolery. If I compile everything separately, though, and execute them in their own environments (if that's possible, given the architecture of the system), modifying BaseSword can only affect one inheritor of BaseSword.

But this isn't yet worth worrying about. And when it is, I can just stuff all the readonly objects into one region of memory and mprotect them as readonly.
Back to top
View user's profile Send private message AIM Address
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