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

New to MiniD / Question about namespaces

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



Joined: 24 Nov 2007
Posts: 18

PostPosted: Mon Nov 26, 2007 3:09 pm    Post subject: New to MiniD / Question about namespaces Reply with quote

First of all ... congratulations. I've been looking for a scripting language for my project for a long time, and MiniD is very groovy (kinda miss a behave() function though, don't know why Very Happy ). Especially the tight integration with D, the exceptions and the GC is great. The "flow" from native to script and back is really seamless.

Now to my question: I want to export some functions from native code to my scripts and group them into categories. I thought namespaces were the way to go ... but I can't figure out how to add MDClosures to a namespace. Adding a global namespace is no problem, but ...

namespace["test"d] = new MDClosure(namespace, &test, "test");

... doesn't compile and ...

new MDClosure(namespace, &test, "test");

... does (obviously) not work. I think I'm missing something obvious here. Alternatively: Is there a way to create static members for classes? I didn't find anything in the docs on that.

-Mike
Back to top
View user's profile Send private message
vertex



Joined: 24 Nov 2007
Posts: 18

PostPosted: Mon Nov 26, 2007 3:39 pm    Post subject: The obvious ... Reply with quote

... is MDValue's static opCall Smile
Back to top
View user's profile Send private message
JarrettBillingsley



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

PostPosted: Mon Nov 26, 2007 3:50 pm    Post subject: Reply with quote

Quote:
First of all ... congratulations. I've been looking for a scripting language for my project for a long time, and MiniD is very groovy (kinda miss a behave() function though, don't know why Very Happy ). Especially the tight integration with D, the exceptions and the GC is great. The "flow" from native to script and back is really seamless.


Very Happy

Quote:
MDValue's static opCall Smile


Indeed Smile

Quote:
Is there a way to create static members for classes?


Nope. What's kind of odd though is that you can call methods of classes through the class, and the class will be passed as the 'this' to the method. In that way you can fake static methods, but those methods will also be available through the instances of that class, which could be a problem.

Static fields and methods is something I'm considering for MD2.
Back to top
View user's profile Send private message
vertex



Joined: 24 Nov 2007
Posts: 18

PostPosted: Mon Nov 26, 2007 4:32 pm    Post subject: Reply with quote

JarrettBillingsley wrote:

Nope. What's kind of odd though is that you can call methods of classes through the class, and the class will be passed as the 'this' to the method. In that way you can fake static methods, but those methods will also be available through the instances of that class, which could be a problem.

Static fields and methods is something I'm considering for MD2.


Static fields would be nice indeed. It's great that you're planning to support such things in the future. I'm playing with MiniD since yesterday and getting more impressed by the minute - it's an external library that's fun to link against! And it just works! You don't see that often. Too bad that I need to hold a seminar tomorrow Sad

Another thing: I want to replace writef/etc. with my own output functions (there's only one class in my program that is allowed to write to the console - it's a little command line editor and I need to update the prompt every new line). Is it okay to just hack baselib.d and replace the calls to Stdout?

-Mike
Back to top
View user's profile Send private message
JarrettBillingsley



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

PostPosted: Mon Nov 26, 2007 5:06 pm    Post subject: Reply with quote

Quote:
Another thing: I want to replace writef/etc. with my own output functions (there's only one class in my program that is allowed to write to the console - it's a little command line editor and I need to update the prompt every new line). Is it okay to just hack baselib.d and replace the calls to Stdout?


Either that, or you could write your new functions and just reassign the globals write[f][ln] to new function closures, like:

Code:
writefln = function(vararg)
{
    myStream.writefln(vararg);
};


You could do it with native closures too, of course.
Back to top
View user's profile Send private message
vertex



Joined: 24 Nov 2007
Posts: 18

PostPosted: Tue Nov 27, 2007 2:27 pm    Post subject: Perfect! Reply with quote

Smile

And thanks for the fast response!
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