Re: Can someone explain how glfw3.dll gets created?

2014-10-14 Thread Mike Parker via Digitalmars-d-learn

On 10/14/2014 5:21 AM, WhatMeWorry wrote:

I have a simple GLFW3 program running in Visual D integrated shell, that
kept aborting at DerelictFLFW3.load() with a failed to load the shared
libraries: glfw3.dll.'

So I found a glfw3.dll somewhere and moved it into the project folder (I
know this is bad technique) and that fixed the problem.

But now I'm wondering were this glfw3.dll came from.




Others have already answered your specific question, but I would just 
like to point out that their answers are generally true for any Derelict 
package you use. Derelict binds to C libraries, or C++ libraries with C 
interfaces, so that they are usable from D. When you add Derelict to 
your dub configuration, or in your Visual D build settings, all you are 
getting are the D files allow you to interface with the C libraries -- 
you are not getting the C libraries themselves. On Windows, in most 
cases you have to go out and either download a prebuilt binary or 
download and compile the C source yourself. I say /most cases/ because 
OpenGL will already be on your system as part of your graphics driver 
and you may already have another library or two installed in your system 
directories (like OpenAL, perhaps).


Furthermore, Derelict is a /dynamic/ binding in that it loads the shared 
libraries at runtime and has absolutely no compile time dependency on 
any of them. This is why you have to call DerelictFoo.load(). That looks 
for the library on the system path and, if found, loads it into memory 
so that you can start calling into it.


