Are there any D scripting engines for use with D?

2016-01-04 Thread Jason Jeffory via Digitalmars-d-learn
We have many scripting engines available for use in D more or less(lua, python, etc...). Is there a D scripting engine that can be easily integrated into a D project? A sort of "exec()". Something that works at compile time and run time possibly? If is a static string then it should be able

Re: Are there any D scripting engines for use with D?

2016-01-04 Thread yawniek via Digitalmars-d-learn
On Monday, 4 January 2016 at 19:04:48 UTC, Max Klyga wrote: On 2016-01-04 18:40:03 +, Jason Jeffory said: The fastest one would probably be Lua - http://code.dlang.org/search?q=lua But there are other options: Python - http://code.dlang.org/packages/pyd Javascript -

Re: GTKD Cairo get pixel color

2016-01-04 Thread Mike Wey via Digitalmars-d-learn
I think you are looking for something like this. Context.getTarget will get you the surface the Context is drawing to, this most likely isn't a ImageSurface. So you will need to create an pixbuf from the returned surface, with the Pixbuf you can then get the raw pixel data using

Re: GTKD Cairo get pixel color

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
On Monday, 4 January 2016 at 19:27:48 UTC, Mike Wey wrote: I think you are looking for something like this. Context.getTarget will get you the surface the Context is drawing to, this most likely isn't a ImageSurface. So you will need to create an pixbuf from the returned surface, with the

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Gerald via Digitalmars-d-learn
On Monday, 4 January 2016 at 18:04:34 UTC, TheDGuy wrote: On Monday, 4 January 2016 at 17:33:28 UTC, Gerald wrote: On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote: [...] Yes, you need it. The extern (C) function is what GDK invokes on idle. In any GUI application there is a lot of

Re: Are there any D scripting engines for use with D?

2016-01-04 Thread cym13 via Digitalmars-d-learn
On Monday, 4 January 2016 at 18:40:03 UTC, Jason Jeffory wrote: We have many scripting engines available for use in D more or less(lua, python, etc...). Is there a D scripting engine that can be easily integrated into a D project? A sort of "exec()". Something that works at compile time and

Re: Are there any D scripting engines for use with D?

2016-01-04 Thread Max Klyga via Digitalmars-d-learn
On 2016-01-04 18:40:03 +, Jason Jeffory said: We have many scripting engines available for use in D more or less(lua, python, etc...). Is there a D scripting engine that can be easily integrated into a D project? A sort of "exec()". Something that works at compile time and run time

Re: Are there any D scripting engines for use with D?

2016-01-04 Thread Jason Jeffory via Digitalmars-d-learn
On Monday, 4 January 2016 at 19:25:18 UTC, yawniek wrote: On Monday, 4 January 2016 at 19:04:48 UTC, Max Klyga wrote: On 2016-01-04 18:40:03 +, Jason Jeffory said: The fastest one would probably be Lua - http://code.dlang.org/search?q=lua But there are other options: Python -

to!double different from cast(double)

2016-01-04 Thread Ali Çehreli via Digitalmars-d-learn
I was writing an example to show that not every 'long' value can be represented by a 'double'. (They are both 64 bits; but for 'double', some of those bits are parts of the exponent, not the mantissa.) Although my demonstration works with to!double, the compiler does something different and

Re: to!double different from cast(double)

2016-01-04 Thread Ali Çehreli via Digitalmars-d-learn
On 01/04/2016 12:22 AM, Ali Çehreli wrote: > assert(l != l.to!double); // passes > assert(l != cast(double)l);// FAILS I've realized that I had the -m32 switch on unintentionally. The above results are for when -m32 is used. (I am on a 64-bit system.) Without -m32 both

Re: question about the implementation of Variant

