Re: Regression vs Bug

2016-01-14 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 14 Jan 2016 17:32:47 +
NX via Digitalmars-d-learn  napsáno:

> Please explain.

Regression: something works before does not work anymore
Bug: something does not work as expected (regression is one type of bug)



Regression vs Bug

2016-01-14 Thread NX via Digitalmars-d-learn

Please explain.


DUB & Win-10 SDK / link lib not found

2016-01-14 Thread Robert M. Münch via Digitalmars-d-learn
I was expecting that DUB / DMD & NMAKE take $LIB into account. I try to 
compile some stuff on x64.


This is LIB:

D:\develop\d-language\webchat> $Env:lib
C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.10240.0\ucrt\x64;C:\Program Files (x86)\Windows 
Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.10240.0\um\x64;



This is the DUB call:

Linking...
dmd 
-of.dub\build\application-debug-windows-x86_64-dmd_2069-B25B434937830646D3F1C40AF40BEB8D\webchat.exe 
.dub\build\application-debug-windows-x86_64-dmd_2069-B25B434937830646D3F1C40AF40BEB8D\webchat.obj 
..\vibe-d-0.7.26\lib\win-amd64\libeay32.lib 
..\vibe-d-0.7.26\lib\win-amd64\ssleay32.lib ..\cairoD\cairoD.lib 
C:\Users\robby\AppData\Roaming\dub\packages\derelict-ft-1.0.2\lib\DerelictFT.lib 
C:\Users\robby\AppData\Roaming\dub\packages\derelict-util-2.0.4\lib\DerelictUtil.lib 
C:\Users\robby\AppData\Roaming\dub\packages\x11-1.0.9\x11.lib 
..\vibe-d-0.7.26\vibe-d.lib wsock32.lib ws2_32.lib advapi32.lib 
user32.lib -LD:\develop\Cairo-VS\projects\x64\Debug\cairo.lib 
-LD:\develop\Cairo-VS\projects\x64\Debug\pixman.lib -m64 -m64 -m64 -m64 
-m64 -m64 -g

LINK : fatal error LNK1104: cannot open file 'wsock32.lib'

Why isn't the "wsock32.lib" found? I really don't have a clue. I think 
that DMD's link step uses the MS tool. Is that right?


I really don't understand why the fundamental wsock32.lib is not found...

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: Glad and WGL

2016-01-14 Thread Dav1d via Digitalmars-d-learn

On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips wrote:

On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote:

Link with opengl32.lib


How? Everywhere I looked it says this cannot be done due to 
conflicting formats between the dmd compiler and the windows 
one.


Welcome to D and Windows. You can use GDC or LDC or try 
http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_(COFF-compatible)


Or you find an OMF opengl32.lib OR you make your own with implib 
and coff2omf

http://www.digitalmars.com/ctg/implib.html
http://www.digitalmars.com/ctg/coff2omf.html
I dont really remember how that worked.


Re: Glad and WGL

2016-01-14 Thread Dav1d via Digitalmars-d-learn

On Thursday, 14 January 2016 at 09:25:50 UTC, Dav1d wrote:
On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips 
wrote:

On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote:

Link with opengl32.lib


How? Everywhere I looked it says this cannot be done due to 
conflicting formats between the dmd compiler and the windows 
one.


Welcome to D and Windows. You can use GDC or LDC or try 
http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_(COFF-compatible)


Or you find an OMF opengl32.lib OR you make your own with 
implib and coff2omf

http://www.digitalmars.com/ctg/implib.html
http://www.digitalmars.com/ctg/coff2omf.html
I dont really remember how that worked.


There is also objconv: http://www.agner.org/optimize/

I found in an older code:

echo "implib /s opengl32.lib opengl32.dll && exit" | cmd

So maybe `implib /s opengl32.lib opengl32.dll` is enough. Would 
like to help you more, but I didnt need to deal with this shit 
lately (luckily) and forgot most of this mess.






Re: Scale-Hierarchy on ndslice

2016-01-14 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 13 January 2016 at 18:35:29 UTC, Ilya Yaroshenko 
wrote:

Ok, great. BTW: What is Mir?


https://github.com/DlangScience/mir --Ilya


Nice.


Re: Output range of ranges to single buffer

2016-01-14 Thread Ali Çehreli via Digitalmars-d-learn

On 01/13/2016 11:41 PM, Jacob Carlborg wrote:

> what if I need to format a third party type that I cannot add
> methods to? UFCS does not seem to work.