So if you are going to use GLFW, SDL, or anything else, you need to go 
to that project's web site and use their documentation to understand how 
to build (if they don't provide binaries) and use those libraries, then 
make sure that the compiled DLLs are on the system path (meaning, 
usually, in the executable's directory).


---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com



Re: dsource and WinAPI

2014-10-14 Thread dcrepid via Digitalmars-d-learn

Which project are you looking at?


Bindings for the Windows API:

http://www.dsource.org/projects/bindings/wiki/WindowsApi

This is a pretty important project, especially for getting more 
Windows programmers on board..


thanks for your help


Re: Really in need of help with std.container.array.d

2014-10-14 Thread Nordlöw
On Monday, 13 October 2014 at 13:46:56 UTC, Robert burner Schadek 
wrote:

other than that I'm not sure how to go about this.


I tried replace inout with a C++-style member duplication at

https://github.com/nordlow/phobos/commit/b2a4ca28bf25bf7c6149566d066cbb54118b36b4

Now it instead errors as

Error: mutable method 
std.container.array.Array!int.Array.__fieldPostBlit is not 
callable using a const object
array.d(252,26): Error: 
cast(inout(int))this._outer.opIndex(this._a) is not an lvalue
array.d(258,26): Error: 
cast(inout(int))this._outer.opIndex(this._b - 1LU) is not an 
lvalue
../../std/algorithm.d(2364,9): Error: cannot modify const 
expression result
array.d(276,24): Error: template instance 
std.algorithm.move!(const(int)) error instantiating
array.d(439,5):instantiated from here: 
Range!(const(Array!int))

array.d(851,5):instantiated from here: Array!int
array.d(294,26): Error: 
cast(inout(int))this._outer.opIndex(this._a + i) is not an lvalue
Error: mutable method std.container.array.Array!int.Array.~this 
is not callable using a const object
array.d(320,30): Error: None of the overloads of 'opSliceAssign' 
are callable using a const object, candidates are:
array.d(507,10):
std.container.array.Array!int.Array.opSliceAssign(int value)
array.d(514,10):
std.container.array.Array!int.Array.opSliceAssign(int value, 
ulong i, ulong j)
array.d(326,38): Error: None of the overloads of 'opSliceAssign' 
are callable using a const object, candidates are:
array.d(507,10):
std.container.array.Array!int.Array.opSliceAssign(int value)
array.d(514,10):
std.container.array.Array!int.Array.opSliceAssign(int value, 
ulong i, ulong j)
array.d(299,32): Error: mutable method 
std.container.array.Array!int.Array.Range!(Array!int).Range.this 
is not callable using a const object
array.d(309,32): Error: mutable method 
std.container.array.Array!int.Array.Range!(Array!int).Range.this 
is not callable using a const object
array.d(443,5): Error: template instance 
std.container.array.Array!int.Array.Range!(Array!int) error 
instantiating

array.d(851,5):instantiated from here: Array!int
../../std/typecons.d(3889,17): Error: template instance 
object.destroy!(Payload) error instantiating
array.d(169,26):instantiated from here: 
RefCounted!(Payload, cast(RefCountedAutoInitialize)0)

array.d(851,5):instantiated from here: Array!int
array.d(880,5): Error: static assert  (!true) is false

Ideas?


Re: Really in need of help with std.container.array.d

2014-10-14 Thread Nordlöw
On Monday, 13 October 2014 at 13:46:56 UTC, Robert burner Schadek 
wrote:

A blunt force solution would be to create a range as
Range!(ReturnType!Array...)(cast(Array!T)this, low, high);
and then do the correct casts in Range.
The ReturnType would be the ReturnType of opIndex of the Range 
type and the Array would be stored as plain array without any


Do you mean a mutable array containing references to inout data?


qualifier.


Could you please give me a code example? I'm not skilled enough 
in D to follow this description.


Re: dsource and WinAPI

2014-10-14 Thread Steven Schveighoffer via Digitalmars-d-learn

On 10/14/14 5:03 AM, dcrepid wrote:

Which project are you looking at?


Bindings for the Windows API:

http://www.dsource.org/projects/bindings/wiki/WindowsApi

This is a pretty important project, especially for getting more Windows
programmers on board..

thanks for your help


Looks like they are still using dsource for that project, latest update 
is 9/7/14.


It does have a github mirror though: 
https://github.com/CS-svnmirror/dsource-bindings


You may be able to at least post a pull request there, and maybe get the 
thing included. The two most recent contributors are regulars here, they 
may be able to get your code considered.


It also looks like the github link is pretty recent (8/16/14), perhaps a 
move to github is forthcoming?


-Steve


When betterC triggers errors in compilation?

2014-10-14 Thread eles via Digitalmars-d-learn

Hello,

According to this:

http://forum.dlang.org/post/lddug4$jgv$1...@digitalmars.com

-betterC should disable support for exception handling. So I 
expected dmd to reject the following code:


===
import std.stdio;

int readDieFromFile()
{
auto file = File(the_file_that_contains_the_value, r);

int die;
file.readf( %s, die);

return die;
}

int tryReadingFromFile()
{
int die;

try {
die = readDieFromFile();

} catch (std.exception.ErrnoException exc) {
writeln((Could not read from file; assuming 1));
die = 1;
}

return die;
}

void main()
{
const int die = tryReadingFromFile();

writeln(Die value: , die);
}
===
(from Ali's book; thanks once again)

But it compiles and runs fine:

$dmd betterC.d -betterC

$./betterC
(Could not read from file; assuming 1)
Die value: 1

This is with dmd 2.066 on Linux x86_64.

What code would fail under -betterC and how?


Re: When betterC triggers errors in compilation?

2014-10-14 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 13:20:50 UTC, eles wrote:

http://forum.dlang.org/post/lddug4$jgv$1...@digitalmars.com


That was just a speculative thread, that stuff isn't implemented. 
(And I think that went way too far, IMO betterC should just 
remove the mandatory stuff like ModuleInfo and TypeInfo 
assumptions and leave the rest to be opt in. I'd be against it 
making exception handling an error).


-betterC right now is still an undocumented hack that doesn't do 
much.


Re: When betterC triggers errors in compilation?

2014-10-14 Thread ketmar via Digitalmars-d-learn
On Tue, 14 Oct 2014 13:20:49 +
eles via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:

 What code would fail under -betterC and how?
currently betterC disables module info generation and some module
helper functions generation. that's all. just grep DMD sources for
betterC and you'll see it.


signature.asc
Description: PGP signature


Re: When betterC triggers errors in compilation?

2014-10-14 Thread eles via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 13:31:47 UTC, Adam D. Ruppe wrote:

On Tuesday, 14 October 2014 at 13:20:50 UTC, eles wrote:

http://forum.dlang.org/post/lddug4$jgv$1...@digitalmars.com


-betterC right now is still an undocumented hack that doesn't 
do much.


Thank you.


Re: dsource and WinAPI

2014-10-14 Thread Vladimir Panteleev via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 13:06:06 UTC, Steven Schveighoffer 
wrote:
dsource is no longer actively maintained. I don't think anyone 
knows how to contact the admin.


I've contacted Brad on a few occasions.

Looks like they are still using dsource for that project, 
latest update is 9/7/14.


I have commit access to that SVN repository. If someone wants 
something changed, I could commit it there for them.


It does have a github mirror though: 
https://github.com/CS-svnmirror/dsource-bindings


This mirror is a fully automatic clone of the SVN repository's 
history. It cannot accept pull requests, because the next 
synchronization will only overwrite them. (I could commit the 
changes into SVN, though.)


Although we could move the repository to GitHub proper to allow 
people to contribute changes more easily, the long-term solution 
is to include the headers in Druntime.


I just noticed 
https://github.com/CS-svnmirror/dsource-bindings/pull/1, I'll 
have a look.


Re: Really in need of help with std.container.array.d

2014-10-14 Thread Robert burner Schadek via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 12:51:29 UTC, Nordlöw wrote:



Could you please give me a code example? I'm not skilled enough 
in D to follow this description.


struct Range(T) {
  Array!S array;
  T opIndex(size_t i) {
 return cast(T)array[i];
  }
}

struct Array(T) {
  Range!(const(T)) opSlice() const {
 return Range!(const(T))(cast(Array!T)array, 0, length);
  }

  Range!(T) opSlice() const {
return Range!(T)(cast(Array!T)array, 0, length);
  }
}





Re: dsource and WinAPI

2014-10-14 Thread Trass3r via Digitalmars-d-learn
the long-term solution is to include the [win32] headers in 
druntime

™


Re: dsource and WinAPI

2014-10-14 Thread dcrepid via Digitalmars-d-learn
Vladimir, thanks for looking at the pull request. It'd be great 
if the whole project was moved to GitHub to allow more people to 
contribute.


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread Sean Kelly via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote:


Greetings.

Imagine this code,

char[] s = ABCabc;
foreach (char c; s)
{
  // how do I convert c to something an Unicode code? ie. 
\u.


}


I'd look at the JSON string encoder.


how to get the \uxxxx unicode code from a char

2014-10-14 Thread jicman via Digitalmars-d-learn


Greetings.

Imagine this code,

char[] s = ABCabc;
foreach (char c; s)
{
  // how do I convert c to something an Unicode code? ie. \u.

}

thanks.


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread ketmar via Digitalmars-d-learn
On Tue, 14 Oct 2014 19:46:57 +
jicman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:

 char[] s = ABCabc;
 foreach (char c; s)
 {
// how do I convert c to something an Unicode code? ie. \u.
 
 }
  string res;
  foreach (dchar ch; s) res ~= \\u%04X.format(ch);
  // here we have the result in res

note dchar instead of char. with dchar foreach() does utf-8
decoding (as 's' is in utf-8).


signature.asc
Description: PGP signature


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread jicman via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 19:49:16 UTC, Sean Kelly wrote:

On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote:


Greetings.

Imagine this code,

char[] s = ABCabc;
foreach (char c; s)
{
 // how do I convert c to something an Unicode code? ie. 
\u.


}


I'd look at the JSON string encoder.


JSON?  What does JSON has to do with my basic D? :-) No thanks. 
:-)


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread Brad Anderson via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote:

https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579


Oops. Linked the the parser section. I actually don't see any 
unicode escape encoder in here. Perhaps he meant the upcoming 
JSON module.


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread Brad Anderson via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:03:37 UTC, jicman wrote:

On Tuesday, 14 October 2014 at 19:49:16 UTC, Sean Kelly wrote:

On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote:


Greetings.

Imagine this code,

char[] s = ABCabc;
foreach (char c; s)
{
// how do I convert c to something an Unicode code? ie. 
\u.


}


I'd look at the JSON string encoder.


JSON?  What does JSON has to do with my basic D? :-) No thanks. 
:-)