2016-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 04, 2016 07:30:50 aki via Digitalmars-d-learn wrote: > But wait, how does GC detect there still be a live reference to > the object Foo? > Because store is just a fix sized array of bytes. > ubyte[size] store; > GC cannot be aware of the reference, right? As I understand it,

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread tcak via Digitalmars-d-learn
On Monday, 4 January 2016 at 10:50:17 UTC, Ur@nuz wrote: Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc() What's your OS? On Linux x64, it works without any

Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
Need some help)... Having the following chunk of code: string[] lines; ... if( firstIndentStyle == IndentStyle.space ) { lines ~= " ".repeat.take(newIndentCount).array; } else //Tabs { lines ~= "\t".repeat.take(newIndentCount).array; //This causes strange 'memset' error } This code

Re: CMake support for D

2016-01-04 Thread Luis via Digitalmars-d-learn
On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar wrote: Does CMake recognise D in the enable_language command? If not is there a workaround? Thanks and Regards Dibyendu I suggest use dub instead of cmake. I did a try to use cmake some time ago (a few years ago, before dub), and

Re: What are the useful inout free functions?

2016-01-04 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 4 January 2016 at 23:15:22 UTC, Guillaume Piolat wrote: Can someone produce a _useful_ free function that uses inout? There are useful getters using inout. There are useless free functions using inout like http://dpaste.dzfl.pl/d038012308ed Adam D. Ruppe answered this on IRC:

Re: GTKD Cairo get pixel color

