[DerelictAlure] Error loading libdumb.so etc...

2014-09-19 Thread Jack via Digitalmars-d-learn

I've configured dub to build DerelictAlure for my project which
only contains the example code shown in:
https://github.com/DerelictOrg/DerelictALURE

The build was successful though when I tried to run it, they were
spewing out that they need some sort of .so files. Full error is
: http://npaste.de/p/2qG/

Though it says that once you configured dub to automatically
build your projects, it would automatically link libraries,
etc... http://dblog.aldacron.net/derelict-help/using-derelict/

In case it helps, this is my current dub.json file:
http://npaste.de/p/Go/

I've already installed openAL and alure in my system in hopes of
solving the issue.

So erm, any clues? Did I miss anything?
I'm using an ArchLinux x64 distribution inside VirtualBox.


Re: Why is amap implemented as a member function of TaskPool?

2014-09-19 Thread Nordlöw

On Thursday, 18 September 2014 at 19:49:00 UTC, Atila Neves wrote:
I had to roll my own parallel map today, but at least I did get 
a nice 3x speedup.


Is your own parallel map public somewhere? It would be 
interesting to see it.


Re: Why is amap implemented as a member function of TaskPool?

2014-09-19 Thread Jared via Digitalmars-d-learn

On Friday, 19 September 2014 at 07:17:50 UTC, Atila Neves wrote:

The point is I _want_ a delegate.

Atila

On Thursday, 18 September 2014 at 20:51:30 UTC, Jared wrote:
On Thursday, 18 September 2014 at 19:49:00 UTC, Atila Neves 
wrote:
Or what I really want to ask: why can't I call amap from 
std.parallelism with a lambda? I assume it's because it's a 
member function but I'm not 100% sure.


Check out this: https://issues.dlang.org/show_bug.cgi?id=5710

It seems that the compiler doesn't know what to do with 
non-global templates and delegates since the delegate would end 
up with two context pointers. Looks like there are efforts to fix 
it.


how to create and compile reesources for dmd 64

2014-09-19 Thread Cassio Butrico via Digitalmars-d-learn

Hello everyone,
When I create and compile resouces to 32 works perfect, but when 
I try to compilat of 64 error

LNK1136: invalid or corrupt file.
I do not know if it has to do with comverter COFF to OMF.
can someone give me a light?
Thank you for your attention.


Re: String[] pointer to void* and back

2014-09-19 Thread anonymous via Digitalmars-d-learn

On Friday, 19 September 2014 at 12:14:19 UTC, seany wrote:
On Thursday, 18 September 2014 at 22:16:48 UTC, Ali Çehreli 
wrote:


If you are holding an address in a void*, you must make sure 
that the original object is still at that location when you 
attempt to access the object.


Does that mean, that there is no way to make a global stack 
accessible accross modules, of runtime generated stack 
variables, unless i define such variable species beforehand?


I don't understand your usage of the word "stack". There may
confusion about the meaning of (the) stack.

As far as I understand, you want to store values (or references
to values) of arbitrary types. You tried to use `void*` for that.
That works, as long as the value stays where the pointer points.
Which is not the case when the value is on the call stack [1]
(i.e. "the stack"). If you put the value on "the heap" [2] (not
to be confused with the data structure), it works fine:

---
import std.stdio;

class C
{
   void* v;

   void dothings()
   {
  string[] ss = ["1", "2", "4"];
  string[][] onTheHeap = new string[][1]; /* Allocate space on
the heap. Can't `new` a single string[] directly, so make it an
array of length 1. */
  onTheHeap[0] = ss; /* Copy ss from the stack to the heap. */
  v = onTheHeap.ptr; /* Could also be `&onTheHeap[0]`, but not
`&onTheheap`. */
   }
}


void main()
{
C c = new C;
c.dothings();

string[]* sh;
sh = cast(string[]*)c.v;

string[] si = *sh;
writeln(si); /* ["1", "2", "4"] */
}
---

By the way, the struct S isn't really buying you anything over
using void* directly.

[1] http://en.wikipedia.org/wiki/Call_stack
[2] http://en.wikipedia.org/wiki/Heap_(programming)


Re: String[] pointer to void* and back

2014-09-19 Thread Ali Çehreli via Digitalmars-d-learn

On 09/19/2014 05:14 AM, seany wrote:

> On Thursday, 18 September 2014 at 22:16:48 UTC, Ali Çehreli wrote:
>
>> If you are holding an address in a void*, you must make sure that the
>> original object is still at that location when you attempt to access
>> the object.
>
> Does that mean, that there is no way to make a global stack accessible
> accross modules, of runtime generated stack variables,

