Jump to page: 1 2 3
Thread overview
Re: DMDScript now under Boost license
Mar 29, 2010
strtr
Mar 29, 2010
Walter Bright
Mar 29, 2010
Adam Ruppe
Mar 29, 2010
Robert Clipsham
Mar 29, 2010
Adam D. Ruppe
Mar 29, 2010
Robert Clipsham
Mar 29, 2010
Adam D. Ruppe
Mar 29, 2010
Robert Clipsham
Mar 30, 2010
Adam Ruppe
Mar 31, 2010
Adam Ruppe
Apr 03, 2010
Bernard Helyer
Mar 31, 2010
Philippe Sigaud
Mar 31, 2010
Adam D. Ruppe
Mar 31, 2010
Philippe Sigaud
Mar 31, 2010
Adam D. Ruppe
Mar 31, 2010
Philippe Sigaud
Mar 30, 2010
strtr
Mar 30, 2010
Walter Bright
Mar 30, 2010
strtr
Mar 30, 2010
bearophile
Mar 31, 2010
bearophile
March 29, 2010
Walter Bright Wrote:

> http://www.digitalmars.com/dscript/index.html

Would it be possible to have some sort of scripting as part of D?


March 29, 2010
strtr wrote:
> Walter Bright Wrote:
> 
>> http://www.digitalmars.com/dscript/index.html
> 
> Would it be possible to have some sort of scripting as part of D?

What did you have in mind?
March 29, 2010
I think it would be pretty great if you could add functions, etc., to the scripting language with a simple one liner:

mixin makeAccessibleFromScript!(scriptEngine, foo);

Or something similar. The template there could mix in a wrapper function for whatever foo() happens to be, and register it with the scripting engine all in one call.

Then, to call a function defined in script, you should be able to just do callScriptFunction("name", args...);, but this is optional; I say getting D functions accessible from the script with ease is more important.


Anyway, you take that and the dmdscript and package them together as an D extender library. To use it, you just import the script module, mixin the template to extend it, and boom, done.


Perhaps down the line, a magic function could even look for @scriptable attributes* and add them automatically. But no need immediately.

* I'll say again, I'd love to have user defined attributes accessible from __traits for just this kind of thing.

On 3/29/10, Walter Bright <newshound1@digitalmars.com> wrote:
> strtr wrote:
>> Walter Bright Wrote:
>>
>>> http://www.digitalmars.com/dscript/index.html
>>
>> Would it be possible to have some sort of scripting as part of D?
>
> What did you have in mind?
>
March 29, 2010
On 29/03/10 18:41, Adam Ruppe wrote:
> I think it would be pretty great if you could add functions, etc., to
> the scripting language with a simple one liner:
>
> mixin makeAccessibleFromScript!(scriptEngine, foo);

You can do with with MiniD, LuaD, PyD, Monster, and possibly others to allow you to script in minid, lua, python an monster (I think there's something for ruby out there too). I haven't played with dmdscript, but I'd guess there's a simple way to expose D functions to it.

> Or something similar. The template there could mix in a wrapper
> function for whatever foo() happens to be, and register it with the
> scripting engine all in one call.
>
> Then, to call a function defined in script, you should be able to just
> do callScriptFunction("name", args...);, but this is optional; I say
> getting D functions accessible from the script with ease is more
> important.

All of the above languages/wrappers have some way of doing this, with various degrees of simplicity/ease.

> Anyway, you take that and the dmdscript and package them together as
> an D extender library. To use it, you just import the script module,
> mixin the template to extend it, and boom, done.

I don't think this is a good idea, unless a decent policy for what is included can be figured out. That said, I believe there's an old version of dmd packaged with projects that work with it.

> Perhaps down the line, a magic function could even look for
> @scriptable attributes* and add them automatically. But no need
> immediately.
>
> * I'll say again, I'd love to have user defined attributes accessible
> from __traits for just this kind of thing.

I'm pretty sure user defined attributes aren't in for D2, it looks like it'll be D3 or later if/when we get them.
March 29, 2010
On Mon, Mar 29, 2010 at 06:49:35PM +0100, Robert Clipsham wrote:
> I haven't played with dmdscript, but I'd guess there's a simple way to expose D functions to it.

It isn't terribly complex, but it is a bit wordy. The docs are here: http://www.digitalmars.com/dscript/extending.html

You have to make your function in a certain convention, then register it using a struct and a function.

The function convention gives you the most access to the script environment, but it is a pain to write all your functions that way.

> I'm pretty sure user defined attributes aren't in for D2, it looks like it'll be D3 or later if/when we get them.

Indeed. But everyone on this group needs /some/ wish feature to bring up at every opportunity, right? :-P

-- 
Adam D. Ruppe
http://arsdnet.net
March 29, 2010
On 29/03/10 19:30, Adam D. Ruppe wrote:
> On Mon, Mar 29, 2010 at 06:49:35PM +0100, Robert Clipsham wrote:
>> I haven't played with dmdscript, but
>> I'd guess there's a simple way to expose D functions to it.
>
> It isn't terribly complex, but it is a bit wordy. The docs are
> here: http://www.digitalmars.com/dscript/extending.html
>
> You have to make your function in a certain convention, then
> register it using a struct and a function.
>
> The function convention gives you the most access to the script
> environment, but it is a pain to write all your functions that way.

You could always write a nice wrapper function/template which automatically does all that guff for you :) If you do, I'm sure Walter wouldn't mind adding it into dmdscript providing you license it appropriately :)

