Re: Formatted output of range of tuples

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

On 10/08/2014 02:31 PM, bearophile wrote:

 For indexes now there is also enumerate.

 Bye,
 bearophile

Thanks for the tip. std.range.enumerate makes a big difference:

foreach (i, element; MyRange(42).enumerate) {
// ...
}

versus sequence!n and zip:

foreach (i, element; zip(sequence!n, MyRange(42))) {
// ...
}

Ali



Re: Formatted output of range of tuples

2014-10-13 Thread bearophile via Digitalmars-d-learn

Ali Çehreli:


foreach (i, element; MyRange(42).enumerate) {
// ...
}

versus sequence!n and zip:

foreach (i, element; zip(sequence!n, MyRange(42))) {
// ...
}


But it's better to not use automatic unpacking of tuples. See 
issues 7361 and especially 9817.


Bye,
bearophile


Re: COFF on Win32 how to try?

2014-10-13 Thread Szymon Gatner via Digitalmars-d-learn

On Saturday, 11 October 2014 at 13:35:55 UTC, Rainer Schuetze
wrote:


Yes, DMD git HEAD is required.


Getting this when trying to build all with Digger:

std\uri.d(872): Deprecation: alias object.clear is deprecated -
Please use destroy instead.
std\uri.d(1166): Deprecation: alias object.clear is deprecated -
Please use destroy instead.
std\concurrency.d(1352): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1354): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1348): Error: function
std.concurrency.FiberScheduler.FiberCondition.wait no return exp;
or assert(0); at end of function
std\concurrency.d(1395): Error: function expected before (), not
this.m_fibers[this.m_pos].state() of type State
std\concurrency.d(1971): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(2019): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1822): Error: function
std.concurrency.MessageBox.get!(Duration, bool delegate(Tid
origin, CurlMessage!(immutable(ubyte)[]) _data) @system, bool
delegate(Tid origin, CurlMessage!bool f) @system).get no return
exp; or assert(0); at end of function
std\concurrency.d(811): Error: template instance
std.concurrency.MessageBox.get!(Duration, bool delegate(Tid
origin, CurlMessage!(immutable(ubyte)[]) _data) @system, bool
delegate(Tid origin, CurlMessage!bool f) @system) error
instantiating
std\net\curl.d(1185):instantiated from here:
receiveTimeout!(bool delegate(Tid origin,
CurlMessage!(immutable(ubyte)[]) _data) @system, bool
delegate(Tid origin, CurlMessage!bool f) @system)
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(225): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(235): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(236): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(225): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(235): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(236): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does 

Re: COFF on Win32 how to try?

2014-10-13 Thread Szymon Gatner via Digitalmars-d-learn

On Saturday, 11 October 2014 at 13:35:55 UTC, Rainer Schuetze
wrote:


Yes, DMD git HEAD is required.


Getting this when trying to build all with Digger:

std\uri.d(872): Deprecation: alias object.clear is deprecated -
Please use destroy instead.
std\uri.d(1166): Deprecation: alias object.clear is deprecated -
Please use destroy instead.
std\concurrency.d(1352): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1354): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1348): Error: function
std.concurrency.FiberScheduler.FiberCondition.wait no return exp;
or assert(0); at end of function
std\concurrency.d(1395): Error: function expected before (), not
this.m_fibers[this.m_pos].state() of type State
std\concurrency.d(1971): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(2019): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1822): Error: function
std.concurrency.MessageBox.get!(Duration, bool delegate(Tid
origin, CurlMessage!(immutable(ubyte)[]) _data) @system, bool
delegate(Tid origin, CurlMessage!bool f) @system).get no return
exp; or assert(0); at end of function
std\concurrency.d(811): Error: template instance
std.concurrency.MessageBox.get!(Duration, bool delegate(Tid
origin, CurlMessage!(immutable(ubyte)[]) _data) @system, bool
delegate(Tid origin, CurlMessage!bool f) @system) error
instantiating
std\net\curl.d(1185):instantiated from here:
receiveTimeout!(bool delegate(Tid origin,
CurlMessage!(immutable(ubyte)[]) _data) @system, bool
delegate(Tid origin, CurlMessage!bool f) @system)
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(225): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(235): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(236): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(225): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(235): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(236): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to be impure - mark it with 'pure' if it is
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to be impure - mark it with 'pure' if it is not
std\internal\math\biguintx86.d(120): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-141(141): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(147): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does not
std\internal\math\biguintx86.d-mixin-158(158): Deprecation: asm
statement is assumed to throw - mark it with 'nothrow' if it does
not
std\internal\math\biguintx86.d(163): Deprecation: asm statement
is assumed to throw - mark it with 'nothrow' if it does 

Re: how to call class' template constructor

2014-10-13 Thread ketmar via Digitalmars-d-learn
On Sun, 12 Oct 2014 21:30:44 -0400
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:

 At least someone else has found a similar issue before: 
 https://issues.dlang.org/show_bug.cgi?id=10689