2016-01-04 Thread Mike Wey via Digitalmars-d-learn
On 01/04/2016 09:13 PM, TheDGuy wrote: On Monday, 4 January 2016 at 19:27:48 UTC, Mike Wey wrote: I think you are looking for something like this. Context.getTarget will get you the surface the Context is drawing to, this most likely isn't a ImageSurface. So you will need to create an pixbuf

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Ali Çehreli via Digitalmars-d-learn
On 01/04/2016 06:31 AM, TheDGuy wrote: > I tried it with "std.concurrency" like this: > > bool drawCallback(Scoped!Context cr, Widget widget){ > writeln("init"); > spawn(, cr, widget); The first parameter to render() is Scoped!Context but render() takes a Context: > void

What are the useful inout free functions?

2016-01-04 Thread Guillaume Piolat via Digitalmars-d-learn
Can someone produce a _useful_ free function that uses inout? There are useful getters using inout. There are useless free functions using inout like http://dpaste.dzfl.pl/d038012308ed

Re: GTKD Cairo get pixel color

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
On Monday, 4 January 2016 at 21:42:16 UTC, Mike Wey wrote: On 01/04/2016 09:13 PM, TheDGuy wrote: [...] I don't have any issues with either getPixelsWithLength and savev. for the savev call there is an missing \ just before test.jpg, but that might be a copy and paste error? For the

Re: GTKD Cairo get pixel color

2016-01-04 Thread Basile B. via Digitalmars-d-learn
On Friday, 1 January 2016 at 22:00:04 UTC, TheDGuy wrote: On Friday, 1 January 2016 at 19:32:40 UTC, Basile B. wrote: On Wednesday, 30 December 2015 at 23:20:23 UTC, Basile B. wrote: On Wednesday, 30 December 2015 at 20:44:44 UTC, TheDGuy wrote: Hello, is there any way to get the pixel color

Re: std.experimental.logger

2016-01-04 Thread Mike via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 02:44:48 UTC, sanjayss wrote: I'm doing the following: import std.experimental.logger; int main(string[] args) { sharedLog = new FileLogger("logfile.log"); log("Test log 1"); log("Test log 2"); log("Test log 3"); } and I expected the logs to be seen in the

Re: std.experimental.logger

2016-01-04 Thread Mike via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 02:59:04 UTC, sanjayss wrote: On Tuesday, 5 January 2016 at 02:49:01 UTC, Mike wrote: [...] Thanks, that works. But the docs are confusing -- it gives the impression that "sharedLog" is something associated with the default logger -- so I would expect the above

Re: std.experimental.logger

2016-01-04 Thread sanjayss via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 02:49:01 UTC, Mike wrote: On Tuesday, 5 January 2016 at 02:44:48 UTC, sanjayss wrote: I'm doing the following: import std.experimental.logger; int main(string[] args) { sharedLog = new FileLogger("logfile.log"); log("Test log 1"); log("Test log 2"); log("Test

std.experimental.logger

2016-01-04 Thread sanjayss via Digitalmars-d-learn
I'm doing the following: import std.experimental.logger; int main(string[] args) { sharedLog = new FileLogger("logfile.log"); log("Test log 1"); log("Test log 2"); log("Test log 3"); } and I expected the logs to be seen in the logfile.log, but it seems like my reading of the docs on this is

Get superclasses at compile time

2016-01-04 Thread Straivers via Digitalmars-d-learn
Hello, I'm working on an event system, and I want to be able to check if an event is a subclass of another event. How might I go about this? In essence, I'm looking to compress this: static if (E == UserInputEvent || E == MouseEvent || E == MouseButtonEvent || E == MouseReleasedEvent) {

Re: Get superclasses at compile time

2016-01-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 05/01/16 5:50 PM, Straivers wrote: On Tuesday, 5 January 2016 at 04:41:45 UTC, Rikki Cattermole wrote: On 05/01/16 5:37 PM, Straivers wrote: Hello, I'm working on an event system, and I want to be able to check if an event is a subclass of another event. How might I go about this? In

Re: Get superclasses at compile time

2016-01-04 Thread Straivers via Digitalmars-d-learn
On Tuesday, 5 January 2016 at 04:41:45 UTC, Rikki Cattermole wrote: On 05/01/16 5:37 PM, Straivers wrote: Hello, I'm working on an event system, and I want to be able to check if an event is a subclass of another event. How might I go about this? In essence, I'm looking to compress this:

Re: Get superclasses at compile time

2016-01-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 05/01/16 5:37 PM, Straivers wrote: Hello, I'm working on an event system, and I want to be able to check if an event is a subclass of another event. How might I go about this? In essence, I'm looking to compress this: static if (E == UserInputEvent || E == MouseEvent || E ==

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote: On Monday, 4 January 2016 at 10:50:17 UTC, Ur@nuz wrote: Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails with error described in stack trace in Gcx.bigAlloc()

Re: CMake support for D

2016-01-04 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2016-01-04 at 08:28 +, Luis via Digitalmars-d-learn wrote: > > I suggest use dub instead of cmake. I did a try to use cmake some  > time ago (a few years ago, before dub), and was a nightmare to  > get ir working on GNU/Linux and Windows. With dub , simply works  > fine with a simple

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 4 January 2016 at 12:20:09 UTC, Ur@nuz wrote: On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote: On Monday, 4 January 2016 at 10:50:17 UTC, Ur@nuz wrote: Sorry, the actual code is: ... lines ~= ' '.repeat.take(newIndentCount).array; ...with character quotes. But it still fails

Re: Can't find windows' CreateThread function / concurrency.spawn crashes host application

2016-01-04 Thread Rainer Schuetze via Digitalmars-d-learn
On 02.01.2016 18:41, alkololl wrote: On Saturday, 2 January 2016 at 16:42:46 UTC, Rainer Schuetze wrote: On 02.01.2016 16:34, alkololl wrote: On Saturday, 2 January 2016 at 01:44:46 UTC, Adam D. Ruppe wrote: [...] Thanks for your reply. I replaced my switch statement with the one behind

Re: CMake support for D

2016-01-04 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Monday, 4 January 2016 at 08:28:03 UTC, Luis wrote: I suggest use dub instead of cmake. I did a try to use cmake some time ago (a few years ago, before dub), and was a nightmare to get ir working on GNU/Linux and Windows. With dub , simply works fine with a simple json file. CMake has

Re: CMake support for D

2016-01-04 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 4 January 2016 at 12:40:23 UTC, Dibyendu Majumdar wrote: Thanks for suggesting dub, will check it out. Also premake seems to support D so that is another option. Another alternative is reggae which supports mixed code base: https://github.com/atilaneves/reggae and can generate

Size of Compiled Program

2016-01-04 Thread Martin Tschierschke via Digitalmars-d-learn
When I was writing a small speed test - D versus Ruby, calculating the first n prime numbers, I realized, that for small n Ruby may be faster, than compiling and executing with D. But for n = 1,000,000 D outperforms Ruby by app. 10x. Looking at the size of my prime executable, it was around

Re: Size of Compiled Program

2016-01-04 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby, calculating the first n prime numbers, I realized, that for small n Ruby may be faster, than compiling and executing with D. But for n = 1,000,000 D outperforms Ruby by

Re: Size of Compiled Program

2016-01-04 Thread Basile B. via Digitalmars-d-learn
On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby, calculating the first n prime numbers, I realized, that for small n Ruby may be faster, than compiling and executing with D. But for n = 1,000,000 D outperforms Ruby by

Re: to!double different from cast(double)

2016-01-04 Thread anonymous via Digitalmars-d-learn
On 04.01.2016 09:22, Ali Çehreli wrote: void main() { const l = long.max; assert(l != l.to!double); // passes assert(l != cast(double)l);// FAILS } Is there a good explanation for this difference? I would expect both expressions to be compiled the same way. (I am aware

Re: question about the implementation of Variant

2016-01-04 Thread aki via Digitalmars-d-learn
Thank you, Jonathan. Now I understand. On Monday, 4 January 2016 at 17:34:47 UTC, Kapps wrote: union { ubyte[size] store; // conservatively mark the region as pointers static if (size >= (void*).sizeof) void*[size / (void*).sizeof] p; } Interesting to know the way to make

Re: GC configuration docs

2016-01-04 Thread Rainer Schuetze via Digitalmars-d-learn
On 05.01.2016 01:39, Dan Olson wrote: I haven't played with any of the new GC configuration options introduced in 2.067, but now need to. An application on watchOS currently has about 30 MB of RAM. Is there any more documentation than the web page https://dlang.org/spec/garbage.html or

Re: Integer literals

2016-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:54:29 UTC, ric maicle wrote: 0U .. 4_294_967_296U in the table Decimal Literal Types has a typo. Shouldn't the range end with 4_294_967_295U? The x .. y syntax excludes y. So 0..3 covers 0, 1, 2. It excludes 3.

Re: @property not available for classes?

2016-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/16 2:25 PM, Jacob Carlborg wrote: On 2016-01-03 18:48, Steven Schveighoffer wrote: class constructor requirements are much different from struct constructor requirements. There's also no implicit constructor that initializes all members as there is for structs. To clarify, there's a

Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
Hello, i use GTKD to draw some stuff on a DrawingArea. Because it needs some time to calculate i want to outsource those calculation so that the GUI doesn't freeze. I tried it with "std.concurrency" like this: bool drawCallback(Scoped!Context cr, Widget widget){ writeln("init");

Integer literals

2016-01-04 Thread ric maicle via Digitalmars-d-learn
I was rereading the Integer Literals section and trying out some code when I came across a couple of error messages on integer overflows. I have reproduced the code below for reference. void main() { // The maximum long value is ...807 // The following line produces an error message:

Re: Size of Compiled Program

2016-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby The smallest possible ruby program has about ~5 MB of dependencies, outside the operating system (the ruby runtime itself). The D program has none. It carries its

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Luis via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:31:04 UTC, TheDGuy wrote: Hello, i use GTKD to draw some stuff on a DrawingArea. Because it needs some time to calculate i want to outsource those calculation so that the GUI doesn't freeze. I tried it with "std.concurrency" like this: bool

Re: Integer literals

2016-01-04 Thread ric maicle via Digitalmars-d-learn
On Monday, 04 January, 2016 10:58 PM, Adam D. Ruppe wrote: On Monday, 4 January 2016 at 14:54:29 UTC, ric maicle wrote: 0U .. 4_294_967_296U in the table Decimal Literal Types has a typo. Shouldn't the range end with 4_294_967_295U? The x .. y syntax excludes y. So 0..3 covers 0, 1, 2. It

Re: Integer literals

2016-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/16 10:33 AM, ric maicle wrote: On Monday, 04 January, 2016 10:58 PM, Adam D. Ruppe wrote: On Monday, 4 January 2016 at 14:54:29 UTC, ric maicle wrote: 0U .. 4_294_967_296U in the table Decimal Literal Types has a typo. Shouldn't the range end with 4_294_967_295U? The x .. y syntax

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Gerald via Digitalmars-d-learn
On Monday, 4 January 2016 at 15:28:56 UTC, TheDGuy wrote: On Monday, 4 January 2016 at 15:07:12 UTC, Luis wrote: On Monday, 4 January 2016 at 14:31:04 UTC, TheDGuy wrote: [...] Before doing anything with threads and GTK, you should read this :

Re: Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
On Monday, 4 January 2016 at 15:07:12 UTC, Luis wrote: On Monday, 4 January 2016 at 14:31:04 UTC, TheDGuy wrote: [...] Before doing anything with threads and GTK, you should read this : http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness Okay, so i

Re: Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
I wrote a demo for GtkD showing how multi-threading and D work together, it's in the demos/gtkD/DemoMultithread folder of GtkD, hopefully it will be helpful. However this example it is based on using the GTk threadIdle callback which is generally preferred over the locking methods you show

Re: Size of Compiled Program

2016-01-04 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:51:59 UTC, Adam D. Ruppe wrote: On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby The smallest possible ruby program has about ~5 MB of dependencies, outside the operating system (the

Re: Size of Compiled Program

2016-01-04 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:01:18 UTC, Basile B. wrote: On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: [...] - if debug info are generated this increases the size. - if bounds checking is turned off there is some code generated for each array operation - if

Re: Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
On Monday, 4 January 2016 at 17:33:28 UTC, Gerald wrote: On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote: [...] Yes, you need it. The extern (C) function is what GDK invokes on idle. In any GUI application there is a lot of idle time waiting for events, what the addThreadIdle

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Gerald via Digitalmars-d-learn
On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote: Thanks for your example code. Do i need those extern (C) function? Yes, you need it. The extern (C) function is what GDK invokes on idle. In any GUI application there is a lot of idle time waiting for events, what the addThreadIdle

Re: question about the implementation of Variant

2016-01-04 Thread Kapps via Digitalmars-d-learn
On Monday, 4 January 2016 at 09:13:25 UTC, Jonathan M Davis wrote: On Monday, January 04, 2016 07:30:50 aki via Digitalmars-d-learn wrote: But wait, how does GC detect there still be a live reference to the object Foo? Because store is just a fix sized array of bytes. ubyte[size] store; GC

Re: Strange 'memset' error when using std.range.repeat and std.array.array

2016-01-04 Thread via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:25:30 UTC, Marc Schütz wrote: On Monday, 4 January 2016 at 12:20:09 UTC, Ur@nuz wrote: On Monday, 4 January 2016 at 12:00:32 UTC, tcak wrote: [...] Yes. It's Ubuntu 14. It works when it's in the separate example, but not working inside my project. The strange

Re: Size of Compiled Program

2016-01-04 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:16:54 UTC, Marc Schütz wrote: On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby, calculating the first n prime numbers, I realized, that for small n Ruby may be faster, than compiling and

Re: Size of Compiled Program

2016-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 January 2016 at 16:56:15 UTC, Martin Tschierschke with the "same" Ubuntu release, I got an error, may be its 32 not 64 Bit? Any hint? Yeah, probably.