>> I'm pretty sure user defined attributes aren't in for D2, it looks like
>> it'll be D3 or later if/when we get them.
>
> Indeed. But everyone on this group needs /some/ wish feature
> to bring up at every opportunity, right? :-P

Agreed :) Guess I need to go and sit in a corner until I think of a feature, then I can come back to the group a true D user :P
March 29, 2010
On Mon, Mar 29, 2010 at 07:45:39PM +0100, Robert Clipsham wrote:
> You could always write a nice wrapper function/template which automatically does all that guff for you :) If you do, I'm sure Walter wouldn't mind adding it into dmdscript providing you license it appropriately :)

Yup, that's what I'm thinking about in these messages. The one problem point might be dmdscript is D1 IIRC.

I'll have to grab the updated source and see what I can make of it.

> Agreed :) Guess I need to go and sit in a corner until I think of a feature, then I can come back to the group a true D user :P

Make sure it is something that's been done to death and only marginally useful anyway for big bonus points!

-- 
Adam D. Ruppe
http://arsdnet.net
March 29, 2010
On 29/03/10 20:07, Adam D. Ruppe wrote:
> On Mon, Mar 29, 2010 at 07:45:39PM +0100, Robert Clipsham wrote:
>> You could always write a nice wrapper function/template which
>> automatically does all that guff for you :) If you do, I'm sure Walter
>> wouldn't mind adding it into dmdscript providing you license it
>> appropriately :)
>
> Yup, that's what I'm thinking about in these messages. The one
> problem point might be dmdscript is D1 IIRC.
>
> I'll have to grab the updated source and see what I can make of it.

I seem to recall it is, and a fairly old D1 at that... You could always update it and send a patch Walter's way, see if he accepts it :)

>> Agreed :) Guess I need to go and sit in a corner until I think of a
>> feature, then I can come back to the group a true D user :P
>
> Make sure it is something that's been done to death and only
> marginally useful anyway for big bonus points!

Hmm, I'll definitely be wanting the bonus points... This is gonna need some thinking!

March 30, 2010
Walter Bright Wrote:

> strtr wrote:
> > Walter Bright Wrote:
> > 
> >> http://www.digitalmars.com/dscript/index.html
> > 
> > Would it be possible to have some sort of scripting as part of D?
> 
> What did you have in mind?

Scripting in de form of a dialect/subset of D in the std/language.
I don't know enough about scripting to say anything specific/useful.
It's just that if scripting were part of D, I would have used it already where the possibilities mentioned by Robert Clipsham just look that much bigger a step.
And being part of the language/community simply instils trust.
March 30, 2010
strtr wrote:
> Scripting in de form of a dialect/subset of D in the std/language.
> I don't know enough about scripting to say anything specific/useful.
> It's just that if scripting were part of D, I would have used it already where the possibilities mentioned by Robert Clipsham just look that much bigger a step.
> And being part of the language/community simply instils trust.

I thought about that a lot, but CTFE seems to fill that gap well enough.
« First   ‹ Prev
1 2 3