Here is an experiment that wraps the third party type to provide a lazy 
toString:


import std.stdio;
import std.format;
import std.array;
import std.algorithm;
import std.range;

/* Wraps an element and provides a lazy toString that dispatches the 
work to a

 * user-provided 'formatter' function. E is the element type. */
struct Formatted(alias formatter, E) {
E element;

void toString(void delegate(const(char)[]) sink) const {
formatter(sink, element);
}
}

/* Adapts a range by converting the elements to 'Formatted'. R is the range
 * type. */
auto formatted(alias formatter, R)(R range) {
return range.map!(e => Formatted!(formatter, ElementType!R)(e));
}

/* A third party test type that does not have a lazy toString member
 * function. */
struct Foo {
double d;
string s;
}

void main() {
auto data = [ Foo(1.5, "hello"), Foo(2.5, "world") ];

auto buf = appender!string();
formattedWrite(buf, "%(%s\n%)",
   data.formatted!(
   (sink, a) => formattedWrite(sink, "%s and %s",
   a.d, a.s)));

writeln(buf.data);
}

Prints the objects according to the user's lambda:

1.5 and hello
2.5 and world

It would be great if the user could provide just the format and accessed 
the members:


data.formatted!("%s and %s", a.d, a.s); // <-- ERROR

But I couldn't get it working because the compiler does not know what 
'a' is at that point. It might be acceptable to provide a lambda per 
member but then it gets to cluttered:


data.formatted!("%s and %s", a => a.d, a => a.s); // Might work

Ali



Re: DUB & Win-10 SDK / link lib not found

2016-01-14 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 14 January 2016 at 22:13:37 UTC, Robert M. Münch 
wrote:




Seems that some paths in sc.ini were not setup correctly. For 
x64 a Win10-SDK directory which doesn't exists was referenced.


Did you install DMD manually? In that case, you will usually need 
to edit sc.ini to point to the proper VC and Win SDK directories. 
The DMD installer should detect your installation and configure 
it for you.


Re: Output range of ranges to single buffer

2016-01-14 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-01-14 17:59, Ali Çehreli wrote:


Here is an experiment that wraps the third party type to provide a lazy
toString:

import std.stdio;
import std.format;
import std.array;
import std.algorithm;
import std.range;

/* Wraps an element and provides a lazy toString that dispatches the
work to a
  * user-provided 'formatter' function. E is the element type. */
struct Formatted(alias formatter, E) {
 E element;

 void toString(void delegate(const(char)[]) sink) const {
 formatter(sink, element);
 }
}


Wrap the object, why didn't I think of that :)


/* Adapts a range by converting the elements to 'Formatted'. R is the range
  * type. */
auto formatted(alias formatter, R)(R range) {
 return range.map!(e => Formatted!(formatter, ElementType!R)(e));
}

/* A third party test type that does not have a lazy toString member
  * function. */
struct Foo {
 double d;
 string s;
}

void main() {
 auto data = [ Foo(1.5, "hello"), Foo(2.5, "world") ];

 auto buf = appender!string();
 formattedWrite(buf, "%(%s\n%)",
data.formatted!(
(sink, a) => formattedWrite(sink, "%s and %s",
a.d, a.s)));

 writeln(buf.data);
}

Prints the objects according to the user's lambda:

1.5 and hello
2.5 and world


Thanks.

--
/Jacob Carlborg


Structs intended to run destructor immediately if not assigned to a variable?

2016-01-14 Thread rsw0x via Digitalmars-d-learn
Returning a struct with a destructor and not binding it to a 
variable appears to make the destructor run immediately instead 
of at the end of the scope.

Is this intended?

example:
http://dpaste.dzfl.pl/dd285200ba2b


Re: Structs intended to run destructor immediately if not assigned to a variable?

2016-01-14 Thread Ali Çehreli via Digitalmars-d-learn

On 01/14/2016 09:23 PM, rsw0x wrote:
> Returning a struct with a destructor and not binding it to a variable
> appears to make the destructor run immediately instead of at the end of
> the scope.
> Is this intended?
>
> example:
> http://dpaste.dzfl.pl/dd285200ba2b

Assuming that this rule is the same as in C++ (and I think so), the 
lifetime of a temporary variable is the whole expression that created 
it. So, the behaviour you are describing is intended.


Ali



Re: Glad and WGL

2016-01-14 Thread Josh Phillips via Digitalmars-d-learn

On Thursday, 14 January 2016 at 09:42:50 UTC, Dav1d wrote:

On Thursday, 14 January 2016 at 09:25:50 UTC, Dav1d wrote:
On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips 
wrote:
Welcome to D and Windows. You can use GDC or LDC or try 
http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_(COFF-compatible)


Or you find an OMF opengl32.lib OR you make your own with 
implib and coff2omf

http://www.digitalmars.com/ctg/implib.html
http://www.digitalmars.com/ctg/coff2omf.html
I dont really remember how that worked.


There is also objconv: http://www.agner.org/optimize/

I found in an older code:

echo "implib /s opengl32.lib opengl32.dll && exit" | cmd

So maybe `implib /s opengl32.lib opengl32.dll` is enough. Would 
like to help you more, but I didnt need to deal with this shit 
lately (luckily) and forgot most of this mess.


I actually got it to work by enforcing 64bit. DMD uses the VC 
Linker in 64bit mode I guess.


However I (of course) ran into new errors. Gl functions like 
glGetString and glGetIntegerv cause the program to crash. It 
appears that an opengl context is being created so I'm not sure 
whats causing the problem


Re: Output range of ranges to single buffer

2016-01-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 14, 2016 08:41:23 Jacob Carlborg via Digitalmars-d-learn 
wrote:
> On 2016-01-13 22:20, H. S. Teoh via Digitalmars-d-learn wrote:
>
> > Isn't that just a matter of replacing each of the segments with their
> > range equivalents? Also, std.format.formattedWrite will do
> > writeln-formatting into a buffer (well, any output range, really) -- I'm
> > pretty sure it doesn't allocate, at least for the simplest cases like
> > converting an integer. So you should be able to do something like this:
> >
> > auto data = [ 1, 2, 3, 4, 5 ];
> > char[] buf = ...;
> > formattedWrite(buf, "[%(%d, %)]", data);
>
> Aha, interesting. I didn't know formattedWrite could format an
> array/range directly like that.
>
> The more complex example works by defining "toString" which takes an
> output range (delegate). But what if I need to format a third party type
> that I cannot add methods to? UFCS does not seem to work.

You can't do toString via UFCS any more than you can overload any operators
via UFCS. If a type's toString does not work how you want, or a type does
not provide one, then you'll need to convert objects of that type to a
string in a different way.

- Jonathan M Davis



Re: DUB & Win-10 SDK / link lib not found

2016-01-14 Thread Robert M. Münch via Digitalmars-d-learn

On 2016-01-14 17:40:44 +, Robert M. Münch said:

I was expecting that DUB / DMD & NMAKE take $LIB into account. I try to 
compile some stuff on x64.


This is LIB:

D:\develop\d-language\webchat> $Env:lib
C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.10240.0\ucrt\x64;C:\Program Files (x86)\Windows 
Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.10240.0\um\x64;



This is the DUB call:

Linking...
dmd 
-of.dub\build\application-debug-windows-x86_64-dmd_2069-B25B434937830646D3F1C40AF40BEB8D\webchat.exe 
.dub\build\application-debug-windows-x86_64-dmd_2069-B25B434937830646D3F1C40AF40BEB8D\webchat.obj 
..\vibe-d-0.7.26\lib\win-amd64\libeay32.lib 
..\vibe-d-0.7.26\lib\win-amd64\ssleay32.lib ..\cairoD\cairoD.lib 
C:\Users\robby\AppData\Roaming\dub\packages\derelict-ft-1.0.2\lib\DerelictFT.lib 
C:\Users\robby\AppData\Roaming\dub\packages\derelict-util-2.0.4\lib\DerelictUtil.lib 
C:\Users\robby\AppData\Roaming\dub\packages\x11-1.0.9\x11.lib 
..\vibe-d-0.7.26\vibe-d.lib wsock32.lib ws2_32.lib advapi32.lib 
user32.lib -LD:\develop\Cairo-VS\projects\x64\Debug\cairo.lib 
-LD:\develop\Cairo-VS\projects\x64\Debug\pixman.lib -m64 -m64 -m64 -m64 
-m64 -m64 -g

LINK : fatal error LNK1104: cannot open file 'wsock32.lib'

Why isn't the "wsock32.lib" found? I really don't have a clue. I think 
that DMD's link step uses the MS tool. Is that right?


I really don't understand why the fundamental wsock32.lib is not found...


Seems that some paths in sc.ini were not setup correctly. For x64 a 
Win10-SDK directory which doesn't exists was referenced.


--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster