Re: OSX Foundation framework D binding

2015-11-11 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 11 Nov 2015 06:17:00 +
Vadim Lopatin via Digitalmars-d-learn
 napsáno:

> Hello,
> 
> I'm working on native Cocoa backend for DlangUI GUI library under 
> OSX.
> Is there any ready to use bindings for easy accessing Cocoa API?
> Probably, there is some HelloWorld program which creates window 
> and draws something?
> 
> 
> Best regards,
>   Vadim

I find only this one: http://code.dlang.org/packages/derelict-cocoa



Re: DUB library prefix - rules ?

2015-11-11 Thread Nicholas Wilson via Digitalmars-d-learn

On Wednesday, 11 November 2015 at 05:03:47 UTC, BBaz wrote:

quoted from the website:

Sets the base name of the output file; type and platform 
specific pre- and suffixes are added automatically

- this setting does not support platform suffixes


I must be blind but I can't find the code that adds the 'lib' 
prefix on GitHub. I need to check something:


Is it correct to say that
- under Macosx and Linux, the 'lib' prefix is added if target 
is a library.

- under Windows, nothing is added and targetName is used as it.

Otherwise, if you have the link with the matching line 
highlihted on GH.


From what i understand yes. That option ( I think ) is for if you 
have a project foo with libraries bar and baz you can make it 
call the libs (lib)foobar.(a|so|dylib|lib |.etc) and libfoobaz.a


Re: my first D program (and benchmark against perl)

2015-11-11 Thread Edwin van Leeuwen via Digitalmars-d-learn

On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote:

for (int rownum=0; rownum < table.length; rownum++) {
res ~= "|";
for (int colnum=0; colnum < table[rownum].length; 
colnum++) {
res ~= leftJustify(table[rownum][colnum], 
widths[colnum]);

res ~= "|";
}
res ~= "\n";


Not sure if this will be faster, but you could try rewriting the 
above for loop

with more functional code (code below is untested):

table.map!((col)
  { return zip(col,widths)
  .map!( (e) => leftJustify(e[0], e[1] ) )
  .join("|");
  }).join("\n");

Cheers,

Edwin


Re: Error: no property "someFont" for type int

2015-11-11 Thread Marco de Wild via Digitalmars-d-learn
This is not D. It should be giving you a compiler error. How 
are you compiling? Or did you type 'using' in the post by 
mistake? Anyway, what you want is:


import style;

I indeed made a typo while typing the post (and also on various 
occasions while writing the program, but compiler errors fixed 
that). That's what you get for using C# at work.


In style.d:
module style;
(...)
public static class Style
{


'static class' has no meaning in module scope, only for inner 
classes. It's not the cause of your problem though.


Thanks for the heads up :) I figured it was about time to dust my 
D-skills.




The error is likley because of a symbol conflict. Assuming that 
Text is from the module dsfml.text.graphics, it has an enum 
type named Style. There's an unfortunate issue in D that allows 
both of the following to compile:


auto e1 = Text.Style.Regular;
_text.Style.Regular;

The latter should not be allowed, IMO, but it is what it is. So 
in your case, accessing your Style class in the scope of 
with(_text) is causing the compiler to find _text.Style. The 
solution is to use the FQN (Fully Qualified Name) on your Style 
inside the with, i.e. style.Style, or to drop the with 
altogether.


Dropping the with worked like a charm, thanks a lot for the fast 
reply!




Re: my first D program (and benchmark against perl)

2015-11-11 Thread cym13 via Digitalmars-d-learn

On Wednesday, 11 November 2015 at 16:02:07 UTC, H. S. Teoh wrote:
If performance is a problem, my first reaction would be to try 
GDC or LDC.  While there have been recent improvements in DMD 
code generation quality, it still has a ways to go to catch 
with GDC/LDC's optimizer.



T


My computer seems to agree (note that I did those a bunch of time 
with
intermediate rounds to heat the cache, these numbers are only to 
give

a rough idea):

$time rdmd --compiler=ldc test.d
|row1.1|row1.2  |row1.3  |
|row2.1|row2.2  |row2.3  |
|row3.1|row3.2  |row3.3  |
|row4.1|row4.2  |row4.3  |
|row5.1|row5.2  |row5.3  |
rdmd --compiler=ldc test.d  6.07s user 0.10s system 99% cpu 6.177 
total


$time rdmd --compiler=dmd test.d
|row1.1|row1.2  |row1.3  |
|row2.1|row2.2  |row2.3  |
|row3.1|row3.2  |row3.3  |
|row4.1|row4.2  |row4.3  |
|row5.1|row5.2  |row5.3  |
rdmd --compiler=dmd test.d  21.21s user 0.09s system 97% cpu 
21.919 total


$time ./test.pl
|row1.1|row1.2  |row1.3  |
|row2.1|row2.2  |row2.3  |
|row3.1|row3.2  |row3.3  |
|row4.1|row4.2  |row4.3  |
|row5.1|row5.2  |row5.3  |
./test.pl  13.71s user 0.00s system 99% cpu 13.715 total


With optimization on it is better but still not enough for dmd:


$time rdmd --compiler=ldc -inline -release -O test.d
|row1.1|row1.2  |row1.3  |
|row2.1|row2.2  |row2.3  |
|row3.1|row3.2  |row3.3  |
|row4.1|row4.2  |row4.3  |
|row5.1|row5.2  |row5.3  |
rdmd --compiler=ldc -inline -release -O test.d  4.99s user 0.09s 
system 98% cpu 5.170 total


$time rdmd --compiler=dmd -inline -release -O test.d
|row1.1|row1.2  |row1.3  |
|row2.1|row2.2  |row2.3  |
|row3.1|row3.2  |row3.3  |
|row4.1|row4.2  |row4.3  |
|row5.1|row5.2  |row5.3  |
rdmd --compiler=dmd -inline -release -O test.d  12.67s user 0.06s 
system 99% cpu 12.736 total




Re: OSX Foundation framework D binding

2015-11-11 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-11-11 10:29, Daniel Kozak via Digitalmars-d-learn wrote:


I find only this one: http://code.dlang.org/packages/derelict-cocoa


Also, there's no point in complicate the bindings by using function 
pointers like this.


--
/Jacob Carlborg


Re: my first D program (and benchmark against perl)

2015-11-11 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 11, 2015 at 02:26:28PM +, Andrea Fontana via 
Digitalmars-d-learn wrote:
> On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote:
> >While I am quite impressed with how easy I was able to write D, I am
> >not so impressed with the performance. Using rdmd (build 20151103),
> >the D program runs in 17.127s while the Perl version runs in 11.391s
> >(so the D version is quite a bit *slower* than Perl's). While using
> >gdc (Debian 4.9.2-10), I am able to run it in 3.988s (only about 3x
> >faster than Perl's version).
> >
> >I understand that string processing (concatenation, allocation) is
> >quite optimized in Perl, I was wondering if the D version could still
> >be sped up significantly?
> 
> Did you try rdmd -O -noboundscheck -release yourscript.d ?
[...]

If performance is a problem, my first reaction would be to try GDC or
LDC.  While there have been recent improvements in DMD code generation
quality, it still has a ways to go to catch with GDC/LDC's optimizer.


T

-- 
Старый друг лучше новых двух.


Re: my first D program (and benchmark against perl)

2015-11-11 Thread Rikki Cattermole via Digitalmars-d-learn

On 12/11/15 2:31 AM, perlancar wrote:

Here's my first non-hello-world D program, which is a direct translation
from the Perl version. I was trying to get a feel about D's performance:

---BEGIN asciitable.d---
import std.string;
import std.stdio;

string fmttable(ref string[][] table) {
 string res = "";

 // column widths
 int[] widths;

 if (table.length == 0) return "";

 widths.length = table[0].length;

 for (int colnum=0; colnum < table[0].length; colnum++) {
 int width = 0;
 for (int rownum=0; rownum < table.length; rownum++) {
 if (table[rownum][colnum].length > width)
 width = cast(int) table[rownum][colnum].length;
 }
 widths[colnum] = width;
 }

 for (int rownum=0; rownum < table.length; rownum++) {
 res ~= "|";
 for (int colnum=0; colnum < table[rownum].length; colnum++) {
 res ~= leftJustify(table[rownum][colnum], widths[colnum]);
 res ~= "|";
 }
 res ~= "\n";
 }

 return res;
}

void main() {
 // tiny table (1x1)
 /*
 string[][] table = [
 ["row1.1"],
 ];
 */

 // small table (3x5)
 string[][] table = [
 ["row1.1", "row1.2  ", "row1.3"],
 ["row2.1", "row2.2", "row2.3"],
 ["row3.1", "row3.2", "row3.3  "],
 ["row4.1", "row4.2", "row4.3"],
 ["row5.1", "row5.2", "row5.3"],
 ];

 write(fmttable(table));
 for (int i=0; i < 100; i++) {
 fmttable(table);
 }
}
---END asciitable.d---

Perl version:

---BEGIN asciitable.pl---
#!/usr/bin/env perl

sub fmttable {
 my $table = shift;

 my $res = "";

 # column widths
 my @widths;

 if (@$table == 0) { return "" }

 for my $colnum (0 .. $#{$table->[0]}) {
 my $width = 0;
 for my $rownum (0 .. $#{$table}) {
 if (length($table->[$rownum][$colnum]) > $width) {
 $width = length($table->[$rownum][$colnum]);
 }
 }
 $widths[$colnum] = $width;
 }

 for my $rownum (0..$#{$table}) {
 $res .= "|";
 for my $colnum (0..$#{$table->[$rownum]}) {
 $res .= sprintf("%-".$widths[$colnum]."s|",
$table->[$rownum][$colnum]);
 }
 $res .= "\n";
 }
 $res;
}

# tiny table (1x1)
#my $table = [["row1.1"]];

# small table (3x5)
my $table = [
 ["row1.1", "row1.2", "row1.3"],
 ["row2.1", "row2.2  ", "row2.3"],
 ["row3.1", "row3.2", "row3.3  "],
 ["row4.1", "row4.2", "row4.3"],
 ["row5.1", "row5.2", "row5.3"],
];

print fmttable($table);

for (1..1_000_000) {
 fmttable($table);
}
---END asciitable.pl---

While I am quite impressed with how easy I was able to write D, I am not
so impressed with the performance. Using rdmd (build 20151103), the D
program runs in 17.127s while the Perl version runs in 11.391s (so the D
version is quite a bit *slower* than Perl's). While using gdc (Debian
4.9.2-10), I am able to run it in 3.988s (only about 3x faster than
Perl's version).

I understand that string processing (concatenation, allocation) is quite
optimized in Perl, I was wondering if the D version could still be sped
up significantly?


I turned it into mostly using large allocations, instead of small ones.
Although I'd recommend using Appender instead of my custom functions for 
this.


Oh and for me, I got it at 2 secs, 513 ms, 397 μs, and 5 hnsecs. 
Unoptimized, using dmd.
When release mode is enabled on dmd: 1 sec, 550 ms, 838 μs, and 9 
hnsecs. So significant improvement even with dmds awful optimizer.


import std.string;
import std.stdio;

static string SPACES = " 
  ";


string fmttable(string[][] table) {
char[] res;

// column widths
int[] widths;
size_t totalSize;

if (table.length == 0) return "";

widths.length = table[0].length;

foreach(colnum; 0 .. table[0].length) {
int width = 0;
size_t count;

foreach(rownum; 0 .. table.length) {
if (table[rownum][colnum].length > width)
width = cast(int) table[rownum][colnum].length;
count += table[rownum].length;
}

totalSize += ((width + 1) * count) + 2;
widths[colnum] = width;
}

char[] buffer = new char[](totalSize);

void assignText(string toAdd) {
if (res.length < buffer.length - toAdd.length) {
} else {
buffer.length += toAdd.length;
}

res = buffer[0 .. res.length + toAdd.length];
res[$-toAdd.length .. $] = toAdd[];
}


foreach(rownum; 0 .. table.length) {
assignText("|");
foreach(colnum; 0 .. table[rownum].length) {
assignText(SPACES[0 .. widths[colnum] - 
table[rownum][colnum].length]);

assignText(table[rownum][colnum]);
assignText("|");
}
assignText("\n");
}

return cast(string)res;
}

void main() {
// tiny table (1x1)
  

Re: OSX Foundation framework D binding

2015-11-11 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-11-11 17:02, Jacob Carlborg wrote:


I would recommend creating new bindings which use the new Objective-C
interoperability feature that was added in the latest release (2.069.0).


You could use DStep [1] to generate the bindings. It will generate 
bindings which are not completely compatible with what the compiler can 
handle. But it can be used as a base.


[1] https://github.com/jacob-carlborg/dstep

--
/Jacob Carlborg


Re: OSX Foundation framework D binding

2015-11-11 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-11-11 10:29, Daniel Kozak via Digitalmars-d-learn wrote:


I find only this one: http://code.dlang.org/packages/derelict-cocoa


I would recommend creating new bindings which use the new Objective-C 
interoperability feature that was added in the latest release (2.069.0).


--
/Jacob Carlborg


my first D program (and benchmark against perl)

2015-11-11 Thread perlancar via Digitalmars-d-learn
Here's my first non-hello-world D program, which is a direct 
translation from the Perl version. I was trying to get a feel 
about D's performance:


---BEGIN asciitable.d---
import std.string;
import std.stdio;

string fmttable(ref string[][] table) {
string res = "";

// column widths
int[] widths;

if (table.length == 0) return "";

widths.length = table[0].length;

for (int colnum=0; colnum < table[0].length; colnum++) {
int width = 0;
for (int rownum=0; rownum < table.length; rownum++) {
if (table[rownum][colnum].length > width)
width = cast(int) table[rownum][colnum].length;
}
widths[colnum] = width;
}

for (int rownum=0; rownum < table.length; rownum++) {
res ~= "|";
for (int colnum=0; colnum < table[rownum].length; 
colnum++) {
res ~= leftJustify(table[rownum][colnum], 
widths[colnum]);

res ~= "|";
}
res ~= "\n";
}

return res;
}

void main() {
// tiny table (1x1)
/*
string[][] table = [
["row1.1"],
];
*/

// small table (3x5)
string[][] table = [
["row1.1", "row1.2  ", "row1.3"],
["row2.1", "row2.2", "row2.3"],
["row3.1", "row3.2", "row3.3  "],
["row4.1", "row4.2", "row4.3"],
["row5.1", "row5.2", "row5.3"],
];

write(fmttable(table));
for (int i=0; i < 100; i++) {
fmttable(table);
}
}
---END asciitable.d---

Perl version:

---BEGIN asciitable.pl---
#!/usr/bin/env perl

sub fmttable {
my $table = shift;

my $res = "";

# column widths
my @widths;

if (@$table == 0) { return "" }

for my $colnum (0 .. $#{$table->[0]}) {
my $width = 0;
for my $rownum (0 .. $#{$table}) {
if (length($table->[$rownum][$colnum]) > $width) {
$width = length($table->[$rownum][$colnum]);
}
}
$widths[$colnum] = $width;
}

for my $rownum (0..$#{$table}) {
$res .= "|";
for my $colnum (0..$#{$table->[$rownum]}) {
$res .= sprintf("%-".$widths[$colnum]."s|", 
$table->[$rownum][$colnum]);

}
$res .= "\n";
}
$res;
}

# tiny table (1x1)
#my $table = [["row1.1"]];

# small table (3x5)
my $table = [
["row1.1", "row1.2", "row1.3"],
["row2.1", "row2.2  ", "row2.3"],
["row3.1", "row3.2", "row3.3  "],
["row4.1", "row4.2", "row4.3"],
["row5.1", "row5.2", "row5.3"],
];

print fmttable($table);

for (1..1_000_000) {
fmttable($table);
}
---END asciitable.pl---

While I am quite impressed with how easy I was able to write D, I 
am not so impressed with the performance. Using rdmd (build 
20151103), the D program runs in 17.127s while the Perl version 
runs in 11.391s (so the D version is quite a bit *slower* than 
Perl's). While using gdc (Debian 4.9.2-10), I am able to run it 
in 3.988s (only about 3x faster than Perl's version).


I understand that string processing (concatenation, allocation) 
is quite optimized in Perl, I was wondering if the D version 
could still be sped up significantly?


Re: OSX Foundation framework D binding

2015-11-11 Thread Vadim Lopatin via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 09:29:47 UTC, Daniel Kozak 
wrote:

V Wed, 11 Nov 2015 06:17:00 +
Vadim Lopatin via Digitalmars-d-learn
 napsáno:


Hello,

I'm working on native Cocoa backend for DlangUI GUI library 
under

OSX.
Is there any ready to use bindings for easy accessing Cocoa 
API?

Probably, there is some HelloWorld program which creates window
and draws something?


Best regards,
  Vadim


I find only this one: 
http://code.dlang.org/packages/derelict-cocoa


Me too.
It looks promising.
I'll try to use it.



Re: my first D program (and benchmark against perl)

2015-11-11 Thread Andrea Fontana via Digitalmars-d-learn

On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote:
While I am quite impressed with how easy I was able to write D, 
I am not so impressed with the performance. Using rdmd (build 
20151103), the D program runs in 17.127s while the Perl version 
runs in 11.391s (so the D version is quite a bit *slower* than 
Perl's). While using gdc (Debian 4.9.2-10), I am able to run it 
in 3.988s (only about 3x faster than Perl's version).


I understand that string processing (concatenation, allocation) 
is quite optimized in Perl, I was wondering if the D version 
could still be sped up significantly?


Did you try rdmd -O -noboundscheck -release yourscript.d ?

You should try using appender!string rather than concatenate 
(http://dlang.org/phobos/std_array.html#.Appender) using capacity 
(http://dlang.org/phobos/std_array.html#.Appender.capacity) to 
improve performace.


You should also switch from for to foreach.

Andrea



Re: my first D program (and benchmark against perl)

2015-11-11 Thread Rikki Cattermole via Digitalmars-d-learn

On 12/11/15 3:20 AM, Rikki Cattermole wrote:

On 12/11/15 2:31 AM, perlancar wrote:

Here's my first non-hello-world D program, which is a direct translation
from the Perl version. I was trying to get a feel about D's performance:

---BEGIN asciitable.d---
import std.string;
import std.stdio;

string fmttable(ref string[][] table) {
 string res = "";

 // column widths
 int[] widths;

 if (table.length == 0) return "";

 widths.length = table[0].length;

 for (int colnum=0; colnum < table[0].length; colnum++) {
 int width = 0;
 for (int rownum=0; rownum < table.length; rownum++) {
 if (table[rownum][colnum].length > width)
 width = cast(int) table[rownum][colnum].length;
 }
 widths[colnum] = width;
 }

 for (int rownum=0; rownum < table.length; rownum++) {
 res ~= "|";
 for (int colnum=0; colnum < table[rownum].length; colnum++) {
 res ~= leftJustify(table[rownum][colnum], widths[colnum]);
 res ~= "|";
 }
 res ~= "\n";
 }

 return res;
}

void main() {
 // tiny table (1x1)
 /*
 string[][] table = [
 ["row1.1"],
 ];
 */

 // small table (3x5)
 string[][] table = [
 ["row1.1", "row1.2  ", "row1.3"],
 ["row2.1", "row2.2", "row2.3"],
 ["row3.1", "row3.2", "row3.3  "],
 ["row4.1", "row4.2", "row4.3"],
 ["row5.1", "row5.2", "row5.3"],
 ];

 write(fmttable(table));
 for (int i=0; i < 100; i++) {
 fmttable(table);
 }
}
---END asciitable.d---

Perl version:

---BEGIN asciitable.pl---
#!/usr/bin/env perl

sub fmttable {
 my $table = shift;

 my $res = "";

 # column widths
 my @widths;

 if (@$table == 0) { return "" }

 for my $colnum (0 .. $#{$table->[0]}) {
 my $width = 0;
 for my $rownum (0 .. $#{$table}) {
 if (length($table->[$rownum][$colnum]) > $width) {
 $width = length($table->[$rownum][$colnum]);
 }
 }
 $widths[$colnum] = $width;
 }

 for my $rownum (0..$#{$table}) {
 $res .= "|";
 for my $colnum (0..$#{$table->[$rownum]}) {
 $res .= sprintf("%-".$widths[$colnum]."s|",
$table->[$rownum][$colnum]);
 }
 $res .= "\n";
 }
 $res;
}

# tiny table (1x1)
#my $table = [["row1.1"]];

# small table (3x5)
my $table = [
 ["row1.1", "row1.2", "row1.3"],
 ["row2.1", "row2.2  ", "row2.3"],
 ["row3.1", "row3.2", "row3.3  "],
 ["row4.1", "row4.2", "row4.3"],
 ["row5.1", "row5.2", "row5.3"],
];

print fmttable($table);

for (1..1_000_000) {
 fmttable($table);
}
---END asciitable.pl---

While I am quite impressed with how easy I was able to write D, I am not
so impressed with the performance. Using rdmd (build 20151103), the D
program runs in 17.127s while the Perl version runs in 11.391s (so the D
version is quite a bit *slower* than Perl's). While using gdc (Debian
4.9.2-10), I am able to run it in 3.988s (only about 3x faster than
Perl's version).

I understand that string processing (concatenation, allocation) is quite
optimized in Perl, I was wondering if the D version could still be sped
up significantly?


I turned it into mostly using large allocations, instead of small ones.
Although I'd recommend using Appender instead of my custom functions for
this.

Oh and for me, I got it at 2 secs, 513 ms, 397 μs, and 5 hnsecs.
Unoptimized, using dmd.
When release mode is enabled on dmd: 1 sec, 550 ms, 838 μs, and 9
hnsecs. So significant improvement even with dmds awful optimizer.

import std.string;
import std.stdio;

static string SPACES = "   ";

string fmttable(string[][] table) {
 char[] res;

 // column widths
 int[] widths;
 size_t totalSize;

 if (table.length == 0) return "";

 widths.length = table[0].length;

 foreach(colnum; 0 .. table[0].length) {
 int width = 0;
 size_t count;

 foreach(rownum; 0 .. table.length) {
 if (table[rownum][colnum].length > width)
 width = cast(int) table[rownum][colnum].length;
 count += table[rownum].length;
 }

 totalSize += ((width + 1) * count) + 2;
 widths[colnum] = width;
 }

 char[] buffer = new char[](totalSize);

 void assignText(string toAdd) {
 if (res.length < buffer.length - toAdd.length) {
 } else {
 buffer.length += toAdd.length;
 }

 res = buffer[0 .. res.length + toAdd.length];
 res[$-toAdd.length .. $] = toAdd[];
 }


 foreach(rownum; 0 .. table.length) {
 assignText("|");
 foreach(colnum; 0 .. table[rownum].length) {
 assignText(SPACES[0 .. widths[colnum] -
table[rownum][colnum].length]);
 assignText(table[rownum][colnum]);
 assignText("|");
 }
 assignText("\n");
 }

Re: why does this error out?

2015-11-11 Thread lobo via Digitalmars-d-learn

On Thursday, 12 November 2015 at 02:36:23 UTC, lobo wrote:
On Tuesday, 10 November 2015 at 14:25:19 UTC, steven kladitis 
wrote:

On Tuesday, 10 November 2015 at 05:14:29 UTC, lobo wrote:

[...]



with dmd 2.069
I always get
--> [1
and then the error no matter what I canhe that line to.


Hmm, that's different to what I get. On linux 64 bit with dmd 
2.069 I get this:


[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 
40, 42]
core.exception.AssertError@std/range/package.d(4691): Assertion 
failure



Note the assertion is same as before; hardas has no values > 
252 so filter!(h => h < 1000) results in an empty range.


bye,
lobo


that should be filter!(h => h > 1000)


Re: why does this error out?

2015-11-11 Thread lobo via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 14:25:19 UTC, steven kladitis 
wrote:

On Tuesday, 10 November 2015 at 05:14:29 UTC, lobo wrote:

On Tuesday, 10 November 2015 at 04:34:22 UTC, Cauterite wrote:

Here's the output I get (DMD v2.068.2):

[1, 3, 10, 12, 21, 30, 100, 102, 111, 120, 201, 210]
core.exception.AssertError@std\range\package.d(4603): 
Assertion failure


iota.front() is complaining the range is empty from this line.

harshads.filter!(h => h > 1000).front.writeln;

your hardas has no values > 1000 so the filter is empty. 
hardwas was seeded with iota(1,256), so the maximum value will 
be 252.


bye,
lobo



with dmd 2.069
I always get
--> [1
and then the error no matter what I canhe that line to.


Hmm, that's different to what I get. On linux 64 bit with dmd 
2.069 I get this:


[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 
40, 42]
core.exception.AssertError@std/range/package.d(4691): Assertion 
failure



Note the assertion is same as before; hardas has no values > 252 
so filter!(h => h < 1000) results in an empty range.


bye,
lobo




Re: Linker error from dub?

2015-11-11 Thread Stiff via Digitalmars-d-learn

On Thursday, 12 November 2015 at 05:17:58 UTC, BBasile wrote:

On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote:

Possibly a dumb question, I'm not sure.
[...]
undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


Any suggestions? I do have a blas library installed, but the 
cblas D project isn't docced very well, so I don't know if 
there's a compatibility issue.


Thanks!


You should add something to tell DUB to link your program with 
the openblas static library since cblas is just a binding. For 
example this should work:


{
 "name" : "tcbuilder",
 "description" : "Thalamocortical network parameter 
parser",

 "dependencies" : {
 "cblas": "~>0.1.0",
 "scid": "~>0.3.0"
 },
 "libs" : [
   "openblas"
 ],
}

And install the 'openblas-devel' package of course. Btw I've 
verified with a simple program and it works, although it just 
included cblas, not scid.


Does the libs element from cblas' dub.json not handle that 
library linkage? I suppose I should also mention that it was 
compiling fine before I actually used a function from the library 
in my code.


If it does work with OpenBLAS, that would seem to suggest that 
"Works with OpenBLAS and others" is a bit more restrictive than 
it sounds...


win32 from master: unicode functions by default?

2015-11-11 Thread Andre via Digitalmars-d-learn

Hi,

by using the win32 library from master, the functions aliases
to the ansi windows functions (...A) instead of the unicode 
functions (...W).
Is there a way to control this behavior beside using the explicit 
function

names (A/W)?

Kind regards
André


Compiler doesn't complain with multiple definitions

2015-11-11 Thread ric maicle via Digitalmars-d-learn

I was playing with __traits and tried the code below.
Shouldn't the compiler emit a warning that I'm defining isPOD
multiple times and/or I'm defining something that is built-in
like isPOD?

// DMD64 D Compiler v2.069
import std.stdio;

struct isPOD {
bool status = false;
}

int main()
{
byte isPOD = 0;
writeln(isPOD);
writeln(__traits(isPOD, typeof(isPOD)));
return 0;
}


Re: OSX Foundation framework D binding

2015-11-11 Thread Vadim Lopatin via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 16:04:44 UTC, Jacob Carlborg 
wrote:

On 2015-11-11 17:02, Jacob Carlborg wrote:

I would recommend creating new bindings which use the new 
Objective-C
interoperability feature that was added in the latest release 
(2.069.0).


You could use DStep [1] to generate the bindings. It will 
generate bindings which are not completely compatible with what 
the compiler can handle. But it can be used as a base.


[1] https://github.com/jacob-carlborg/dstep


Aren't there any ready set of translated and post-processed files 
for main OSX foundations in some repository? Could you point at 
it?




Re: Linker error from dub?

2015-11-11 Thread BBasile via Digitalmars-d-learn

On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote:

Possibly a dumb question, I'm not sure.
[...]
undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


Any suggestions? I do have a blas library installed, but the 
cblas D project isn't docced very well, so I don't know if 
there's a compatibility issue.


Thanks!


You should add something to tell DUB to link your program with 
the openblas static library since cblas is just a binding. For 
example this should work:


{
 "name" : "tcbuilder",
 "description" : "Thalamocortical network parameter 
parser",

 "dependencies" : {
 "cblas": "~>0.1.0",
 "scid": "~>0.3.0"
 },
 "libs" : [
   "openblas"
 ],
}

And install the 'openblas-devel' package of course. Btw I've 
verified with a simple program and it works, although it just 
included cblas, not scid.


Linker error from dub?

2015-11-11 Thread Stiff via Digitalmars-d-learn

Possibly a dumb question, I'm not sure.

I'm trying to use the cblas headers from DLangScience, and 
getting linker errors out of dub when trying to build my project. 
I'm only trying to call gemm(), so it should be pretty 
straightforward.


Anyway, my dub.json:

{
"name" : "tcbuilder",
"description" : "Thalamocortical network parameter 
parser",

"dependencies" : {
"cblas": "~>0.1.0",
"scid": "~>0.3.0"
}
}

and the output from `dub build`:

Performing "debug" build using dmd for x86_64.
cblas 0.1.0: target for configuration "library" is up to date.
scid 0.3.0: target for configuration "library" is up to date.
tcbuilder ~master: building configuration "application"...
blasint = int
Linking...
.dub/build/application-debug-linux.posix-x86_64-dmd_2069-8ECAC666F541E423658AC8BE09AB7073/tcbuilder.o:
 In function 
`_D3app18__T10matrixMultTdZ10matrixMultFNbxS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewxS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixViewZS4scid6matrix68__T10MatrixViewTdVE4scid6matrix7Storagei0VE4scid6matrix8Trianglei85Z10MatrixView':
/home/stiff/Projects/TCBuilder/source/app.d:248: undefined 
reference to `cblas_dgemm'

collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


Any suggestions? I do have a blas library installed, but the 
cblas D project isn't docced very well, so I don't know if 
there's a compatibility issue.


Thanks!


Re: win32 from master: unicode functions by default?

2015-11-11 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 12 November 2015 at 04:58:42 UTC, Andre wrote:

Hi,

by using the win32 library from master, the functions aliases
to the ansi windows functions (...A) instead of the unicode 
functions (...W).
Is there a way to control this behavior beside using the 
explicit function

names (A/W)?

Kind regards
André


version=Unicode on the compiler command line.


Re: OSX Foundation framework D binding

2015-11-11 Thread Vadim Lopatin via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 16:04:44 UTC, Jacob Carlborg 
wrote:

On 2015-11-11 17:02, Jacob Carlborg wrote:

I would recommend creating new bindings which use the new 
Objective-C
interoperability feature that was added in the latest release 
(2.069.0).


You could use DStep [1] to generate the bindings. It will 
generate bindings which are not completely compatible with what 
the compiler can handle. But it can be used as a base.


[1] https://github.com/jacob-carlborg/dstep


That's interesting. Let me try.
Thank you!



Re: win32 from master: unicode functions by default?

2015-11-11 Thread Andre via Digitalmars-d-learn

On Thursday, 12 November 2015 at 05:08:25 UTC, Mike Parker wrote:

On Thursday, 12 November 2015 at 04:58:42 UTC, Andre wrote:

Hi,

by using the win32 library from master, the functions aliases
to the ansi windows functions (...A) instead of the unicode 
functions (...W).
Is there a way to control this behavior beside using the 
explicit function

names (A/W)?

Kind regards
André


version=Unicode on the compiler command line.


perfect. Thanks a lot.

Kind regards
André


Re: Linker error from dub?

2015-11-11 Thread BBasile via Digitalmars-d-learn

On Thursday, 12 November 2015 at 05:44:37 UTC, Stiff wrote:

On Thursday, 12 November 2015 at 05:17:58 UTC, BBasile wrote:

On Thursday, 12 November 2015 at 02:02:56 UTC, Stiff wrote:

Possibly a dumb question, I'm not sure.
[...]
undefined reference to `cblas_dgemm'
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


Any suggestions? I do have a blas library installed, but the 
cblas D project isn't docced very well, so I don't know if 
there's a compatibility issue.


Thanks!


You should add something to tell DUB to link your program with 
the openblas static library since cblas is just a binding. For 
example this should work:


{
 "name" : "tcbuilder",
 "description" : "Thalamocortical network parameter 
parser",

 "dependencies" : {
 "cblas": "~>0.1.0",
 "scid": "~>0.3.0"
 },
 "libs" : [
   "openblas"
 ],
}

And install the 'openblas-devel' package of course. Btw I've 
verified with a simple program and it works, although it just 
included cblas, not scid.


Does the libs element from cblas' dub.json not handle that 
library linkage?


If it does work with OpenBLAS, that would seem to suggest that 
"Works with OpenBLAS and others" is a bit more restrictive than 
it sounds...


On my system it only worked with OpenBlas...so now I don't know 
(its quite probable that the other blas libs work..) but what's 
sure is that you have to fill the libs[] to compile the 
application because the blas C library won't be pre-linked when 
compiling cblas. I mean that even if it's done in cblas D binding 
you'll have to add it anyway in the final project.


I suppose I should also mention that it was compiling fine 
before I actually used a function from the library in my code.


It worked fine because it was not used, not parsed, not linked. 
Maybe just the functions declarations was parsed to solve the 
symbols in the program, but since none was used the 'import 
blas.blas' was eliminated or something like that. This could be 
explained better by someone who knows well DMD architecture...


Re: Linker error from dub?

2015-11-11 Thread BBasile via Digitalmars-d-learn

On Thursday, 12 November 2015 at 06:03:49 UTC, BBasile wrote:
It worked fine because it was not used, not parsed, not linked. 
Maybe just the functions declarations was parsed to solve the 
symbols in the program, but since none was used the 'import 
blas.blas' was eliminated or something like that. This could be 
explained better by someone who knows well DMD architecture...


I think that you would get an error with just the 'import 
blas.blas' and building the debug config.


I've spotted a std.expirmental.allocators bug this summer that 
was revealed in by a similar scheme: extern declaration not used 
in release mode, but in debug mode the symbols, even if not used, 
were not eliminated and the compiler complained about undefined 
symbol this & that !





Re: OSX Foundation framework D binding

2015-11-11 Thread Jeremy DeHaan via Digitalmars-d-learn
On Thursday, 12 November 2015 at 05:50:09 UTC, Vadim Lopatin 
wrote:
On Wednesday, 11 November 2015 at 16:04:44 UTC, Jacob Carlborg 
wrote:

On 2015-11-11 17:02, Jacob Carlborg wrote:

I would recommend creating new bindings which use the new 
Objective-C
interoperability feature that was added in the latest release 
(2.069.0).


You could use DStep [1] to generate the bindings. It will 
generate bindings which are not completely compatible with 
what the compiler can handle. But it can be used as a base.


[1] https://github.com/jacob-carlborg/dstep


Aren't there any ready set of translated and post-processed 
files for main OSX foundations in some repository? Could you 
point at it?


That's doubtful. OS X interoperability is pretty new. If anyone 
has done any bindings like what you want I don't think they've 
announced it.


How to fix "Error symbol '.....' is already defined"

2015-11-11 Thread Vincent R via Digitalmars-d-learn

Hi,

I have a small project and I would like to use D to build it.
I am working on Windows and I have already generated a gdc 
compiler through msys2/mingw64 and now I would like to compile 
the old.unmaintained wxWidgets wrapper called wxd.
I have forked the project here: https://github.com/vrichomme/wxd 
and tried to fix the easiest errors but now there is still an 
error about symbol already defined:


http://dpaste.dzfl.pl/c925e7f888e8

By looking at 
https://github.com/vrichomme/wxd/blob/master/src/wx/TreeCtrl.d do 
you know why I get this error ?
When using dmd I still have the warning but the linker ignores 
it, however since my project is for a raspberrypi I prefer to use 
the same toolchain on destop(gdc).


Thanks