I assume you mean 'program stack' as opposed to the 'stack' data structure.

Objects on the program stack don't work because program stack is like a 
scratch pad and the stack data structure won't work in some situations 
if it's implemented in terms of an array and if the array gets larger 
over time, because array elements get moved around as the capacity is 
consumed.


The important part is to ensure that the object will be there when the 
void* is actually used.


Here is an example that uses a fixed-length array. string[] objects are 
passed as void* parameters to a function (perhaps a C library function). 
That function uses the void* argument when calling the callback function.


When the callback function received the void*, the object is still in 
the global (more correctly, module-scoped) array.


Note that although I used literals string arrays when populating the 
tables, they can be stack variables as well, as long as they are put in 
to the array and addresses of the array elements are used.


import std.stdio;

string[][2] stringTables;

void populateTables()
{
stringTables[0] = [ "apple", "pear" ];
stringTables[1] = [ "coffee", "tea" ];
}

void main()
{
populateTables();

foreach (i; 0 .. 4) {
const index = i % 2;
void* param = &(stringTables[index]);
callWith(&callbackFunction, param);
}
}

alias CallbackFunction = void function(void*);

void callWith(CallbackFunction func, void* param)
{
func(param);
}

void callbackFunction(void* param)
{
string[]* table = cast(string[]*)param;
writefln("Called with %s", *table);
}

> unless i define such variable species beforehand?

Unlike the example above, you can define the objects during runtime as 
well. The problem with slices is that it is not possible to create the 
actual slice object dynamically:


alias Numbers = int[];
auto p = new Numbers;

Error: new can only create structs, dynamic arrays or class objects, not 
int[]'s


Ironically, the error message mentions 'dynamic arrays' but it is 
talking about the actual storage for elements, not the slice object itself.


So, one way is to wrap the slice in a struct:

struct Table
{
int[] table;
}

void foo()
{
void* p = new Table;
// ...
}

Now it works and 'p' can be used as a void*. Although the struct object 
(and the slice inside it) is on the GC heap, there is a different kind 
of problem: There may not be any other pointer to that object and the GC 
may collect the memory before the void* is used in the program later on. 
(This may not be a concern if the void* remains in the program as a 
reference. However, if the void* is passed to e.g. a C library function, 
which puts it in a container there, then GC will not know about it.


Although GC.addRange helps with that, the void* can safely be put in a 
void* slice as well:


void*[] persistingTable;

persistingTable ~= p;

This time, even if persistingTable moves its void* elements around, it 
won't matter because persistingTable is only for keeping a visible 
pointer in the program so that GC doesn't free our objects.


As you can see, there are a lot of things to consider. :) What are you 
thinking of using the void* for?


Ali



Re: [Dub Problem] DMD compile run failed with exit code -9

2014-09-19 Thread Jack via Digitalmars-d-learn

On Friday, 19 September 2014 at 16:45:28 UTC, evilrat wrote:

On Friday, 19 September 2014 at 16:35:39 UTC, Jack wrote:

On Friday, 19 September 2014 at 16:06:23 UTC, evilrat wrote:

On Friday, 19 September 2014 at 15:58:37 UTC, Jack wrote:

Disclaimer: I'm a newbie so don't bite me.

Anyway I've been testing out dub in an ArchLinux environment 
that is inside a VM software(namely VirtualBox) and tried to 
build the Dash-sample game.


The whole process went smoothly until it ended with the Line:
"Error executing command run: DMD compile run failed with 
exit code -9"


The whole error message is in : http://npaste.de/p/HW/

Both dub and dmd are up-to-date. (Dmd version 2.066 and Dub 
version 0.9.21)


So, erm any ideas or clues?

Sorry if I'm a little bit cryptic or broken in my English. 
It's around midnight here and I'm trying to find out more 
about this.


verbose mode probably could help to find out whats wrong (dub 
-v)


Here's what verbose spewed out: http://npaste.de/p/G2f/
Seems like it's the Compiler having trouble and not Dub. 
Though I

can't understand what it says anyway.


thats all?
if yes, i recently have accidentally declared struct array and
initialized it as struct with array fields
MyStruct[] sarr = {
  [ "field1", "field2" ],
  ...
};

while it should be array of structs
MyStruct[] sarr = [
  MyStruct("field1", "field2"),
  ...
];

DMD chokes on such cases. probably you have something similar.


So it's more likely a bug with the Sample Dash Game with the
latest version of dmd? Strange, It's supposed to be compatible
with it.