Sean's saying that the JSON encoder does the same thing so you 
can look there for how to do it.


https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread Brad Anderson via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson wrote:
On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson 
wrote:

https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579


Oops. Linked the the parser section. I actually don't see any 
unicode escape encoder in here. Perhaps he meant the upcoming 
JSON module.


Here we go.

https://github.com/s-ludwig/std_data_json/blob/4ecb90626055269f4897902404741f1173fb5e8e/source/stdx/data/json/generator.d#L451

Sönke's is pretty sophisticated. You could probably just use the 
non-surrogate supporting simple branch.


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread jicman via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 19:56:29 UTC, ketmar via 
Digitalmars-d-learn wrote:

On Tue, 14 Oct 2014 19:46:57 +
jicman via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com

wrote:


char[] s = ABCabc;
foreach (char c; s)
{
   // how do I convert c to something an Unicode code? ie. 
\u.


}

  string res;
  foreach (dchar ch; s) res ~= \\u%04X.format(ch);
  // here we have the result in res

note dchar instead of char. with dchar foreach() does 
utf-8

decoding (as 's' is in utf-8).


Thanks.  This is a missing function in std.uni or std.string.

josé


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread jicman via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:13:17 UTC, Brad Anderson wrote:
On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson 
wrote:
On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson 
wrote:

https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579


Oops. Linked the the parser section. I actually don't see any 
unicode escape encoder in here. Perhaps he meant the upcoming 
JSON module.


Here we go.

https://github.com/s-ludwig/std_data_json/blob/4ecb90626055269f4897902404741f1173fb5e8e/source/stdx/data/json/generator.d#L451

Sönke's is pretty sophisticated. You could probably just use 
the non-surrogate supporting simple branch.


thanks.  the problem is that I am still in D1. ;-)  over 300K 
lines of code and growing...


Re: how to get the \uxxxx unicode code from a char

2014-10-14 Thread Ali Çehreli via Digitalmars-d-learn

On 10/14/2014 01:18 PM, jicman wrote:


Thanks.  This is a missing function in std.uni or std.string.

josé


I don't know D1 but there is std.utf.decode:

  http://dlang.org/phobos/std_utf.html#decode

Ali



Mixin template functions are ignored in struct

2014-10-14 Thread tcak via Digitalmars-d-learn
I have written a struct and a mixin template, and that mixin 
template is mixed into that struct as follows.


private mixin template TestCommonMethods(){
public bool apply( int d, int e ){
return false;
}
}

public struct Test{
public mixin TestCommonMethods;

public bool apply( char c ){
return true;
}
}

void main(){
Test t;
t.apply( 5, 3 );
}

---

For the line t.apply( 5, 3 );, error is given saying that 
function test.apply(char c) is not callable.


---

For better testing, I added another function to template as 
public bool blah(){}, and called it in main, and it works. So, 
thus this mean overloading is not supported with mixin templates?


Re: Mixin template functions are ignored in struct

2014-10-14 Thread anonymous via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:58:19 UTC, tcak wrote:
I have written a struct and a mixin template, and that mixin 
template is mixed into that struct as follows.


private mixin template TestCommonMethods(){
public bool apply( int d, int e ){
return false;
}
}

public struct Test{
public mixin TestCommonMethods;

public bool apply( char c ){
return true;
}
}

void main(){
Test t;
t.apply( 5, 3 );
}

---

For the line t.apply( 5, 3 );, error is given saying that 
function test.apply(char c) is not callable.


---

For better testing, I added another function to template as 
public bool blah(){}, and called it in main, and it works. 
So, thus this mean overloading is not supported with mixin 
templates?


http://dlang.org/template-mixin.html says:
If the name of a declaration in a mixin is the same as a 
declaration in the surrounding scope, the surrounding 
declaration overrides the mixin one


So, yes, the mixed in `apply` doesn't overload with the other one.

You can use an alias declaration to bring them together:

public struct Test{
public mixin TestCommonMethods Common;
alias apply = Common.apply;

public bool apply( char c ){
return true;
}
}


Re: Mixin template functions are ignored in struct

2014-10-14 Thread tcak via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 21:10:02 UTC, anonymous wrote:

On Tuesday, 14 October 2014 at 20:58:19 UTC, tcak wrote:
I have written a struct and a mixin template, and that mixin 
template is mixed into that struct as follows.


private mixin template TestCommonMethods(){
public bool apply( int d, int e ){
return false;
}
}

public struct Test{
public mixin TestCommonMethods;

public bool apply( char c ){
return true;
}
}

void main(){
Test t;
t.apply( 5, 3 );
}

---

For the line t.apply( 5, 3 );, error is given saying that 
function test.apply(char c) is not callable.


---

For better testing, I added another function to template as 
public bool blah(){}, and called it in main, and it works. 
So, thus this mean overloading is not supported with mixin 
templates?


http://dlang.org/template-mixin.html says:
If the name of a declaration in a mixin is the same as a 
declaration in the surrounding scope, the surrounding 
declaration overrides the mixin one


So, yes, the mixed in `apply` doesn't overload with the other 
one.


You can use an alias declaration to bring them together:

public struct Test{
public mixin TestCommonMethods Common;
alias apply = Common.apply;

public bool apply( char c ){
return true;
}
}


Hmm, so it is not able to mix enough then. That's a weird 
decision though. Anyway, that suggested usage is making my work 
harder. I am putting that mixin in many struct and defining each 
method one by one in that way doesn't seem like suitable to me.


Re: Mixin template functions are ignored in struct

2014-10-14 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:58:19 UTC, tcak wrote:
So, thus this mean overloading is not supported with mixin 
templates?


Nope, what happens is mixin stuff adds items by name. If you have 
a variable or function in the object with the same name, it 
overrides the mixin one entirely.


This is really useful for customizing the behavior of a mixin by 
taking most but not all of its functions.


Re: Mixin template functions are ignored in struct

2014-10-14 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 21:21:33 UTC, tcak wrote:
Anyway, that suggested usage is making my work harder. I am 
putting that mixin in many struct and defining each method one 
by one in that way doesn't seem like suitable to me.


You could rename the method in the struct then mixin the rest. 
Like


private mixin template TestCommonMethods(){
public bool apply( int d, int e ){
return false;
}
}

public struct Test{
public mixin TestCommonMethods;

public bool apply2( char c ){ // now named apply2
return true;
}
}

void main(){
Test t;
t.apply( 5, 3 ); // works
t.apply2('c'); // also works
}



The mixin template might also define an apply function that just 
forwards the call to the other name, similarly to how a final 
method in a class or interface might call a virtual function to 
allow customization.


Re: Mixin template functions are ignored in struct

2014-10-14 Thread Daniel N via Digitalmars-d-learn

On Tuesday, 14 October 2014 at 20:58:19 UTC, tcak wrote:
I have written a struct and a mixin template, and that mixin 
template is mixed into that struct as follows.




Use a normal mixin + token strings(q{}).

enum TestCommonMethods = q{
public bool apply( int d, int e ){
return false;
}
};

public struct Test{
mixin(TestCommonMethods);

public bool apply(char c){
return true;
}
}

void main(){
Test t;
t.apply( 5, 3 );
}


What is this ? Howw to solve it ?

2014-10-14 Thread Domingo Alvarez Duarte via Digitalmars-d-learn
With dmd trunk trying to compile vibed after fixing several array 
declarations from C style to D style I'm getting this error that 
I do not understand:

---
Building vibe-d 0.7.21-rc.2 configuration libevent, build type 
debug.

Running dmd...
/home/mingo/dev/d/src/install/bin/../../../src/phobos/std/container/array.d(432): 
Error: cannot implicitly convert expression ((inout inout(Range) 
__ctmp3047 = 0;
 , __ctmp3047).this(this, 0LU, this.length())) of type 
inout(Range) to Range
source/vibe/core/drivers/timerqueue.d(29):while looking 
for match for BinaryHeap!(Array!(TimeoutEntry), a.timeout  
b.timeout)
source/vibe/core/drivers/libevent2.d(74): Error: template 
instance vibe.core.drivers.timerqueue.TimerQueue!(TimerInfo, 
1L) error instantiating

---

Any clue from the experts ?