hm. i somehow missed this in my searches. thanks.

 I'm not sure what proper syntax would be, perhaps:
 auto a = (new A)!foo(xFn);
how about: `auto a = new A.this!foo(xFn);`?

there is no harm in specifying constructor name for resolving ambiguity
here. and it still allows `auto a = new A!int.this!foo(xFn);` for
example. and it's not breaking any existing code, afaik.

i'm sure that this is not a complex patch. let's hope someone will write
it and convince Walter to accept it.


signature.asc
Description: PGP signature


Re: Formatted output of range of tuples

2014-10-13 Thread monarch_dodra via Digitalmars-d-learn

On Wednesday, 8 October 2014 at 23:28:34 UTC, bearophile wrote:

anonymous:


You can turn the tuples into ranges with `only`:

writef(%(%(%s %)\n%), zip(indexes, source).map!(t = 
only(t.expand)));


This is a nice idea. Expand can probably be replaced by a []. I 
presume this works only if the types inside the tuple are the 
same.


Expand creates returns a TypeTuple though, so it's arguably 
free. [] allocates a dynamic array, so is costly.


On the flip side, only is *entirelly* by value, and carries all 
its arguments. If the tuple is big, then the range can become 
quite big.


Re: Formatted output of range of tuples

2014-10-13 Thread Sag Academy via Digitalmars-d-learn

On Monday, 13 October 2014 at 09:20:27 UTC, monarch_dodra wrote:

On Wednesday, 8 October 2014 at 23:28:34 UTC, bearophile wrote:

anonymous:


You can turn the tuples into ranges with `only`:

writef(%(%(%s %)\n%), zip(indexes, source).map!(t = 
only(t.expand)));


This is a nice idea. Expand can probably be replaced by a []. 
I presume this works only if the types inside the tuple are 
the same.


Expand creates returns a TypeTuple though, so it's arguably 
free. [] allocates a dynamic array, so is costly.


On the flip side, only is *entirelly* by value, and carries 
all its arguments. If the tuple is big, then the range can 
become quite big.



you are right man.


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

2014-10-13 Thread Robert burner Schadek via Digitalmars-d-learn
hm, the problems seams to be that inout Array is not becoming 
const Array and friends.


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 
qualifier.


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



is there any hack to determine if variable is __gshared?

2014-10-13 Thread ketmar via Digitalmars-d-learn
Hello.

i need to enumerate all module variables of the given types (it's easy,
this is not the question) and make list of only __gshared ones. of
course, i'm talking about CTFE.

is there any hack/trick to determine if variable is __gshared? or if it
is a thread-local, for that matter?

i added 'isGShared' trait to my compiler, but i'm not expecting from
others to do the same. ;-)

the only hack i invented is this abomination:

  int v0;
  __gshared int v1;


  enum isGShared(alias var) =
!__traits(compiles,
  mixin({auto a___ = function typeof(~var.stringof~
) () @safe { return ~var.stringof~; };}));


  pragma(msg, isGShared!v0); // false
  pragma(msg, isGShared!v1); // true


sure, it's very limited, and we must do alot of checks before using it.
it *SEEMS* to work, but i not tested it very well.


signature.asc
Description: PGP signature


Re: is there any hack to determine if variable is __gshared?

2014-10-13 Thread bearophile via Digitalmars-d-learn

ketmar:

is there any hack/trick to determine if variable is __gshared? 
or if it is a thread-local, for that matter?


There is the -vtls compiler switch.

Bye,
bearophile


Re: ini library in OSX

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

On Saturday, 11 October 2014 at 22:38:20 UTC, Joel wrote:
On Thursday, 11 September 2014 at 10:49:48 UTC, Robert burner 
Schadek wrote:

some self promo:

http://code.dlang.org/packages/inifiled


I would like an example?


go to the link and scroll down a page


Re: is there any hack to determine if variable is __gshared?

2014-10-13 Thread ketmar via Digitalmars-d-learn
On Mon, 13 Oct 2014 15:57:13 +
bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:

  is there any hack/trick to determine if variable is __gshared? 
  or if it is a thread-local, for that matter?
 
 There is the -vtls compiler switch.

let me quote myself: i'm talking about CTFE. i need to build mixin
string with this variables, to be precise.


signature.asc
Description: PGP signature


Re: COFF on Win32 how to try?

2014-10-13 Thread Rainer Schuetze via Digitalmars-d-learn



On 13.10.2014 10:12, Szymon Gatner wrote:

On Saturday, 11 October 2014 at 13:35:55 UTC, Rainer Schuetze
wrote:


Yes, DMD git HEAD is required.


Getting this when trying to build all with Digger:

std\uri.d(872): Deprecation: alias object.clear is deprecated -
Please use destroy instead.
std\uri.d(1166): Deprecation: alias object.clear is deprecated -
Please use destroy instead.
std\concurrency.d(1352): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1354): Error: function expected before (), not
currSystemTick() of type TickDuration
std\concurrency.d(1348): Error: function
std.concurrency.FiberScheduler.FiberCondition.wait no return exp;
or assert(0); at end of function
std\concurrency.d(1395): Error: function expected before (), not
this.m_fibers[this.m_pos].state() of type State
std\concurrency.d(1971): Error: function expected before (), not
currSystemTick() of type TickDuration

