Re: drastic slowdown for copies

2015-05-29 Thread Momo via Digitalmars-d-learn

On Friday, 29 May 2015 at 07:51:31 UTC, thedeemon wrote:

On Thursday, 28 May 2015 at 21:23:11 UTC, Momo wrote:

Ah, actually it's more complicated, as it depends on inlining a 
lot.
Yes. And real functions are more complex and inlining is no 
reliable option.
Indeed, without -O and -inline I was able to get by_ref to be 
slightly slower than by_copy for struct of 4 ints. But when 
inlining turns on, the numbers change in different directions. 
And for 5 ints inlining influence is quite different:


4 ints: 5 ints:
-release
by ref: 53  by ref: 53
by copy: 57 by copy: 137
by move: 54 by move: 137

-release -O
by ref: 38  by ref: 34
by copy: 54 by copy: 137
by move: 49 by move: 137

-release -O -inline
by ref: 15  by ref: 20
by copy: 72 by copy: 91
by move: 72 by move: 91


So as you can see, it is 2-3 times slower. Is there an 
alternative?


Re: Windows Universal/Store apps support

2015-05-29 Thread Paulo Pinto via Digitalmars-d-learn

On Friday, 29 May 2015 at 03:23:39 UTC, Rikki Cattermole wrote:

On 29/05/2015 3:57 a.m., Olivier Prince wrote:
I searched the forum to find if there is some support for new 
Windows
development technologies and I didn't find anything related 
(except some

rants about WinRT 3 years ago).

- Is there any support in D or phobos for developping this 
kind of

applications?


No.


- Does D support ARM as Windows target?


Yes/No. ldc/gdc guys probably are a good place to start.

- Are there any plans to support the specific libraries in 
this respect

(something like C++/CX extensions or COM metadata files)?


What exactly do you need?


WinRT is an evolution of COM with a .NET feel to the API.

Basically it is COM where objects also need to implement a new 
interface, IInspectable, and .NET metadata stored in .winmd files 
is used instead of COM type libraries.


In a way WinRT is the return of Ext-VOS, the original idea behind 
.NET. Most likely caused by the Longhorn failure to write 
everything in .NET, as most new Windows APIs have been introduced 
as COM components since Vista.


So any language targeting WinRT, or Universal Apps as they are 
now known, needs to to support COM alongside the required 
interfaces for interoperability between languages and be able to 
consume/produce .NET metadata files.


--
Paulo


Re: drastic slowdown for copies

2015-05-29 Thread thedeemon via Digitalmars-d-learn

On Friday, 29 May 2015 at 07:51:31 UTC, thedeemon wrote:

Above was on Core 2 Quad,

here's for Core i3:

4 ints  5 ints
-release
by ref: 67  by ref: 66
by copy: 44 by copy: 142
by move: 45 by move: 137

-release -O
by ref: 29  by ref: 29
by copy: 41 by copy: 141
by move: 40 by move: 142

-release -O -inline
by ref: 16  by ref: 20
by copy: 83 by copy: 104
by move: 83 by move: 104


Re: Windows Universal/Store apps support

2015-05-29 Thread Rikki Cattermole via Digitalmars-d-learn

On 29/05/2015 7:03 p.m., Paulo Pinto wrote:

On Friday, 29 May 2015 at 03:23:39 UTC, Rikki Cattermole wrote:

On 29/05/2015 3:57 a.m., Olivier Prince wrote:

I searched the forum to find if there is some support for new Windows
development technologies and I didn't find anything related (except some
rants about WinRT 3 years ago).

- Is there any support in D or phobos for developping this kind of
applications?


No.


- Does D support ARM as Windows target?


Yes/No. ldc/gdc guys probably are a good place to start.


- Are there any plans to support the specific libraries in this respect
(something like C++/CX extensions or COM metadata files)?


What exactly do you need?


WinRT is an evolution of COM with a .NET feel to the API.

Basically it is COM where objects also need to implement a new
interface, IInspectable, and .NET metadata stored in .winmd files is
used instead of COM type libraries.

In a way WinRT is the return of Ext-VOS, the original idea behind .NET.
Most likely caused by the Longhorn failure to write everything in .NET,
as most new Windows APIs have been introduced as COM components since
Vista.

So any language targeting WinRT, or Universal Apps as they are now
known, needs to to support COM alongside the required interfaces for
interoperability between languages and be able to consume/produce .NET
metadata files.

--
Paulo


D already supports COM.
For .winmd, you should be good to go for -m32mscoff and -m64! Just add 
LFLAGS=/winmd


Although this really really needs to be tested.


Re: drastic slowdown for copies

2015-05-29 Thread thedeemon via Digitalmars-d-learn

On Thursday, 28 May 2015 at 21:23:11 UTC, Momo wrote:

Ah, actually it's more complicated, as it depends on inlining a 
lot.
Indeed, without -O and -inline I was able to get by_ref to be 
slightly slower than by_copy for struct of 4 ints. But when 
inlining turns on, the numbers change in different directions. 
And for 5 ints inlining influence is quite different:


4 ints: 5 ints:
-release
by ref: 53  by ref: 53
by copy: 57 by copy: 137
by move: 54 by move: 137

-release -O
by ref: 38  by ref: 34
by copy: 54 by copy: 137
by move: 49 by move: 137

-release -O -inline
by ref: 15  by ref: 20
by copy: 72 by copy: 91
by move: 72 by move: 91



Re: drastic slowdown for copies

2015-05-29 Thread thedeemon via Digitalmars-d-learn

On Thursday, 28 May 2015 at 21:23:11 UTC, Momo wrote:
I'm currently investigating the difference of speed between 
references and copies. And it seems that copies got a immense 
slowdown if they reach a size of = 20 bytes.


This is processor-specific, on different models of CPUs you might 
get different results. Here's what I see running your program 
with 4 and 5 ints in the struct:


C:\prog\Ddmd copyref.d -ofcopyref.exe -release -O -inline
16u

C:\prog\Dcopyref.exe
by ref: 18
by copy: 85
by move: 84

C:\prog\Dcopyref.exe
by ref: 18
by copy: 72
by move: 72

C:\prog\Dcopyref.exe
by ref: 16
by copy: 72
by move: 72

C:\prog\Ddmd copyref.d -ofcopyref.exe -release -O -inline
20u

C:\prog\Dcopyref.exe
by ref: 23
by copy: 98
by move: 91

C:\prog\Dcopyref.exe
by ref: 20
by copy: 91
by move: 102

C:\prog\Dcopyref.exe
by ref: 23
by copy: 91
by move: 91

I see these digits on an old Core 2 Quad and very similar on a 
Core i3. So your findings are not reproducible.


Re: Windows Universal/Store apps support

2015-05-29 Thread Paulo Pinto via Digitalmars-d-learn

On Friday, 29 May 2015 at 10:01:53 UTC, Rikki Cattermole wrote:

On 29/05/2015 9:55 p.m., Paulo Pinto wrote:

On Friday, 29 May 2015 at 07:41:14 UTC, Rikki Cattermole wrote:

On 29/05/2015 7:03 p.m., Paulo Pinto wrote:
On Friday, 29 May 2015 at 03:23:39 UTC, Rikki Cattermole 
wrote:

On 29/05/2015 3:57 a.m., Olivier Prince wrote:
I searched the forum to find if there is some support for 
new Windows
development technologies and I didn't find anything 
related (except

some
rants about WinRT 3 years ago).

- Is there any support in D or phobos for developping this 
kind of

applications?


No.


- Does D support ARM as Windows target?


Yes/No. ldc/gdc guys probably are a good place to start.

- Are there any plans to support the specific libraries in 
this

respect
(something like C++/CX extensions or COM metadata files)?


What exactly do you need?


WinRT is an evolution of COM with a .NET feel to the API.

Basically it is COM where objects also need to implement a 
new
interface, IInspectable, and .NET metadata stored in .winmd 
files is

used instead of COM type libraries.

In a way WinRT is the return of Ext-VOS, the original idea 
behind .NET.
Most likely caused by the Longhorn failure to write 
everything in .NET,
as most new Windows APIs have been introduced as COM 
components since

Vista.

So any language targeting WinRT, or Universal Apps as they 
are now
known, needs to to support COM alongside the required 
interfaces for
interoperability between languages and be able to 
consume/produce .NET

metadata files.

--
Paulo


D already supports COM.
For .winmd, you should be good to go for -m32mscoff and -m64! 
Just add

LFLAGS=/winmd

Although this really really needs to be tested.


As far as I am aware D supports old style COM, not COM with 
WinRT

improvements.

I don't get your hint with LFLAGS.


https://msdn.microsoft.com/en-us/library/jj157268.aspx
So unless this isn't doing what I think it is doing, then yes 
it is relevant.
No guarantees about what it requires for input info regarding 
e.g. symbols however.



Are you aware what are .NET metadata files?


I can't say anything about that. Again try the flag. If it 
doesn't do what I'm expecting it does, no harm. It's just a 
feature that definitely isn't implemented or supported by the 
toolchain.


Of course, just because it generates the file, doesn't mean 
that there will be anything of use within it.


The compiler provides the required information in C++/CX mode.

When using pure C++ with the Windows Runtime C++ Template Library 
instead[0], it requires an idl file to be given to the MIDL 
compiler, that is then fed to the linker, like old style COM type 
libraries.


[0] - 
https://msdn.microsoft.com/en-us/library/windows/apps/hh438466.aspx


[1] - 
https://msdn.microsoft.com/en-us/library/windows/apps/hh973463.aspx







Mutable reference for immutable AA

2015-05-29 Thread Jack Applegame via Digitalmars-d-learn
I need mutable storage for immutable associative array. Just 
create new immutable AA and store it for future passing it 
between threads/fibers.


First attempt: just immutable AA
immutable aa = [1:1, 2:1];
aa = [1:1, 2:1]; // fail, can't assign a new AA

Second attempt: mutable AA with immutable elements.
immutable (int)[string] aa = [1:1, 2:1];
aa = [1:1, 2:1]; // sucess!
aa[2] = 2; // doesn't compile, is AA immutable?
aa.remove(1);  // fail, this compiles, AA actually isn't 
immutable


Third attempt: Rebindable
Rebindable!(immutable int[string]) aa; // fail, Rebindable 
doesn't accept AAs


Re: Mutable reference for immutable AA

2015-05-29 Thread Jack Applegame via Digitalmars-d-learn
I made trivial pull request - 
https://github.com/D-Programming-Language/phobos/pull/3341


RebindableAA!(immutable int[string]) aa = [a: 1, b: 2]; // 
works

assert(aa[a] == 1);  // cool
aa = [a: 3, b: 4]; // nice
auto bb = aa;  // yes
bb = [a: 4, b: 5]; // super

aa[a] = 2;   // error, good
aa.remove(a);// error, very good




Re: Windows Universal/Store apps support

2015-05-29 Thread Rikki Cattermole via Digitalmars-d-learn

On 29/05/2015 9:55 p.m., Paulo Pinto wrote:

On Friday, 29 May 2015 at 07:41:14 UTC, Rikki Cattermole wrote:

On 29/05/2015 7:03 p.m., Paulo Pinto wrote:

On Friday, 29 May 2015 at 03:23:39 UTC, Rikki Cattermole wrote:

On 29/05/2015 3:57 a.m., Olivier Prince wrote:

I searched the forum to find if there is some support for new Windows
development technologies and I didn't find anything related (except
some
rants about WinRT 3 years ago).

- Is there any support in D or phobos for developping this kind of
applications?


No.


- Does D support ARM as Windows target?


Yes/No. ldc/gdc guys probably are a good place to start.


- Are there any plans to support the specific libraries in this
respect
(something like C++/CX extensions or COM metadata files)?


What exactly do you need?


WinRT is an evolution of COM with a .NET feel to the API.

Basically it is COM where objects also need to implement a new
interface, IInspectable, and .NET metadata stored in .winmd files is
used instead of COM type libraries.

In a way WinRT is the return of Ext-VOS, the original idea behind .NET.
Most likely caused by the Longhorn failure to write everything in .NET,
as most new Windows APIs have been introduced as COM components since
Vista.

So any language targeting WinRT, or Universal Apps as they are now
known, needs to to support COM alongside the required interfaces for
interoperability between languages and be able to consume/produce .NET
metadata files.

--
Paulo


D already supports COM.
For .winmd, you should be good to go for -m32mscoff and -m64! Just add
LFLAGS=/winmd

Although this really really needs to be tested.


As far as I am aware D supports old style COM, not COM with WinRT
improvements.

I don't get your hint with LFLAGS.


https://msdn.microsoft.com/en-us/library/jj157268.aspx
So unless this isn't doing what I think it is doing, then yes it is 
relevant.
No guarantees about what it requires for input info regarding e.g. 
symbols however.



Are you aware what are .NET metadata files?


I can't say anything about that. Again try the flag. If it doesn't do 
what I'm expecting it does, no harm. It's just a feature that definitely 
isn't implemented or supported by the toolchain.


Of course, just because it generates the file, doesn't mean that there 
will be anything of use within it.


Re: Windows Universal/Store apps support

2015-05-29 Thread Olivier Prince via Digitalmars-d-learn

On Friday, 29 May 2015 at 03:23:39 UTC, Rikki Cattermole wrote:

On 29/05/2015 3:57 a.m., Olivier Prince wrote:
I searched the forum to find if there is some support for new 
Windows
development technologies and I didn't find anything related 
(except some

rants about WinRT 3 years ago).

- Is there any support in D or phobos for developping this 
kind of

applications?


No.


- Does D support ARM as Windows target?


Yes/No. ldc/gdc guys probably are a good place to start.

- Are there any plans to support the specific libraries in 
this respect

(something like C++/CX extensions or COM metadata files)?


What exactly do you need?


Language integrated reference counting, runtime templates, 
partial COM classes, strings, arrays, collections, exceptions, 
events, delegates, attributes. I know that D has these features 
but I doubt that thay are mapped to COM counterparts.





- At least, is there a skeleton Store app written in D?


No.




Re: Windows Universal/Store apps support

2015-05-29 Thread Paulo Pinto via Digitalmars-d-learn

On Friday, 29 May 2015 at 07:41:14 UTC, Rikki Cattermole wrote:

On 29/05/2015 7:03 p.m., Paulo Pinto wrote:

On Friday, 29 May 2015 at 03:23:39 UTC, Rikki Cattermole wrote:

On 29/05/2015 3:57 a.m., Olivier Prince wrote:
I searched the forum to find if there is some support for 
new Windows
development technologies and I didn't find anything related 
(except some

rants about WinRT 3 years ago).

- Is there any support in D or phobos for developping this 
kind of

applications?


No.


- Does D support ARM as Windows target?


Yes/No. ldc/gdc guys probably are a good place to start.

- Are there any plans to support the specific libraries in 
this respect

(something like C++/CX extensions or COM metadata files)?


What exactly do you need?


WinRT is an evolution of COM with a .NET feel to the API.

Basically it is COM where objects also need to implement a new
interface, IInspectable, and .NET metadata stored in .winmd 
files is

used instead of COM type libraries.

In a way WinRT is the return of Ext-VOS, the original idea 
behind .NET.
Most likely caused by the Longhorn failure to write everything 
in .NET,
as most new Windows APIs have been introduced as COM 
components since

Vista.

So any language targeting WinRT, or Universal Apps as they are 
now
known, needs to to support COM alongside the required 
interfaces for
interoperability between languages and be able to 
consume/produce .NET

metadata files.

--
Paulo


D already supports COM.
For .winmd, you should be good to go for -m32mscoff and -m64! 
Just add LFLAGS=/winmd


Although this really really needs to be tested.


As far as I am aware D supports old style COM, not COM with WinRT 
improvements.


I don't get your hint with LFLAGS.

Are you aware what are .NET metadata files?

..
Paulo


Re: drastic slowdown for copies

2015-05-29 Thread Momo via Digitalmars-d-learn

Perhaps you can give me another detailed answer.
I get a slowdown for all parts (ref, copy and move) if I use 
uninitialized floats. I got these results from the following code:


by ref:  2369
by copy: 2335
by move: 2341

Code:

struct vec2f {
float x;
float y;
}

But if I assign 0 to them I got these results:

by ref:  49
by copy: 22
by move: 25

Why?


Re: Get index of string in array at compile time

2015-05-29 Thread Timon Gehr via Digitalmars-d-learn

On 05/29/2015 06:43 PM, tcak wrote:

I have define an immutable string array:

[code]
immutable string[] placeHolderDefinitionList = [
 !-- fullname --,
 !-- list item --
];
[/code]

I need to get index of a string at compile time. So I have written a
function as below:

[code]
public size_t getPlaceholderIndex(string PlaceHolderText)( size_t
lookIndex = 0 ){
 static if( lookIndex = placeHolderDefinitionList.length )
 return size_t.max;

 static if( placeHolderDefinitionList[lookIndex] == PlaceHolderText )
 return lookIndex;
 else
 return getPlaceholderIndex( lookIndex + 1 );
}
[/code]

Called it as below:

[code]
writeln( Index: , getPlaceholderIndex!!-- list item --( 0 ) );
[/code]

Compiler didn't like my code. It said those things to my face:

main.d(22): Error: variable lookIndex cannot be read at compile time
main.d(25): Error: variable lookIndex cannot be read at compile time
main.d(28): Error: template main.getPlaceholderIndex cannot deduce
function from argument types !()(ulong), candidates are:
main.d(21):main.getPlaceholderIndex(string
PlaceHolderText)(size_t lookIndex = 0)
main.d(105): Error: template instance main.getPlaceholderIndex!!--
list item -- error instantiating

This is my first try with this type of code. So I am confused a little
about what I should be doing.


The easiest way is to just write runtime code and evaluate it via CTFE:

immutable string[] placeHolderDefinitionList = [
!-- fullname --,
!-- list item --
];

void main(){
import std.stdio, std.algorithm;
enum index=placeHolderDefinitionList.countUntil(!-- list item --);
writeln(Index: , index);
}

If you never need the placeHolderDefinitionList at runtime, make it enum 
instead of immutable.




Get index of string in array at compile time

2015-05-29 Thread tcak via Digitalmars-d-learn

I have define an immutable string array:

[code]
immutable string[] placeHolderDefinitionList = [
!-- fullname --,
!-- list item --
];
[/code]

I need to get index of a string at compile time. So I have 
written a function as below:


[code]
public size_t getPlaceholderIndex(string PlaceHolderText)( size_t 
lookIndex = 0 ){

static if( lookIndex = placeHolderDefinitionList.length )
return size_t.max;

	static if( placeHolderDefinitionList[lookIndex] == 
PlaceHolderText )

return lookIndex;
else
return getPlaceholderIndex( lookIndex + 1 );
}
[/code]

Called it as below:

[code]
writeln( Index: , getPlaceholderIndex!!-- list item --( 0 ) 
);

[/code]

Compiler didn't like my code. It said those things to my face:

main.d(22): Error: variable lookIndex cannot be read at compile 
time
main.d(25): Error: variable lookIndex cannot be read at compile 
time
main.d(28): Error: template main.getPlaceholderIndex cannot 
deduce function from argument types !()(ulong), candidates are:
main.d(21):main.getPlaceholderIndex(string 
PlaceHolderText)(size_t lookIndex = 0)
main.d(105): Error: template instance 
main.getPlaceholderIndex!!-- list item -- error instantiating


This is my first try with this type of code. So I am confused a 
little about what I should be doing.


Re: Windows Universal/Store apps support

2015-05-29 Thread Jesse Phillips via Digitalmars-d-learn

On Thursday, 28 May 2015 at 15:57:42 UTC, Olivier Prince wrote:
I searched the forum to find if there is some support for new 
Windows development technologies and I didn't find anything 
related (except some rants about WinRT 3 years ago).


- Is there any support in D or phobos for developping this kind 
of applications?

- Does D support ARM as Windows target?
- Are there any plans to support the specific libraries in this 
respect (something like C++/CX extensions or COM metadata 
files)?

- At least, is there a skeleton Store app written in D?

Thanks.


I don't know of any work outside of the old Microsoft slides, so 
likely someone who is familiar with writing a C++ app will need 
to try it out and request improvements where things are missing.


Juno may be a good place to go for COM.

https://github.com/JesseKPhillips/Juno-Windows-Class-Library


Re: Windows Universal/Store apps support

2015-05-29 Thread ZombineDev via Digitalmars-d-learn

On Thursday, 28 May 2015 at 15:57:42 UTC, Olivier Prince wrote:

[snip]


There isn't yet a polished alternative to MS VS Windows Store 
toolchain, but probably you don't need most of it (e.g. you can 
have a C++/XAML app that calls you D code).
I noticed that Vibe.d has some WinRT support. Here's their WinRT 
driver, which uses calls some parts of WinRT API:


https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/drivers/winrt.d


Mixin - to get to the content-type `MapResult!(__lambda1, int[]).MapResult`

2015-05-29 Thread Dennis Ritchie via Digitalmars-d-learn

Hi,
This code prints the arrays:
[5]
[6]
[7]

import std.stdio, std.algorithm;

static int idx;

void walk(R)(R range) {
while (!range.empty) {
range.front;
range.popFront;
++idx;
}
}

void main() {
[5, 6, 7].map!(a = [a].writeln).walk;
}

How should I apply mixins to `range.front` to the program to 
print the arrays:

[0, 5]
[1, 6]
[2, 7]

Ie I want to get something like this:

void walk(R)(R range) {
while (!range.empty) {
// mixin(`[idx ~ mixin(range.front)[1 .. $]);`);
range.popFront;
++idx;
}
}

Can I do this?

-
Thank you for the function `walk` Mark Isaacson of presentation 
DConf 2015:

http://dconf.org/2015/talks/isaacson.pdf


Re: drastic slowdown for copies

2015-05-29 Thread Ali Çehreli via Digitalmars-d-learn

On 05/29/2015 06:55 AM, Momo wrote:

Perhaps you can give me another detailed answer.
I get a slowdown for all parts (ref, copy and move) if I use
uninitialized floats.


Floating point variables are initialized to .nan of their types (e.g. 
float.nan). Apparently, the CPU is slow when using those special values:



http://stackoverflow.com/questions/3606054/how-slow-is-nan-arithmetic-in-the-intel-x64-fpu

Ali