Re: [Dub Problem] DMD compile run failed with exit code -9

2014-09-19 Thread evilrat via Digitalmars-d-learn

On Friday, 19 September 2014 at 16:35:39 UTC, Jack wrote:

On Friday, 19 September 2014 at 16:06:23 UTC, evilrat wrote:

On Friday, 19 September 2014 at 15:58:37 UTC, Jack wrote:

Disclaimer: I'm a newbie so don't bite me.

Anyway I've been testing out dub in an ArchLinux environment 
that is inside a VM software(namely VirtualBox) and tried to 
build the Dash-sample game.


The whole process went smoothly until it ended with the Line:
"Error executing command run: DMD compile run failed with 
exit code -9"


The whole error message is in : http://npaste.de/p/HW/

Both dub and dmd are up-to-date. (Dmd version 2.066 and Dub 
version 0.9.21)


So, erm any ideas or clues?

Sorry if I'm a little bit cryptic or broken in my English. 
It's around midnight here and I'm trying to find out more 
about this.


verbose mode probably could help to find out whats wrong (dub 
-v)


Here's what verbose spewed out: http://npaste.de/p/G2f/
Seems like it's the Compiler having trouble and not Dub. Though 
I

can't understand what it says anyway.


thats all?
if yes, i recently have accidentally declared struct array and
initialized it as struct with array fields
MyStruct[] sarr = {
  [ "field1", "field2" ],
  ...
};

while it should be array of structs
MyStruct[] sarr = [
  MyStruct("field1", "field2"),
  ...
];

DMD chokes on such cases. probably you have something similar.


Re: [Dub Problem] DMD compile run failed with exit code -9

2014-09-19 Thread Jack via Digitalmars-d-learn

On Friday, 19 September 2014 at 16:06:23 UTC, evilrat wrote:

On Friday, 19 September 2014 at 15:58:37 UTC, Jack wrote:

Disclaimer: I'm a newbie so don't bite me.

Anyway I've been testing out dub in an ArchLinux environment 
that is inside a VM software(namely VirtualBox) and tried to 
build the Dash-sample game.


The whole process went smoothly until it ended with the Line:
"Error executing command run: DMD compile run failed with exit 
code -9"


The whole error message is in : http://npaste.de/p/HW/

Both dub and dmd are up-to-date. (Dmd version 2.066 and Dub 
version 0.9.21)


So, erm any ideas or clues?

Sorry if I'm a little bit cryptic or broken in my English. 
It's around midnight here and I'm trying to find out more 
about this.


verbose mode probably could help to find out whats wrong (dub 
-v)


Here's what verbose spewed out: http://npaste.de/p/G2f/
Seems like it's the Compiler having trouble and not Dub. Though I
can't understand what it says anyway.


Re: [Dub Problem] DMD compile run failed with exit code -9

2014-09-19 Thread evilrat via Digitalmars-d-learn

On Friday, 19 September 2014 at 15:58:37 UTC, Jack wrote:

Disclaimer: I'm a newbie so don't bite me.

Anyway I've been testing out dub in an ArchLinux environment 
that is inside a VM software(namely VirtualBox) and tried to 
build the Dash-sample game.


The whole process went smoothly until it ended with the Line:
"Error executing command run: DMD compile run failed with exit 
code -9"


The whole error message is in : http://npaste.de/p/HW/

Both dub and dmd are up-to-date. (Dmd version 2.066 and Dub 
version 0.9.21)


So, erm any ideas or clues?

Sorry if I'm a little bit cryptic or broken in my English. It's 
around midnight here and I'm trying to find out more about this.


verbose mode probably could help to find out whats wrong (dub -v)


[Dub Problem] DMD compile run failed with exit code -9

2014-09-19 Thread Jack via Digitalmars-d-learn

Disclaimer: I'm a newbie so don't bite me.

Anyway I've been testing out dub in an ArchLinux environment that 
is inside a VM software(namely VirtualBox) and tried to build the 
Dash-sample game.


The whole process went smoothly until it ended with the Line:
"Error executing command run: DMD compile run failed with exit 
code -9"


The whole error message is in : http://npaste.de/p/HW/

Both dub and dmd are up-to-date. (Dmd version 2.066 and Dub 
version 0.9.21)


So, erm any ideas or clues?

Sorry if I'm a little bit cryptic or broken in my English. It's 
around midnight here and I'm trying to find out more about this.


Re: String[] pointer to void* and back

2014-09-19 Thread seany via Digitalmars-d-learn

On Thursday, 18 September 2014 at 22:16:48 UTC, Ali Çehreli wrote:

If you are holding an address in a void*, you must make sure 
that the original object is still at that location when you 
attempt to access the object.


Does that mean, that there is no way to make a global stack 
accessible accross modules, of runtime generated stack variables, 
unless i define such variable species beforehand?


Re: dub can't read files from cache

2014-09-19 Thread Kagamin via Digitalmars-d-learn
On Thursday, 18 September 2014 at 18:26:37 UTC, ketmar via 
Digitalmars-d-learn wrote:

i can't have koi8 string in my D
code without ugly "\x" escapes. i can't have koi8 text in my 
comments.
Great Lord, it's just comments, it's not even DDoc, why can't i 
write

anything i want there?!


Editors usually can handle various encodings independently from 
your system settings, you should be able to keep D code in utf-8. 
For example, notepad on windows can handle utf-8 even though it's 
not a native encoding for windows.


Re: linux ipv4 multicast

2014-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/18/14 10:55 PM, james wrote:

I just started doing D networking today, so I may just be doing
something wrong / stupid but I can not find the "ip_mreq"
struct anywhere.

I ended up just making my own in my module

struct ip_mreq
{
   in_addr imr_multiaddr;
   in_addr imr_interface;
}

And then I was able to continue and successfully process
multicast.

The ipv6 things seem to be available.

I was hoping it would be picked up by import std.c.linux.socket;

In /usr/include/dmd , running
   find . -type f -exec grep -Hi "ip_mreq" {} \;
returns no results.

Am I doing something wrong or is this just an oversight somehow?

DMD v2.065


The vast amount of C declarations that could be done on D simply aren't 
done until someone needs them. So no, you aren't doing anything wrong, 
no it's not an oversight :)


If you like it to be part of the main library, submit a pull request, 
and I'll be happy to review.


One thing -- you should extern(C) the struct so the symbol is not 
mangled (extern(C): is probably already done at the top of the file, so 
you may not need to do this if you add it to std.c.linux.socket)


-Steve


Re: Trouble with std.Variant

2014-09-19 Thread Nicolas Sicard via Digitalmars-d-learn

On Thursday, 18 September 2014 at 21:14:55 UTC, Ali Çehreli wrote:

On 09/18/2014 02:06 PM, ddos wrote:
The following code fails because Vec2.length() does not return 
int ...
so Variant is only usable with types that do not have a method 
with name

length() ?? i'm confused

On Thursday, 18 September 2014 at 21:03:47 UTC, ddos wrote:

struct Vec2
{
   float[2] vec;

   public float length()
   {
   return sqrt(vec[0]*vec[0]+vec[1]*vec[1]);
   }
}

int main(string[] argv)
{
   Vec2 test;
   Variant v = test;
   return 0;
}




Compiles and runs without error with dmd git head, after adding 
the following two lines: ;)


import std.math;
import std.variant;

Ali


It shouldn't work in dmd git head. See Andrei's answer in
https://issues.dlang.org/show_bug.cgi?id=5501



Re: Why is amap implemented as a member function of TaskPool?

2014-09-19 Thread Atila Neves via Digitalmars-d-learn

The point is I _want_ a delegate.

Atila

On Thursday, 18 September 2014 at 20:51:30 UTC, Jared wrote:
On Thursday, 18 September 2014 at 19:49:00 UTC, Atila Neves 
wrote:
Or what I really want to ask: why can't I call amap from 
std.parallelism with a lambda? I assume it's because it's a 
member function but I'm not 100% sure.


Atila


You have to tell DMD that the lambda is not in fact a delegate.

import std.stdio;
import std.range;
import std.parallelism;

void main()
{
auto w = iota(0,1_000_000);
int[] foo;

// Not OK, dmd can't infer lambda isn't a delegate
// foo = taskPool().amap!(a => a + 1)(w);

// OK:
foo = taskPool().amap!`a+1`(w); // string lambdas, yeah!
foo = taskPool().amap!(function int(int a) => a + 1)(w);
static int func(int a) { return a + 1; }
foo = taskPool().amap!func(w);
}




Re: dub can't read files from cache

2014-09-19 Thread Kagamin via Digitalmars-d-learn
On Thursday, 18 September 2014 at 15:53:03 UTC, Ilya Yaroshenko 
wrote:

Windows 9 will be based on Windows 98 =)
Seriously, console application (in Russian lang. Windows) is 
not unicode-ready.


Console API is unicode too. What can be not unicode is console 
font, but that can happen for GUI too.