...


--- errorlevel 1
Fatal error: Command [make, -f, win32.mak, phobos.lib,
MODEL=32] failed with status 1

Sorry for taking your time. I thin, I'll just wait for 2.067 and
re-try then.


I believe you have built the pull requests by choosing Make me one with 
everything from the web interface. That stops at the first failing one.


Just hit Build. That worked for Win32 for me, but I got a ZipException 
when downloading the tools to build Win64.


Can someone explain how glfw3.dll gets created?

2014-10-13 Thread WhatMeWorry via Digitalmars-d-learn
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.

I rebuildt the DerelictGLFW3 with dub as per the instructions.

E:\DerelictGLFW3-masterdub build
Building derelict-glfw3 ~master configuration library, build 
type debug.

Running dmd...

And I see
E:\DerelictGLFW3-master\source\derelict\glfw3\glfw3.d  which is 
used for compile time.


And the
E:\DerelictGLFW3-master\lib\DerelictGLFW3.lib which is the static 
library required at link time.


But I couldn't find any glfw3.dll under the 
E:\DerelictGLFW3-master path.



I did however, find these lines in the DerelictGLFW3/glfw3.d code:
...
static if( Derelict_OS_Windows )
   enum libNames = glfw3.dll;
. . .
class DerelictGLFW3Loader : SharedLibLoader {
public this() {
super( libNames );
}

protected override void loadSymbols() {
bindFunc( cast( void** )glfwInit, glfwInit );
bindFunc( cast( void** )glfwTerminate, glfwTerminate );
bindFunc( cast( void** )glfwGetVersion, glfwGetVersion 
);
bindFunc( cast( void** )glfwGetVersionString, 
glfwGetVersionString );
bindFunc( cast( void** )glfwSetErrorCallback, 
glfwSetErrorCallback );

 ...

But I don't believe this will create the glfw3.dll file?  If I'm 
correct, how, when and where is glfw3.dll created.


thanks as always.


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

2014-10-13 Thread Kapps via Digitalmars-d-learn
Derelict provides bindings to C libraries, and loads them at 
runtime. So glfw3.dll is actually an existing C library (you can 
get it at http://www.glfw.org/download.html), which Derelict 
provides bindings for. Derelict / your code does not generate the 
actual dll.


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

2014-10-13 Thread John Colvin via Digitalmars-d-learn

On Monday, 13 October 2014 at 20:21:56 UTC, 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.

I rebuildt the DerelictGLFW3 with dub as per the instructions.

E:\DerelictGLFW3-masterdub build
Building derelict-glfw3 ~master configuration library, build 
type debug.

Running dmd...

And I see
E:\DerelictGLFW3-master\source\derelict\glfw3\glfw3.d  which is 
used for compile time.


And the
E:\DerelictGLFW3-master\lib\DerelictGLFW3.lib which is the 
static library required at link time.


But I couldn't find any glfw3.dll under the 
E:\DerelictGLFW3-master path.



I did however, find these lines in the DerelictGLFW3/glfw3.d 
code:

...
static if( Derelict_OS_Windows )
   enum libNames = glfw3.dll;
. . .
class DerelictGLFW3Loader : SharedLibLoader {
public this() {
super( libNames );
}

protected override void loadSymbols() {
bindFunc( cast( void** )glfwInit, glfwInit );
bindFunc( cast( void** )glfwTerminate, glfwTerminate 
);
bindFunc( cast( void** )glfwGetVersion, 
glfwGetVersion );
bindFunc( cast( void** )glfwGetVersionString, 
glfwGetVersionString );
bindFunc( cast( void** )glfwSetErrorCallback, 
glfwSetErrorCallback );

 ...

But I don't believe this will create the glfw3.dll file?  If 
I'm correct, how, when and where is glfw3.dll created.


thanks as always.


Derelict-glfw3 is just d bindings and a loader for the glfw3 
library. The actual implementation of glfw (i.e. what you would 
find in glfw3.dll) is a separate project, which you can find the 
source for here http://www.glfw.org


dsource and WinAPI

2014-10-13 Thread dcrepid via Digitalmars-d-learn
I've tried to create an account on dsource.org without success, 
and am wondering if anyone here knows if they are no longer 
accepting new users or whatnot?


I've added a new winhttp.d source file for the win32 folder and 
would like to somehow contribute it.


thanks!


Re: dsource and WinAPI

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

On 10/13/14 8:17 PM, dcrepid wrote:

I've tried to create an account on dsource.org without success, and am
wondering if anyone here knows if they are no longer accepting new users
or whatnot?


dsource is no longer actively maintained. I don't think anyone knows how 
to contact the admin. Most D projects these days are done on github.




I've added a new winhttp.d source file for the win32 folder and would
like to somehow contribute it.


Which project are you looking at?

-Steve