[Issue 15032] [REG2.068.1] coverage output is discreted around the calls to map(), canFind(), filter()

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15032

--- Comment #2 from j...@red.email.ne.jp ---
(In reply to jiki from comment #1)
> [command]
> dmd -cov mod_a.d mod_b.d

Oops, please run 'mod_a' after the compile finished, of course.

--


Re: Is D suitable for my latest project?

2015-09-09 Thread Atila Neves via Digitalmars-d-learn

On Sunday, 6 September 2015 at 14:36:53 UTC, chris stevens wrote:

Hi All,

I am considering using D for my latest project and there are a 
few features I would like and am not entirely sure at this 
point whether D has them. They are:


- dynamic creation of classes/structs at runtime (think I can 
emulate this with variants/dynamic)


At runtime, no. However... if it doesn't actually need to be 
runtime and is in the code itself you can have code be generated 
at compile time.



- dynamic compilation of code files at runtime


Only by running a compiler. But as above, if it doesn't strictly 
have to be at runtime and everything is specified in the source 
files, you can compute strings at compile-time and mix them in to 
generate code.



- some basic code creation tools


mixin, template mixin, CTFE.


Are the above possible?


It really depends on what you want to do. A lot of the dynamic 
code generation that goes on is done at runtime because that's 
what other languages support. In my experience a lot of those 
use-cases can be done at compile-time in D. A famous example is 
compile-time regular expressions. Unless you're writing a tool 
similar to grep, all regexes in your program are known at 
compile-time. They don't _need_ to be parsed/interpreted/compiled 
at run-time, that's just what every other language that isn't D 
does.


So, if your use-case depends on information from the file-system, 
user interaction, networking, etc. then your only choice is to 
generate text files with D code and compile it. If, on the other 
hand, it's all defined by the code you write, then D has 
excellent compile-time code generation tools at your disposal.


Atila


Re: Compile all-of-dub?

2015-09-09 Thread Rikki Cattermole via Digitalmars-d

On 09/09/15 8:26 PM, qznc wrote:

The Rust people have this Crater [0,1] tool, which essentially builds
all Rust libraries with two compiler versions and compares for regressions.

Since D has a central library repository as well, it would make sense to
do this broad testing as well. We don't have nightly builds (or do we?),
but release candidates. Is something like this already done?

For example, dfmt broke between 2.068 and 2.068.1 [2]. It is easily
possible to detect regressions like this automatically. The biggest
problem is probably that someone has to provide servers or pay for AWS
instances.

[0] https://internals.rust-lang.org/t/crater-plans/2206
[1] https://github.com/brson/taskcluster-crater
[2] https://github.com/Hackerpilot/dfmt/pull/184#issuecomment-138713802


Or use travis-ci.


Re: What is "FilterResult" type?

2015-09-09 Thread Atila Neves via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar 
wrote:
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis 
wrote:

If you're returning a range, you should be returning auto.


@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`.  However there are times when 
you need to pass the `auto` value to another function and the 
receiving function needs to know the type of its input 
arguments.


No, it doesn't. It needs to know what the compile-time interface 
is, i.e. what it can do with that type. If the type in question 
happens to be an InputRange, then the consumer function would be:


void func(R)(R range) if(isInputRange!R) { ... }

instead of using a concrete type like this:

void func(MyType range) { ... }

That way you can change range types and `func` doesn't care.

Atila



Re: Why 1f.iota(100f).array returns double[] not float[]?

2015-09-09 Thread Ali Çehreli via Digitalmars-d-learn

On 09/08/2015 06:37 AM, Steven Schveighoffer wrote:

I think this warrants a bug report, iota with only floats as parameters
should result in floats.


https://issues.dlang.org/show_bug.cgi?id=15033

Ali




Re: Behavior of opEquals

2015-09-09 Thread Jacob Carlborg via Digitalmars-d

On 2015-09-08 18:40, Jonathan M Davis wrote:


Well, it might be a bit annoying, but it's simply a matter of adjusting
your code to call opEquals explicitly when trying to call the base
version


Given that fact that I found this problem in std.xml.Document shows 
either that this is not so easy to remember or that std.xml is basically 
never used and it doesn't have a test for this. That it doesn't have a 
test is true regardless.



,whereas without the free function opEquals, you have subtle
correctness problems. For instance, if you have base == derived and
derived == base, you'll get the same result for both for D, whereas the
equivalent Java or C# could would likely not, because the free function
opEquals checks both lhs.opEquals(rhs) and rhs.OpEquals(lhs) whether you
did base == derived or derived == base.

So, while what we have is by no means perfect, I think that it is an
improvement over what Java and C# did.


It should be possible for the compiler to see that it's a super call and 
generate a call to opSuperEquals (or similar) instead, which would make 
a non-virtual call when calling opEquals on the instance.


--
/Jacob Carlborg


Re: Announcing dplug, a toolkit for making audio plugins with D

2015-09-09 Thread ponce via Digitalmars-d-announce

On Saturday, 13 June 2015 at 14:18:31 UTC, ponce wrote:

dplug is a library for audio plugin development.

https://github.com/p0nce/dplug
http://code.dlang.org/packages/dplug

It's aim is to be a lean alternative to JUCE and IPlug, the 
most used C++ libraries in this space.


It is currently less useful since supporting only VST 2.x on 
Windows. The plan is to gradually add more formats and OS 
support (VST Mac and AudioUnit should be first).


A bit of update about dplug:

- Mac VST support for 64-bit is there, with the exception of a 
weird scanning bug in Reaper and Studio One (#62). The interface 
use Cocoa through DerelictCocoa. 32-bit plugins would require a 
Carbon UI and I don't think it's clever to focus time on it.


  I should do AudioUnit next but it requires inheriting from C++ 
classes so it's not sure it can work.


- The GUI now use a simplified physically-based model for 
rendering, a bit over-the-top but always nice to use.


- Linux windowing is started, but stalled

A big surprise was that DMD can also make plugins on OS X, 
despite not supporting shared libraries theorically. I don't know 
why it works.


Please note however that dplug does not respect SemVer yet and 
stuff will break without notice or insurance.


Re: DCD: Autocomplete without the IDE

2015-09-09 Thread Brian Schott via Digitalmars-d-announce
On Wednesday, 9 September 2015 at 07:04:27 UTC, Ludovit Lucenic 
wrote:
Hello yaz, how far did you get with Sublime Text autocomplete 
support for D?


https://github.com/yazd/DKit/

There's a link to this on DCD's wiki.



[Issue 14877] std.net.curl needs PATCH http method

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14877

badlink  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||andrea.9...@gmail.com
 Resolution|FIXED   |---

--- Comment #5 from badlink  ---
The current version in phobos of std.net.curl.patch does not upload any data in
the http request.

Small testcase: http://pastebin.com/UujEqh4K
Expected: the data field in the response should not be empty

-

Workaround: change the switch case in std.net.curl.HTTP.perform:

[...]
case Method.patch:
p.curl.set(CurlOption.customrequest, "PATCH");
p.curl.set(CurlOption.upload, 1L); // add this line
opt = CurlOption.customrequest;
break;
[...]

Note: probably this workaround does not leave a clean state.

--


Re: What's the "right" way to do openmp-style parallelism?

2015-09-09 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-09-08 at 07:33 +, Dominikus Dittes Scherkl via
Digitalmars-d-learn wrote:
> On Tuesday, 8 September 2015 at 05:50:30 UTC, Russel Winder wrote:
> > void main() {
> >   immutable imax = 10;
> >   immutable jmax = 10;
> >   float[imax][jmax] x;
> >   foreach(int j; 1..jmax){
> > foreach(int i, ref item; parallel(x[j-1])){
> >   x[j][i] = complicatedFunction(i, item);
> > }
> >   }
> > }
> > 
> > (though sadly, this doesn't compile for a reason I can't fathom 
> > instantly)
> Hmm. Shouldn't you instead parallel the outer loop?

Can't do that because it is a pipeline: the current computation is
input to the next one. As far as I can tell there is no way the code as
presented can be parallelized in the general case. If there were some
guarantees on complicatedFunction, then it is a different game.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



signature.asc
Description: This is a digitally signed message part


Re: class destruction

2015-09-09 Thread ponce via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Hi. I'm playing around with D for a while and I would like to 
switch. But here is one thing, I need an answer for. In the 
Docs is mentioned that it is not sure that the DTor of a class 
is called. But what if I have struct, which holds a C Handle 
which is destroyed as soon as the struct gets destroyed (more 
or less like a unique pointer) and I stick this struct into a 
class (because I strongly need polymorphism)?


Then you have to make sure the class destruction happens and not 
rely on the GC.



Can I be sure that the Handle is destroyed as soon as the class 
is destroyed?


I think that yes, struct members are destroyed. But you need to 
make sure the class is destroyed.






If so there are only two ways that come to mind:
1.  the class holds only a pointer to the struct, which is 
unsafe since I must guarantee that the struct lives as long as 
the class
2. the class gets a close/finalize/destroy method (or is called 
with the built in destroy method), which is a absolute nogo, 
because it is absolutly sure that this can be forgotten. 
Besides, we live in 2015 and that is not C where I have to 
clean my code manually, so this option would be ridiculous :D


I'm gratefull for any answers and ideas.


I'm using the manual method after much hair-pulling: 
http://p0nce.github.io/d-idioms/#GC-proof-resource-class


It absolutely is worse than the C++ situation, however with the 
above pattern leaks will be reported by the GC, which is a nice 
consolation prize.



Alternatively, stick your class in Unique! / Refcounted! / scoped!






Re: A collection of DIPs

2015-09-09 Thread NX via Digitalmars-d
On Wednesday, 9 September 2015 at 06:13:59 UTC, Dominikus Dittes 
Scherkl wrote:

On Tuesday, 8 September 2015 at 17:07:50 UTC, NX wrote:
And, can somebody show me a working example code of how to 
solve that friend class problem without some horrible hacktic 
way and agressive template/mixin stuff ? (I doubt it can 
solved via templates but anyway...)

Why would you ever need "friend"?
All functions have access to private members if they are 
declared within the same module, so there "friend" is not 
needed. And if you need access from outside the module, why do 
you declare them "private"?


IMHO "friend" is a misconception, that is only there to 
compensate for the lack of modules in C++.


Woah! I didn't know about private members are visible in it's 
module, but to me it feels much cleaner if it was achieved by 
something similar to what I suggested... Isn't it?

never mind...


Re: DCD: Autocomplete without the IDE

2015-09-09 Thread Ludovit Lucenic via Digitalmars-d-announce

On Tuesday, 3 September 2013 at 05:50:58 UTC, yaz wrote:
On Tuesday, 3 September 2013 at 04:54:24 UTC, Rory McGuire 
wrote:
Do you ever use Sublime Text 2/3? Any plans to support 
integration with it?


Seriously awesome work. I've wanted to make this since I saw 
gocode,  but I

couldn't figure out how to get at the ast in dmd.
On 3 Sep 2013 00:25, "Brian Schott"  
wrote:




I'm currently experimenting a bit with Sublime Text and DCD. I 
might hopefully get an alpha quality plugin that just works in 
a week. No promises made.


Hello yaz, how far did you get with Sublime Text autocomplete 
support for D?


Re: RFC: Units of measurement for D (Phobos?)

2015-09-09 Thread via Digitalmars-d

On Tuesday, 12 April 2011 at 16:44:10 UTC, David Nadlinger wrote:
Recently, I have been playing around with a little units of 
measurement system in D. As this topic has already been brought 
up quite a number of times here, I thought I would put my 
implementation up for discussion here.


I would like to move forward with std.experimental.unit(s).

A question that needs to be decided on Before starting this is:

- David's library and quantities use different interal 
representation. Davids 7-dimensional vector of rational integers 
(a la Boost) is hardcoded to represent SI units. biozic's is not 
and uses a tuple of strings and is therefore more flexible. Which 
direction should we choose?


Re: What is "FilterResult" type?

2015-09-09 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar 
wrote:
The only way to make it work is `.array.idup` the output of 
`filter`.  For example:


auto result = reduce!(
  (acc, num) => acc.filter!(
fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
  ).array.idup
)(foobars, nums);

Honestly, I cannot comprehend anything out of this; why I had 
to realise the lazy value and `idup` it for it to become usable 
by `reduce`?

Does this mean that I am simply missing something obvious?


Reduce takes the seed, calls your function, and your function 
returns a new seed.


What is going wrong is that the types aren't the same. That is, 
the type of the seed you supplied - `typeof(foobars)` - isn't the 
type that your function returns - `typeof(acc.filter!...)`.


`array()` fixes that, no idea why you need `idup()` though.

OT: I wonder, is reduce able to call a different templated 
version of reduce?


Re: Is D suitable for my latest project?

2015-09-09 Thread Kagamin via Digitalmars-d-learn

On Tuesday, 8 September 2015 at 20:01:15 UTC, chris stevens wrote:
Thanks for the reply Kagamin, just had a quick look at dparse 
and not sure how I could use it in the way you describe. Any 
examples of this?


As I understand, you wanted to build an AST tree and format it to 
string?


Re: class destruction

2015-09-09 Thread Kagamin via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Besides, we live in 2015 and that is not C where I have to 
clean my code manually, so this option would be ridiculous :D


The difference is that in C you need to manage POD memory too. 
Manual management of non-POD resources is a problem of a smaller 
size, and you can use RAII too.


[Issue 15033] New: Element type of float iota is double

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15033

  Issue ID: 15033
   Summary: Element type of float iota is double
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: acehr...@yahoo.com

The following assert fails (passes with 'double'):

import std.range;

void main()
{
static assert(is (ElementType!(typeof(iota(0f))) == float));
}

There are a couple of recommended solutions in the following thread:

  http://forum.dlang.org/thread/msm14h$2ae$1...@digitalmars.com

Ali

--


Re: A collection of DIPs

2015-09-09 Thread Dominikus Dittes Scherkl via Digitalmars-d

On Tuesday, 8 September 2015 at 17:07:50 UTC, NX wrote:
And, can somebody show me a working example code of how to 
solve that friend class problem without some horrible hacktic 
way and agressive template/mixin stuff ? (I doubt it can solved 
via templates but anyway...)

Why would you ever need "friend"?
All functions have access to private members if they are declared 
within the same module, so there "friend" is not needed. And if 
you need access from outside the module, why do you declare them 
"private"?


IMHO "friend" is a misconception, that is only there to 
compensate for the lack of modules in C++.




Re: A collection of DIPs

2015-09-09 Thread ponce via Digitalmars-d

On Wednesday, 9 September 2015 at 06:48:45 UTC, NX wrote:


Woah! I didn't know about private members are visible in it's 
module, but to me it feels much cleaner if it was achieved by 
something similar to what I suggested... Isn't it?

never mind...


Everything in the same module is friend to everything. That's D 
take on friendship.





Re: Benchmarking suite

2015-09-09 Thread qznc via Digitalmars-d
On Tuesday, 8 September 2015 at 23:20:05 UTC, Ola Fosheim Grøstad 
wrote:

On Tuesday, 8 September 2015 at 21:11:15 UTC, qznc wrote:
Yes. I'm not sure how to structure this whole suite. The 
general goal is "D claims that it can match C/C++ in 
performance, let's have some actual numbers". So far D mostly 
disappoints in terms of performance.


The most interesting thing to test is how they fare with high 
level optimization, not low level optimization. So make sure 
the implementation is similar...


I'm not sure if I understand you correctly. What is "high level" 
and "low level" optimization?


What I want to know is a) how fast is "idiomatic" D code (using 
ranges etc) compared to "idiomatic" C/C++ and b) how do they 
compare if you push performance to the limits (code beauty be 
damned).


For a) you want a similar implementation although C/C++ will most 
certainly always loose in terms of length and convenience.


For b) we don't care. C/C++ is free to use builtins, pragmas, and 
whatnot. If for loops are faster than ranges in D, then we will 
use for loops here.


Re: What is "FilterResult" type?

2015-09-09 Thread cym13 via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar 
wrote:
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis 
wrote:

[...]


@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`.  However there are times when 
you need to pass the `auto` value to another function and the 
receiving function needs to know the type of its input 
arguments.


In other news:
Consider the following piece of code.  *Please note that I am 
aware that the simple problem introduced can be solved in 
several ways which are more efficient.*


immutable struct FooBar {
  int x;
  int y;
}
immutable(FooBar)[] foobars = [
  FooBar(60, 100),
  FooBar(8, 20),
  FooBar(9, 15)
];
int[] nums = [20, 40, 55];

//
// find FooBars which:
//   - x * y is greater than any `num`
//   - x and y are smaller than any `num`
//
auto result = reduce!(
  (acc, num) => acc.filter!(
fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
  )
)(foobars, nums);
//
assert(result[0].x == 9 && result[0].y == 15);

This fails to compile with the following message:

Error: static assert  "Incompatible function/seed/element: 
test.__unittestL40_4.__lambda1/immutable(FooBar)[]/int"

/usr/include/dmd/phobos/std/algorithm/iteration.d(2518):
  instantiated from here: reduceImpl!(false, int[], 
immutable(FooBar)[])

/usr/include/dmd/phobos/std/algorithm/iteration.d(2502):
  instantiated from here: reducePreImpl!(int[], 
immutable(FooBar)[]) test.d(56):instantiated from here: 
reduce!(immutable(FooBar)[], int[])


The only way to make it work is `.array.idup` the output of 
`filter`.  For example:


auto result = reduce!(
  (acc, num) => acc.filter!(
fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
  ).array.idup
)(foobars, nums);

Honestly, I cannot comprehend anything out of this; why I had 
to realise the lazy value and `idup` it for it to become usable 
by `reduce`?

Does this mean that I am simply missing something obvious?


You are using reduce in a weird way here... I find it normal to 
have to use weird internal tricks if you are trying weird things. 
The way I would have written it is:


auto result = foobars.filter!(fb => nums.all!(n => (fb.x * fb.y) 
> n))
 .filter!(fb => nums.all!(n => fb.x < n && 
fb.y < n));


Here you don't have any weird and completely unreadable reduce 
construct and don't have to realize the lazy check as 
std.algorithm.searching.all is lazy too.


Re: What is "FilterResult" type?

2015-09-09 Thread Bahman Movaqar via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 07:59:57 UTC, Sebastiaan Koppe 
wrote:
What is going wrong is that the types aren't the same. That is, 
the type of the seed you supplied - `typeof(foobars)` - isn't 
the type that your function returns - `typeof(acc.filter!...)`.


Alright.  So, `reduce` initial seed is an `array` while the 
output of `filter` is a `FilterResult`.  I suppose it makes sense 
to realise it (`.array`) before passing to the next round.


I was under the impression that `reduce` understands 
`FilterResult` and realises it internally; it doesn't and I was 
wrong.  Though I believe it would have been more intuitive if it 
did.


Thanks for the help.


`array()` fixes that, no idea why you need `idup()` though.


True --`idup` was not required.  My mistake.




Compile all-of-dub?

2015-09-09 Thread qznc via Digitalmars-d
The Rust people have this Crater [0,1] tool, which essentially 
builds all Rust libraries with two compiler versions and compares 
for regressions.


Since D has a central library repository as well, it would make 
sense to do this broad testing as well. We don't have nightly 
builds (or do we?), but release candidates. Is something like 
this already done?


For example, dfmt broke between 2.068 and 2.068.1 [2]. It is 
easily possible to detect regressions like this automatically. 
The biggest problem is probably that someone has to provide 
servers or pay for AWS instances.


[0] https://internals.rust-lang.org/t/crater-plans/2206
[1] https://github.com/brson/taskcluster-crater
[2] 
https://github.com/Hackerpilot/dfmt/pull/184#issuecomment-138713802


Re: Visual Studio Code

2015-09-09 Thread Jacob Carlborg via Digitalmars-d

On 2015-08-03 02:24, bitwise wrote:

Just stumbled upon this:

https://code.visualstudio.com/

I see support for Rust and Go, but no D.

If you download it, there is a little smiley/frowny in the bottom right
corner for feedback/feature requests.

Or just vote here:

http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7763160-support-the-d-programming-language


I noticed there are (at least) two entries for the D programming 
language. The other one is [1].


[1] 
http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/8214915-d


--
/Jacob Carlborg


Re: What is "FilterResult" type?

2015-09-09 Thread Bahman Movaqar via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 18:45:33 UTC, Jonathan M Davis 
wrote:

If you're returning a range, you should be returning auto.


@Jonathan, @cym13 and @Meta
It's reasonable to use `auto`.  However there are times when you 
need to pass the `auto` value to another function and the 
receiving function needs to know the type of its input arguments.


In other news:
Consider the following piece of code.  *Please note that I am 
aware that the simple problem introduced can be solved in several 
ways which are more efficient.*


immutable struct FooBar {
  int x;
  int y;
}
immutable(FooBar)[] foobars = [
  FooBar(60, 100),
  FooBar(8, 20),
  FooBar(9, 15)
];
int[] nums = [20, 40, 55];

//
// find FooBars which:
//   - x * y is greater than any `num`
//   - x and y are smaller than any `num`
//
auto result = reduce!(
  (acc, num) => acc.filter!(
fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
  )
)(foobars, nums);
//
assert(result[0].x == 9 && result[0].y == 15);

This fails to compile with the following message:

Error: static assert  "Incompatible function/seed/element: 
test.__unittestL40_4.__lambda1/immutable(FooBar)[]/int"
/usr/include/dmd/phobos/std/algorithm/iteration.d(2518):  
  instantiated from here: reduceImpl!(false, int[], 
immutable(FooBar)[])
/usr/include/dmd/phobos/std/algorithm/iteration.d(2502):  
  instantiated from here: reducePreImpl!(int[], 
immutable(FooBar)[]) test.d(56):instantiated from here: 
reduce!(immutable(FooBar)[], int[])


The only way to make it work is `.array.idup` the output of 
`filter`.  For example:


auto result = reduce!(
  (acc, num) => acc.filter!(
fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
  ).array.idup
)(foobars, nums);

Honestly, I cannot comprehend anything out of this; why I had to 
realise the lazy value and `idup` it for it to become usable by 
`reduce`?

Does this mean that I am simply missing something obvious?


class destruction

2015-09-09 Thread Q via Digitalmars-d-learn
Hi. I'm playing around with D for a while and I would like to 
switch. But here is one thing, I need an answer for. In the Docs 
is mentioned that it is not sure that the DTor of a class is 
called. But what if I have struct, which holds a C Handle which 
is destroyed as soon as the struct gets destroyed (more or less 
like a unique pointer) and I stick this struct into a class 
(because I strongly need polymorphism)? Can I be sure that the 
Handle is destroyed as soon as the class is destroyed? Or will 
the handle leak?

If so there are only two ways that come to mind:
1.  the class holds only a pointer to the struct, which is unsafe 
since I must guarantee that the struct lives as long as the class
2. the class gets a close/finalize/destroy method (or is called 
with the built in destroy method), which is a absolute nogo, 
because it is absolutly sure that this can be forgotten. Besides, 
we live in 2015 and that is not C where I have to clean my code 
manually, so this option would be ridiculous :D


I'm gratefull for any answers and ideas.


C++ Interop -- Two Questions

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

Given a C++ class that looks like this:

class Foo {
   static void Initialize(const SomeObject&);

   virtual void func1();
}

The documentation at [1] doesn't say anything about how to handle 
static member functions like Initialize, nor do I see anything 
about references. I assume I can declare any reference function 
parameters using D's ref, but I have no idea how to declare 
static methods. My questions:


1) Am I right about ref?

2) Do I need to create a wrapper function in C or C++ for static 
member functions?


[Issue 9891] Ability to modify immutable using default value of ref/out parameter

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9891

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


Re: Is D suitable for my latest project?

2015-09-09 Thread chris stevens via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 08:24:06 UTC, Kagamin wrote:
As I understand, you wanted to build an AST tree and format it 
to string?


Thanks again. So I can build an AST and convert it to full D 
source from that? I think that's what i'm likely going need to do.


Re: C++ Interop -- Two Questions

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

On Wednesday, 9 September 2015 at 09:55:21 UTC, Mike Parker wrote:


The documentation at [1] doesn't say anything about how to


[1] http://dlang.org/cpp_interface.html


Re: Benchmarking suite

2015-09-09 Thread via Digitalmars-d

On Wednesday, 9 September 2015 at 07:59:48 UTC, qznc wrote:
I'm not sure if I understand you correctly. What is "high 
level" and "low level" optimization?


Low level are local optimizations, which basically will be the 
same if you use the same backend (like LLVM). It would just 
measure the programmer's approach and not the compiler.


What I want to know is a) how fast is "idiomatic" D code (using 
ranges etc) compared to "idiomatic" C/C++ and b) how do they 
compare if you push performance to the limits (code beauty be 
damned).


For a) you want a similar implementation although C/C++ will 
most certainly always loose in terms of length and convenience.


For b) we don't care. C/C++ is free to use builtins, pragmas, 
and whatnot. If for loops are faster than ranges in D, then we 
will use for loops here.


The problem with a) is that in C++ there are many libraries and 
you'll have a hard time finding comparable alternatives on both 
sides... People don't stick to the standard libraries in C++.


For b) C++ will be slightly faster because of things like modular 
arithmetics and OpenMP support.


I think the better approach is to write up the same algorithms in 
a high level fashion (using generic templates on both sides) from 
the ground up using the same constructs and measure the ability 
to optimize.


Otherwise you end up comparing apples and oranges in a rather 
subjective manner.




Re: Is D suitable for my latest project?

2015-09-09 Thread chris stevens via Digitalmars-d-learn

On Tuesday, 8 September 2015 at 21:51:03 UTC, wobbles wrote:
"Previously undefined". As far as I know, this is impossible in 
D. Thr compiler has to know how much memory to allocate/request 
and it has to know that at compiletime (else it wouldn't be the 
compiler!)


http://wiki.dlang.org/Dynamic_typing

This is what I saw that made me think that I could. Have had 
another closer look and I do believe it's possible.


Re: What is "FilterResult" type?

2015-09-09 Thread Bahman Movaqar via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 08:29:20 UTC, cym13 wrote:

You are using reduce in a weird way here...


Oh?  Perhaps it was all because of the lame example I used :-)
The real problem I was trying to solve, source of which I just 
pushed[1], was the `select` method on line 130.  Is this 
idiomatic or still weird?



The way I would have written it is:

auto result = foobars.filter!(fb => nums.all!(n => (fb.x * 
fb.y) > n))
 .filter!(fb => nums.all!(n => fb.x < n && 
fb.y < n));


For the lame example I gave, something similar occurred to me at 
first; but then I thought 4 `filter`s (assuming `all` is simply a 
`filter`) might be non-idiomatic as it might incur some 
performance penalty.


Here you don't have any weird and completely unreadable reduce 
construct and don't have to realize the lazy check as 
std.algorithm.searching.all is lazy too.


True.  But is pumping the output of `filter` as the seed into 
`reduce` really considered weird usage!?


[1] 
https://github.com/bahmanm/d-etudes/blob/master/source/e002/models.d


Re: Compile all-of-dub?

2015-09-09 Thread Sebastiaan Koppe via Digitalmars-d

On Wednesday, 9 September 2015 at 08:26:59 UTC, qznc wrote:
The Rust people have this Crater [0,1] tool, which essentially 
builds all Rust libraries with two compiler versions and 
compares for regressions.


Since D has a central library repository as well, it would make 
sense to do this broad testing as well. We don't have nightly 
builds (or do we?), but release candidates. Is something like 
this already done?


I think this is a splendid idea. Limiting to just 
release-candidates allows the instances to be killed in between, 
thus saving costs.


Re: Compile all-of-dub?

2015-09-09 Thread Jacob Carlborg via Digitalmars-d

On 2015-09-09 10:26, qznc wrote:

The Rust people have this Crater [0,1] tool, which essentially builds
all Rust libraries with two compiler versions and compares for regressions.

Since D has a central library repository as well, it would make sense to
do this broad testing as well. We don't have nightly builds (or do we?),
but release candidates. Is something like this already done?

For example, dfmt broke between 2.068 and 2.068.1 [2]. It is easily
possible to detect regressions like this automatically. The biggest
problem is probably that someone has to provide servers or pay for AWS
instances.

[0] https://internals.rust-lang.org/t/crater-plans/2206
[1] https://github.com/brson/taskcluster-crater
[2] https://github.com/Hackerpilot/dfmt/pull/184#issuecomment-138713802


I think it's a great idea. This has been suggested before. The 
objections were that:


* If you do find a problem who should be responsible for figuring out if 
it's a regression or an intended change?


* Not all packages are maintained enough to keep up with all compiler 
changes


--
/Jacob Carlborg


Re: Compile all-of-dub?

2015-09-09 Thread Edwin van Leeuwen via Digitalmars-d
On Wednesday, 9 September 2015 at 08:56:56 UTC, Rikki Cattermole 
wrote:

On 09/09/15 8:26 PM, qznc wrote:
The Rust people have this Crater [0,1] tool, which essentially 
builds
all Rust libraries with two compiler versions and compares for 
regressions.


Since D has a central library repository as well, it would 
make sense to
do this broad testing as well. We don't have nightly builds 
(or do we?),

but release candidates. Is something like this already done?

For example, dfmt broke between 2.068 and 2.068.1 [2]. It is 
easily
possible to detect regressions like this automatically. The 
biggest
problem is probably that someone has to provide servers or pay 
for AWS

instances.


Or use travis-ci.


One problem with relying on travis is that it doesn't rerun tests 
for the libraries when compiler is updated. Crater seems to 
automatically compile/test all libraries whenever there is a 
compiler upgrade. Maybe it could be integrated with the 
autotester?


https://auto-tester.puremagic.com/



Re: A collection of DIPs

2015-09-09 Thread via Digitalmars-d
On Wednesday, 9 September 2015 at 06:13:59 UTC, Dominikus Dittes 
Scherkl wrote:
IMHO "friend" is a misconception, that is only there to 
compensate for the lack of modules in C++.


It can be useful. Say you have a database engine module and an 
ORM module, you might want to give the ORM special privileges to 
certain parts of the database engine, but shield it from the rest 
of the program.




Re: Is D suitable for my latest project?

2015-09-09 Thread chris stevens via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 09:14:30 UTC, Atila Neves wrote:
So, if your use-case depends on information from the 
file-system, user interaction, networking, etc. then your only 
choice is to generate text files with D code and compile it. 
If, on the other hand, it's all defined by the code you write, 
then D has excellent compile-time code generation tools at your 
disposal.


Thanks for the in depth reply. Unfortunately, yes, my use case 
depends on user input so definitions will not be known at 
compiletime. I'm keen to learn D though so I think I'm going to 
try and make it work with dynamically compiling and loading 
libraries.





Re: Is D suitable for my latest project?

2015-09-09 Thread chris stevens via Digitalmars-d-learn

On Tuesday, 8 September 2015 at 21:51:03 UTC, wobbles wrote:
"Previously undefined". As far as I know, this is impossible in 
D. Thr compiler has to know how much memory to allocate/request 
and it has to know that at compiletime (else it wouldn't be the 
compiler!)


There was also this:

http://rosettacode.org/wiki/Add_a_variable_to_a_class_instance_at_runtime#D

That made me think I could emulate the functionality I need.


Re: C++ Interop -- Two Questions

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

On 2015-09-09 11:55, Mike Parker wrote:

Given a C++ class that looks like this:

class Foo {
static void Initialize(const SomeObject&);

virtual void func1();
}

The documentation at [1] doesn't say anything about how to handle static
member functions like Initialize, nor do I see anything about
references. I assume I can declare any reference function parameters
using D's ref, but I have no idea how to declare static methods. My
questions:

1) Am I right about ref?


I would assume so. It's just a pointer under the hood.


2) Do I need to create a wrapper function in C or C++ for static member
functions?


The documentation for the C++ support is very outdated. I recommend to 
give it a try and see what happens :). Alternatively look in the DMD 
test suite and see what you can find, or the DMD source code now when 
it's in D.


--
/Jacob Carlborg


Re: Is D suitable for my latest project?

2015-09-09 Thread Ali Çehreli via Digitalmars-d-learn

On 09/08/2015 12:30 PM, chris stevens wrote:

> create new
> (previously undefined) classes in D at runtime that I could then use
> with Object.factory to create instances of.

SDC is a D compiler as a library but as far as I know, it's not complete 
yet:


  https://github.com/SDC-Developers/SDC

Ali



[Issue 9891] Ability to modify immutable using default value of ref/out parameter

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9891

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6b091dc67a71b82a30ba26d2af73e2d67180740c
fix Issue 9891 - Ability to modify immutable using default value of ref/out
parameter

https://github.com/D-Programming-Language/dmd/commit/065881c6f71ef8e76c882b2ce739fa452b547e8e
Merge pull request #5056 from 9rnsr/fix9891

Issue 9891 - Ability to modify immutable using default value of ref/out
parameter

--


Re: Why 1f.iota(100f).array returns double[] not float[]?

2015-09-09 Thread Nordlöw

On Wednesday, 9 September 2015 at 06:37:17 UTC, Ali Çehreli wrote:

https://issues.dlang.org/show_bug.cgi?id=15033

Ali


https://github.com/D-Programming-Language/phobos/pull/3641


Re: What is "FilterResult" type?

2015-09-09 Thread Bahman Movaqar via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 09:08:28 UTC, Atila Neves wrote:
No, it doesn't. It needs to know what the compile-time 
interface is, i.e. what it can do with that type. If the type 
in question happens to be an InputRange, then the consumer 
function would be:


void func(R)(R range) if(isInputRange!R) { ... }

instead of using a concrete type like this:

void func(MyType range) { ... }

That way you can change range types and `func` doesn't care.


Ah...makes sense.  Thanks.



Re: C++ Interop -- Two Questions

2015-09-09 Thread Kagamin via Digitalmars-d-learn
Static functions are declared with `static` storage class. This 
looks so basic, it's even not documented in language spec, lol.


In D classes are reference types by default.


Re: Compile all-of-dub?

2015-09-09 Thread Rikki Cattermole via Digitalmars-d

On 09/09/15 9:21 PM, Edwin van Leeuwen wrote:

On Wednesday, 9 September 2015 at 08:56:56 UTC, Rikki Cattermole wrote:

On 09/09/15 8:26 PM, qznc wrote:

The Rust people have this Crater [0,1] tool, which essentially builds
all Rust libraries with two compiler versions and compares for
regressions.

Since D has a central library repository as well, it would make sense to
do this broad testing as well. We don't have nightly builds (or do we?),
but release candidates. Is something like this already done?

For example, dfmt broke between 2.068 and 2.068.1 [2]. It is easily
possible to detect regressions like this automatically. The biggest
problem is probably that someone has to provide servers or pay for AWS
instances.


Or use travis-ci.


One problem with relying on travis is that it doesn't rerun tests for
the libraries when compiler is updated. Crater seems to automatically
compile/test all libraries whenever there is a compiler upgrade. Maybe
it could be integrated with the autotester?

https://auto-tester.puremagic.com/


You would need to update the travis configuration file for the new 
compiler. That would trigger a new build.


Where is this problem?



Re: "Programming in D" paper book is available for purchase

2015-09-09 Thread Ali Çehreli via Digitalmars-d-announce

On 08/18/2015 05:57 PM, Ali Çehreli wrote:

> it is up to date with 2.068

  http://ddili.org/ders/d.en/index.html

This information is coming a little late but here are the changes since 
the previous release on December 15:



New chapters:

- Fibers

- Pragmas (moved from elsewhere)

- Operator Precedence

- Andrei Alexandrescu's foreword


New features:

- pragma(inline)

- hasUDA (instead of the earlier hand-coded hasAttribute)

- std.range.generate

- AliasSeq (formerly TypeTuple)

- Attributes like 'pure' of 'auto' functions are inferred

- std.algorithm.each

- .byKeyValue


Additions:

- typeid, TypeInfo, and a discriminated union example

- Constructor qualifiers and type constructors

- The 'with' keyword

- The comma operator

- typeof(this), typeof(super), and typeof(return)

- .funcptr and .ptr of delegates


Edits:

- Mainly by Luís Marques, Steven Schveighoffer, and Andrej Mitrović

- Improved book index

- Improved overall formatting

- Inline (Egyptian) opening brackets throughout (available online and in 
the upcoming IngramSpark edition; not available in the CreateSpace edition)



Ali



[Issue 15030] [REG2.068.1] ICE with recursive delegate, -unittest, and std.range

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15030

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d96a64973467d54a91693f87511da7289d1e1b71
fix Issue 15030 - ICE with recursive delegate, -unittest, and std.range

Refer the detailed explanation in `test/runnable/ice15030.d`.

https://github.com/D-Programming-Language/dmd/commit/ea5d85af7abf0b1e36fd42a8d98fd692a765dea0
Merge pull request #5058 from 9rnsr/fix15030

[REG2.068.1] Issue 15030 - ICE with recursive delegate, -unittest, and
std.range

--


Re: Benchmarking suite

2015-09-09 Thread via Digitalmars-d

On Wednesday, 9 September 2015 at 14:00:07 UTC, qznc wrote:
That is a good idea, if you want to measure compiler 
optimizations. Ideally g++ and gdc should always yield the same 
performance then?


Hopefully, as I understand GCC uses a highlevel IR, but if 
performance is equal that is a pretty strong argument to get 
people to adopt, if the rest of the language is polished.


And you could measure regressions.

Suppose you consider using D with C/C++ as the stable 
alternative. D lures you with its high level features. However, 
you know that you will have to really optimize some hot spots 
sooner or later. Will D impose a penalty on you and C/C++ could 
have provided better performance?


Walter argues that there is no technical reason why D should be 
slower than C/C++. My experience with the benchmarks says, 
there seem to be such penalties. For example, there is no 
__builtin_ia32_cmplepd or __builtin_ia32_movmskpd like gcc has.


Ok, I see your point. You want to measure maximum throughput for 
critical applications that might benefit from language specific 
intrinsics.


Multithreaded applications could probably show some differences 
too, due to TLS/shared...


Maybe some kind of actor based benchmark. Essentially running 
thousands of fibers with lots of intercommunication.




Re: A collection of DIPs

2015-09-09 Thread Brandon Ragland via Digitalmars-d

On Monday, 7 September 2015 at 14:44:05 UTC, nx wrote:

https://github.com/NightmareX1337/DX

Don't kill me, I'm just trying to help...

You can report issues and create pull requests :)


Destroy!


Most of these things I agree with.

CamelCase this_case or that-case doesn't matter to me. It's a 
personal choice and preferences. Technically, you can write all 
of YOUR code in whatever case you like, in just about any 
language (though some languages do not support this-case).


It would be nice to get rid of the __traits. It's not uncommon to 
see an underscore before something (I'm a C guy) but I was hoping 
D made better use of it. Putting two underscores in front of 
things does seem a bit "paranoid". But I digress, once you know 
it, you don't care anymore. You just type it the way it is. 
__traits it is, and will probably always be.


As for the Garbage Collector!

Please somebody save me! D's Garbage Collector is perhaps the 
WORSE garbage collector I have ever seen. It's slow, really slow, 
and stopping the entire world is painful, even in trivial user 
applications. A pause for even half a second or less on the UI 
makes the application looks "chunky" and broken.


Real world time-sensitive issues you say??, D's GC is so bad, it 
cannot be used, ever. D has zero use in anything time sensitive.


"But you can code with the GC when you don't need it" you say? 
Well, I can also code in C and C++ and not have to deal with it 
all, and take advantage of the STL in C++ or a plethora of 
open-libraries in C and still get what I need, without all the 
confusing mess around trying to use arrays or pointers without 
the stupid GC.


Seriously, the fact that the GC has gone un-noticied for so long 
is a HUGE turn off for just about ANY would be C like developer 
to migrate to D, and even for the managed folks from Java and C# 
to migrate to D.


I'm not against Garbage Collectors, but I AM against TERRIBLE 
garbage collectors, of which, D's garbage collector is.


D could SERIOUSLY use a rewrite or three of the garbage collector.

What get's me, is that D is sold as this beautiful evolution of 
C++ with this wonderful GC, but then once you buy in, you realize:


1. Nobody uses the GC because it sucks.
2. The GC sucks hardcore.
3. You can't use those nice GC features, because the GC sucks.

Case closed. SOMEBODY SAVE ME! D's garbage collector is a FAIL, 
and that makes the rest of the language a FAIL until it get's 
fixed.







Re: Benchmarking suite

2015-09-09 Thread qznc via Digitalmars-d
On Wednesday, 9 September 2015 at 09:56:10 UTC, Ola Fosheim 
Grøstad wrote:
I think the better approach is to write up the same algorithms 
in a high level fashion (using generic templates on both sides) 
from the ground up using the same constructs and measure the 
ability to optimize.


That is a good idea, if you want to measure compiler 
optimizations. Ideally g++ and gdc should always yield the same 
performance then?


However, it does answer the wrong question imho.

Suppose you consider using D with C/C++ as the stable 
alternative. D lures you with its high level features. However, 
you know that you will have to really optimize some hot spots 
sooner or later. Will D impose a penalty on you and C/C++ could 
have provided better performance?


Walter argues that there is no technical reason why D should be 
slower than C/C++. My experience with the benchmarks says, there 
seem to be such penalties. For example, there is no 
__builtin_ia32_cmplepd or __builtin_ia32_movmskpd like gcc has.


Re: D could catch this wave: web assembly

2015-09-09 Thread Marco Leise via Digitalmars-d
Am Sat, 20 Jun 2015 15:15:47 + (UTC)
schrieb ketmar :

> On Sat, 20 Jun 2015 14:06:50 +0200, Marco Leise wrote:
> 
> > If you have a perfectly working old notebook with Windows XP on it, I
> > can recommend QtWeb for its low resource usage and modern-ish feature
> > set. It is a little unstable and rough around the edges though:
> > http://www.qtweb.net/
> 
> Qt+WebKit. low resource usage. you must be joking.

No I was serious. I compared it to pretty much every other
complete graphical web browser on XP and it "won" by a big
margin. (I opened 5 different web sites in each browser and
compared their memory use in the task manager).
Remember when tabbed browsing was no option on old notebooks?
Now it is and my preference in terms of closing old tabs is
doing it like a mark and sweep garbage collector - every once
in a while.

-- 
Marco



Re: What is "FilterResult" type?

2015-09-09 Thread cym13 via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 11:30:26 UTC, Bahman Movaqar 
wrote:
For the lame example I gave, something similar occurred to me 
at first; but then I thought 4 `filter`s (assuming `all` is 
simply a `filter`) might be non-idiomatic as it might incur 
some performance penalty.


As those are templates I don't think you'd have any overhead ; I 
may be wrong about that but the whole point of such constructs is 
to allow what Walter poetically called “memory disallocation”.


https://www.youtube.com/watch?v=znjesAXEEqw

True.  But is pumping the output of `filter` as the seed into 
`reduce` really considered weird usage!?


I don't think it is really weird per se, I just can't think of a 
case where there isn't a better way to do it. I find it 
completely unreadable frankly, and I generally avoid reduce when 
I can because it is not UFCS-able. This is only personal opinion 
though.


Re: C++ Interop -- Two Questions

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

On Wednesday, 9 September 2015 at 11:49:33 UTC, Kagamin wrote:
Static functions are declared with `static` storage class. This 
looks so basic, it's even not documented in language spec, lol.




Yes, I get that. But how does that work when you're linking to a 
C++ library and the translation of the C++ class to D is an 
interface? Or is it possible now to link D classes directly with 
C classes?



In D classes are reference types by default.


Yes, of course. I just want to verify that the D ref and C++ ref 
are equivalent.


I realize I can do it myself when I sit down this weekend and 
start exploring it, but I'm hoping someone can point me to a blog 
post, some sample code, or just give me some insights to save 
time.


Re: Compile all-of-dub?

2015-09-09 Thread Jack Stouffer via Digitalmars-d
On Wednesday, 9 September 2015 at 12:02:55 UTC, Jacob Carlborg 
wrote:
I think it's a great idea. This has been suggested before. The 
objections were that:


* If you do find a problem who should be responsible for 
figuring out if it's a regression or an intended change?


* Not all packages are maintained enough to keep up with all 
compiler changes


A good compromise is to whitelist libraries created by language 
contributors, e.g. vibed, cerealed, dfmt, etc.


Re: dpaste web site

2015-09-09 Thread BBasile via Digitalmars-d

On Wednesday, 9 September 2015 at 04:17:13 UTC, nazriel wrote:

On Sunday, 30 August 2015 at 15:05:41 UTC, BBasile wrote:

On Wednesday, 26 August 2015 at 05:54:44 UTC, nazriel wrote:
On Thursday, 20 August 2015 at 20:28:48 UTC, Steven 
Schveighoffer wrote:

[...]


I will work on it.

Should be fixed before weekend.

I will also open source dpaste frontend and backend so such 
problems can be avoided in the future.


Got a little bit behind with D related stuff and auto-updates 
of DMD stopped working for some reason.


That's why we are on 2.065.

Regards,
Damian Ziemba


since mothes 90% of the new content is spam.
http://dpaste.dzfl.pl/pastes?p=8


Ok I've changed algorithm for spam detection
Also tried to remove some of the spam already posted.


There are still some links sent. Either the bot who targets 
DPaste works well or...no i can't believe this actually a human 
being who send this manually ?!


However thx, a lot, i think that the biggest doleance that people 
had was to have an up-to-date compiler.


Re: Compile all-of-dub?

2015-09-09 Thread qznc via Digitalmars-d
On Wednesday, 9 September 2015 at 08:56:56 UTC, Rikki Cattermole 
wrote:

Or use travis-ci.


They have that as well: http://rust-ci.org/


Re: Compile all-of-dub?

2015-09-09 Thread qznc via Digitalmars-d
On Wednesday, 9 September 2015 at 12:02:55 UTC, Jacob Carlborg 
wrote:
I think it's a great idea. This has been suggested before. The 
objections were that:


* If you do find a problem who should be responsible for 
figuring out if it's a regression or an intended change?


It does raise the bar for language changes. Most changes should 
be backwards compatible. For intended changes it forces us to 
come up with a way to automatically detect and ideally fix it 
(dfix?).


In an ideal world, I would imagine it like this: Tester finds a 
package breaks. Package is on Github, so Tester can file an issue 
there. Tester checks out the source from repo, runs dfix, sends 
pull request referencing the issue.


* Not all packages are maintained enough to keep up with all 
compiler changes


Then it would be quite interesting to know about this and provide 
this information at code.dlang.org, like "broken for 2.068.0 and 
above".


Re: Benchmarking suite

2015-09-09 Thread Iain Buclaw via Digitalmars-d
On 9 September 2015 at 16:00, qznc via Digitalmars-d <
digitalmars-d@puremagic.com> wrote:

> On Wednesday, 9 September 2015 at 09:56:10 UTC, Ola Fosheim Grøstad wrote:
>
>> I think the better approach is to write up the same algorithms in a high
>> level fashion (using generic templates on both sides) from the ground up
>> using the same constructs and measure the ability to optimize.
>>
>
> That is a good idea, if you want to measure compiler optimizations.
> Ideally g++ and gdc should always yield the same performance then?
>
> However, it does answer the wrong question imho.
>
> Suppose you consider using D with C/C++ as the stable alternative. D lures
> you with its high level features. However, you know that you will have to
> really optimize some hot spots sooner or later. Will D impose a penalty on
> you and C/C++ could have provided better performance?
>
> Walter argues that there is no technical reason why D should be slower
> than C/C++. My experience with the benchmarks says, there seem to be such
> penalties. For example, there is no __builtin_ia32_cmplepd or
> __builtin_ia32_movmskpd like gcc has.
>

import gcc.builtins;  // OK, cheating. :-)


Re: class destruction

2015-09-09 Thread Q via Digitalmars-d-learn
But if others use my code they must think about finalizing the 
classes? That is very awkward.
I'll take a look at Rust and otherwise I will stick with C++. 
Thanks for you answer. :)


Re: class destruction

2015-09-09 Thread ponce via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 14:36:24 UTC, Q wrote:
But if others use my code they must think about finalizing the 
classes? That is very awkward.


classes, yes but structs, no.

I'll take a look at Rust and otherwise I will stick with C++. 
Thanks for you answer. :)


Well, resource management is only part of the story.


Re: RFC: Units of measurement for D (Phobos?)

2015-09-09 Thread HaraldZealot via Digitalmars-d

On Tuesday, 12 April 2011 at 16:44:10 UTC, David Nadlinger wrote:
Recently, I have been playing around with a little units of 
measurement system in D. As this topic has already been brought 
up quite a number of times here, I thought I would put my 
implementation up for discussion here.


...

Anyway, here is a link to the code: 
https://github.com/klickverbot/phobos/tree/units (std/units.d 
and std/si.d). Also, I put up a build of the DDoc output at 
http://klickverbot.at/code/units/std_units.html resp. 
http://klickverbot.at/code/units/std_si.html.


...

David


One big problem is, that in SI base unit for mass is kilogram not 
gram.


Re: class destruction

2015-09-09 Thread Q via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 15:32:58 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote:

I thought that is not guaranteed, according to the docs?


It is possible that the GC will never actually run, but you can 
force it to if you need it to by calling GC.collect at any time.


Yes, but according to the specs it is not guaranteed that the GC 
calls the DTor if the Object is collected.


Re: Is D suitable for my latest project?

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 10:23:55 UTC, chris stevens 
wrote:

http://wiki.dlang.org/Dynamic_typing

This is what I saw that made me think that I could. Have had 
another closer look and I do believe it's possible.


These are things I wrote, so let me explain how they work: they 
do not attempt to actually run through the D compiler, but 
instead use tagged memory to check it all at runtime.


This is kinda similar to creating a class, but it has no help 
from the compiler and no static type checks.



So, let's say the user wanted to create an object with two 
integers, x and y. Code like the jsvar in the link does it with 
an associative array: var[string]. var is defined as a struct 
with a storage variable for the data, and a variable saying what 
type it is. All operations check that type variable. Then the 
names are indexed through the hash map. This is like how 
javascript engines work.


You could also do it a bit differently by making a type 
definition for the whole object and allocating the memory that 
way.




You can also go with the run the compiler and load a library 
option. There's different pros and cons for each approach.




Here's some example code you might go with the second option: a 
type definition and dynamically allocated memory:


---

struct ObjectHandle {
immutable(ObjectDefinition) type;
ubyte[] data;

ubyte[] getRawDataForField(string field) {
auto info = type.fields[field];
auto raw = data[info.offset .. info.offset + info.ti.tsize];
return raw;
}

string toString() {
string s = type.name ~ "_dynamic(\n";
foreach(fieldName, fieldDefinition; type.fields) {
			s ~= "\t" ~ fieldName ~ ": " ~ 
typeToString(fieldDefinition.ti, getRawDataForField(fieldName));

s ~= "\n";

}
return s ~ ")";
}
}

class ObjectDefinition {
// OffsetTypeInfo is defined in object.d
// http://dlang.org/phobos/object.html#OffsetTypeInfo
//
// These TypeInfo things are D's built-in runtime reflection.
// We're borrowing that information and the types to create our
// own extensions.
OffsetTypeInfo[string] fields;

string name;

this(string name) {
this.name = name;
}

void addField(string type, string name) {
switch(type) {
case "int":
OffsetTypeInfo field;
field.ti = typeid(int);
field.offset = dataSize(); // you might also want to do some 
alignment here...

fields[name] = field;
break;
			// you can add other supported types here. You could even loop 
through a list

// of them at compile time and generate this code btw.
default: assert(0, "unsupported type " ~ type);
}
}

int dataSize() const {
int size = 0;
foreach(k, v; fields)
size += v.ti.tsize;
return size;
}

// this is immutable because you don't want
// the layout to change after you've created it.
//
// So it forces the factory to be called only after
// the definition is set in stone.
ObjectHandle factory() immutable {
		auto data = new ubyte[](this.dataSize()); // dynamically 
allocate space for our object's variables...

foreach(k, field; fields) { // and now initialize them properly
auto i = cast(const(ubyte)[]) field.ti.init();
if(i.length)
data[field.offset .. field.offset + 
field.ti.tsize] = i[];
}
		return ObjectHandle(this, data); // and finally return it, 
along with a reference to this so we can identify the type later


}
}

// Similarly to addField, doing operations on our field need to 
dispatch based on
// type. I'll only show int. Others could be added in the if/else 
chain, or also

// auto-generated by a compile time loop.
string typeToString(const(TypeInfo) t, const(ubyte)[] rawData) {
import std.conv;
if(t == typeid(int)) {
int i = *(cast(int*) rawData.ptr);
return to!string(i);
}

return null;
}



void main() {
auto definition = new ObjectDefinition("MyRuntimeType");
definition.addField("int", "x");
definition.addField("int", "y");

auto finalDefinition = cast(immutable) definition;
	definition = null; // we can't edit it anymore, so nulling out 
the mutable original reference



auto object = finalDefinition.factory();

auto rawData = object.getRawDataForField("x");
rawData[0] = 15; // since I know it is an int, I can do 

Compiling dman with the system D compiler

2015-09-09 Thread Marco Leise via Digitalmars-d
I would like to compile dman with any available D compiler.
Ideally with no network traffic on any system where a D
compiler is available.
Is there a way to do this with the downloadable zip archives
of dlang.org, druntime and Phobos? The background is shipping
the dlang tools as a "build from source" package on Gentoo
Linux. And dman is the only tool with a build process strongly
focused around downloading stuff and using dmd specifically.

-- 
Marco



Re: class destruction

2015-09-09 Thread Q via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 14:57:26 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Can I be sure that the Handle is destroyed as soon as the 
class is destroyed?


It will do that automatically.

Like the others said, you won't be sure when the class is 
destroyed unless you have the user code take ownership of it. 
(This btw is the same as C++, just in C++ the ownership syntax 
is a wee bit shorter.)


C++:

class Foo {
  public:
   Foo() { /* acquire */ }
   ~Foo() { /* destroy */ }
};

void useFoo(Foo* foo) { }

// pretend I did the header separation here

int main() {
   Foo foo;
   useFoo();
   return 0;
}


D:

--
module foo;

class Foo {
   private this() { /* acquire */ }
   ~this() { /* destroy */ }
}

struct OwnedFoo(F) {
F foo;
alias foo this;
~this() {
.destroy(foo);
}

@disable this(this) {}
}

auto create(F, T...)(T t) if(is(F : Foo)) {
return OwnedFoo!F(new F(t));
}
--

--
module main;
import foo;

void useFoo(Foo foo) {}

void main() {
   auto foo = create!Foo();
}
---


The code is a bit longer since the owned pointer in the 
standard library isn't exactly what I wanted, but you could use 
std.typecons.Unique too. (Actually, it does offer a bit more 
safety in reference escaping than mine. But mine is the closest 
to C++ default).



The private constructor means it won't let you bypass the owned 
factory when creating it. A bit extra code in foo means all 
uses of it will be simple like in main.


Just don't store the reference after it is destroyed, just like 
you would need to be careful with in C++. Using the library 
Unique will help you get this right too if you want to learn 
that.


But in C++, classes and structs are value types _and_ 
extendable.There is no pressure to heap allocate a class. Of 
course, if I do that, I use a unique_ptr (shared_ptr is almost 
everytime misplaced).
But since D has a GC and (per default) force to heap allocate a 
class. So IMO the GC should also destroy it, everything else is 
just awkward. I don't want to hack around in a new language. I 
think Rust offers my all I want. But thanks for the explanation.




Re: class destruction

2015-09-09 Thread Q via Digitalmars-d-learn
And sorry if that sounds rude, I'm just in a hurry. I just think 
D is not mature enough for serious stuff. :) That is of course 
only my personal opinion.


Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote:

I thought that is not guaranteed, according to the docs?


It is possible that the GC will never actually run, but you can 
force it to if you need it to by calling GC.collect at any time.


Re: 1st Ever Artificial Consciousness to be Written in D Language

2015-09-09 Thread via Digitalmars-d-announce

On Wednesday, 9 September 2015 at 14:47:40 UTC, burjui wrote:
And then GrandAxe pops up with this revolutionary software, 
claiming that Okeuvo company built an AI. However, that claim 
is not supported by anything and reminds me of the Unlimited 
Detail technology by Euclideon, which was announced in a 
similar manner, promising a revolution in graphics rendering. 
As you can see, it's far from it, despite the fact they were 
given $2 million by the Australian government. It seems like 
this revolution takes a little bit more effort, than was 
anticipated :)
And there's no reason to think Okeuvo's technology is different 
in that sense.


Oh well, I believe Manu is working for Euclideon and would like 
to use D for their renderer if it was possible. I like what their 
tech-demos display, but the storage requirements suggest that it 
is more useful for specialized application domains than 
entertainment for now.


Sometimes it can be important to announce something just in order 
to get yourself focused on it, like a start pistol. Maybe 
GrandAxe has some ideas that will lead to something useful for 
end users even if the mechanisms might be simpler than we expect 
them to be.


He only seems to have announced it here and on reddit, so it 
let's assume he is only excited to get started on his mission and 
isn't conducting search engine optimizations by having back links 
from the forums.




Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote:
Yes, but according to the specs it is not guaranteed that the 
GC calls the DTor if the Object is collected.


Where? This page says pretty plainly:

http://dlang.org/class.html#destructors

"The garbage collector calls the destructor function when the 
object is deleted."


(this is arguably a mistake, dtor and finalizer being the same 
thing have been a problem before, but it does say that)


This sentence: "The garbage collector is not guaranteed to run 
the destructor for all unreferenced objects. " is because the GC 
is conservative and has a few exceptions in what it covers. But 
if you aren't one of those exceptions (data segment, or pinned by 
a false pointer (very rare in 64 bit btw), it will be collected 
and if it is collected, the dtor is run.


Re: class destruction

2015-09-09 Thread Meta via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote:
Yes, but according to the specs it is not guaranteed that the 
GC calls the DTor if the Object is collected.


Note that I believe this is the same as in Java (though not C#, 
interestingly enough). In Java an object's destructor is not 
guaranteed to run.


Re: C++ Interop -- Two Questions

2015-09-09 Thread Kagamin via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 13:17:53 UTC, Mike Parker wrote:
Yes, I get that. But how does that work when you're linking to 
a C++ library and the translation of the C++ class to D is an 
interface? Or is it possible now to link D classes directly 
with C classes?


Classes and templates except for special members (which are 
usually relied upon heavily in C++ code, but maybe your C++ code 
is unusual).


I realize I can do it myself when I sit down this weekend and 
start exploring it, but I'm hoping someone can point me to a 
blog post, some sample code, or just give me some insights to 
save time.


You can see bugzilla issues marked with C++ keyword. The docs 
were deemed unworthy because of skills required to write C++ 
bindings. Maybe because it's still not practical as it doesn't 
support critical C++ idioms like RAII.


Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote:
Can I be sure that the Handle is destroyed as soon as the class 
is destroyed?


It will do that automatically.

Like the others said, you won't be sure when the class is 
destroyed unless you have the user code take ownership of it. 
(This btw is the same as C++, just in C++ the ownership syntax is 
a wee bit shorter.)


C++:

class Foo {
  public:
   Foo() { /* acquire */ }
   ~Foo() { /* destroy */ }
};

void useFoo(Foo* foo) { }

// pretend I did the header separation here

int main() {
   Foo foo;
   useFoo();
   return 0;
}


D:

--
module foo;

class Foo {
   private this() { /* acquire */ }
   ~this() { /* destroy */ }
}

struct OwnedFoo(F) {
F foo;
alias foo this;
~this() {
.destroy(foo);
}

@disable this(this) {}
}

auto create(F, T...)(T t) if(is(F : Foo)) {
return OwnedFoo!F(new F(t));
}
--

--
module main;
import foo;

void useFoo(Foo foo) {}

void main() {
   auto foo = create!Foo();
}
---


The code is a bit longer since the owned pointer in the standard 
library isn't exactly what I wanted, but you could use 
std.typecons.Unique too. (Actually, it does offer a bit more 
safety in reference escaping than mine. But mine is the closest 
to C++ default).



The private constructor means it won't let you bypass the owned 
factory when creating it. A bit extra code in foo means all uses 
of it will be simple like in main.


Just don't store the reference after it is destroyed, just like 
you would need to be careful with in C++. Using the library 
Unique will help you get this right too if you want to learn that.


Re: Benchmarking suite

2015-09-09 Thread Isaac Gouy via Digitalmars-d

On Tuesday, 8 September 2015 at 21:06:26 UTC, qznc wrote:


Afaik the Erlang runtime does not interrupt processes.


Depends what you mean by "processes" :-)

In this comparison it is actually interesting, because D has 
its own bignum implementation in the standard library.


There you go!



On Tuesday, 8 September 2015 at 21:11:15 UTC, qznc wrote:

The general goal is "D claims that it can match C/C++ in 
performance, let's have some actual numbers".


- You're only dealing with 3 programming languages, although more 
than 3 language implementations


- Those programming languages are intended to be used for similar 
tasks.


- You'll correctly be seen as a D language advocate, so your 
presentation needs to show that you accept advice on how to 
improve the C and C++ programs.


- "short idiomatic programs" is difficult because the tradeoff 
between performance and "idiomatic" is so subjective, and you 
will correctly be seen as a D language advocate :-)


   When asked, one of the C++ program contributors to the 
benchmarks game did try to write some "shorter" C++ programs, see:


   
http://benchmarksgame.alioth.debian.org/u64/code-used-time-used-shapes.php#shortest


std.experimental.testing formal review

2015-09-09 Thread Robert burner Schadek via Digitalmars-d-announce

http://forum.dlang.org/post/stbdckpfsysjtppld...@forum.dlang.org


Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 15:10:33 UTC, Q wrote:
But since D has a GC and (per default) force to heap allocate a 
class. So IMO the GC should also destroy it, everything else is 
just awkward.


Well, it *does* by default. If that's what you want, just do it 
the plain way with simple `new`. It will be destroyed (and any 
structs inside also destroyed) when the GC gets it.




Re: 1st Ever Artificial Consciousness to be Written in D Language

2015-09-09 Thread burjui via Digitalmars-d-announce

On Sunday, 6 September 2015 at 22:49:17 UTC, jqb wrote:

verging on racism with talk of "Nigerian software"


The term has nothing to do with racism. See 
https://en.wikipedia.org/wiki/419_scams
AFAIK, in Russia, my home, this type of scam is commonly known as 
"Nigerian letters": 
https://ru.wikipedia.org/wiki/Нигерийские_письма
I assume you're an American, because Americans are obsessed with 
racism and overly sensitive in general, they like to bring such 
things up. Funny fact: in Russia, we call black people negros, 
and it's completely normal, just like calling Chinese or Georgian 
people asian. On the other hand, pointing out skin color _is_ 
racist here, no matter if it's black, yellow or white. All this 
stuff is completely culture-dependent, after all.


On the topic: I agree that being rude is not the way do discuss 
things, especially in an IT community (we strive to be smarter 
than the majority of people, don't we?). But I understand the 
skepticism in comments. Best scientists study inner workings of 
human brain and are working on theory of consciousness if you 
will, but current results are far from even understanding it 
completely, let alone building an AI.


And then GrandAxe pops up with this revolutionary software, 
claiming that Okeuvo company built an AI. However, that claim is 
not supported by anything and reminds me of the Unlimited Detail 
technology by Euclideon, which was announced in a similar manner, 
promising a revolution in graphics rendering. As you can see, 
it's far from it, despite the fact they were given $2 million by 
the Australian government. It seems like this revolution takes a 
little bit more effort, than was anticipated :)
And there's no reason to think Okeuvo's technology is different 
in that sense.


In general, I tend to not trust people, who claim that their 
technology _will_ do this and that, revolutionize something and 
so on. Show me a working technology first, sell it later. 
Otherwise it's nothing but promises, and I'm not interested in 
that, because everybody can create a website and make promises. 
This thread should be posted at the release date, with "will do 
something" replaced by "does something", supported by a working 
demo that anybody can download without giving up their social 
security number, sexual preferences and whatnot. And in this 
particular case, it should be also supported by scientific 
papers, since they claim to solve such a huge scientific problem 
of the 21th century.


Re: A collection of DIPs

2015-09-09 Thread via Digitalmars-d
On Wednesday, 9 September 2015 at 14:00:52 UTC, Brandon Ragland 
wrote:
Seriously, the fact that the GC has gone un-noticied for so 
long is a HUGE turn off for just about ANY would be C like


It has not gone un-noticed, that's how @nogc came about. So 
people are aware that it is not suitable for interactive use.


The key focus seems to be to rewrite Phobos so that you don't 
need a GC there at all. That approach I know nothing about...


Unfortunately, how to do C++-style memory management is still not 
obvious to me either. And I am also not happy with the 
library-allocator approach since that will make it more difficult 
for the compiler to optimize memory allocations. I think memory 
handling should be part of the language, not a runtime or library 
issue.


So I very much hope for a language spec that takes a more modern 
approach to address memory management so that we can get 
something that is better than  C++ for interactive applications.


D could SERIOUSLY use a rewrite or three of the garbage 
collector.


You actually have to change the language semantics if you want a 
faster garbage collector. You can only scan so many cache-lines 
and unfortunately scanning is limited by total memory that can 
contain pointers and not the size of the GC heap itself... So 
either you need to group pointers on cache-lines and use advanced 
static analysis, limit GC memory access or take the toll of a 
concurrent GC (which would set back progress a couple of years).




Re: class destruction

2015-09-09 Thread Q via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 15:19:04 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 9 September 2015 at 15:10:33 UTC, Q wrote:
But since D has a GC and (per default) force to heap allocate 
a class. So IMO the GC should also destroy it, everything else 
is just awkward.


Well, it *does* by default. If that's what you want, just do it 
the plain way with simple `new`. It will be destroyed (and any 
structs inside also destroyed) when the GC gets it.


I thought that is not guaranteed, according to the docs?


std.experimental.testing formal review

2015-09-09 Thread Robert burner Schadek via Digitalmars-d
This post marks the start of the two week review process of 
std.experimental.testing.


PR: https://github.com/D-Programming-Language/phobos/pull/3207
Dub: http://code.dlang.org/packages/unit-threaded
Doc: See CyberShadow/DAutoTest for up-to-date documentation build

Previous Thread: 
http://forum.dlang.org/post/uzocokshugchescba...@forum.dlang.org


Re: Benchmarking suite

2015-09-09 Thread qznc via Digitalmars-d

On Wednesday, 9 September 2015 at 14:09:36 UTC, Iain Buclaw wrote:

import gcc.builtins;  // OK, cheating. :-)


Thanks, I did not know this. :)

I would not consider it cheating. Using builtins in C is not 
portable C11 either. It also shows off how D does versions.


Re: RFC: Units of measurement for D (Phobos?)

2015-09-09 Thread Robert burner Schadek via Digitalmars-d

On Wednesday, 9 September 2015 at 07:04:05 UTC, Per Nordlöw wrote:

Which direction should we choose?


quantities


Re: dpaste web site

2015-09-09 Thread Vladimir Panteleev via Digitalmars-d

On Wednesday, 9 September 2015 at 22:59:42 UTC, nazriel wrote:

I really have no idea,
I tried to copy and paste those links and indeed they trigger 
recaptcha...
Not sure if recaptcha is so weak or indeed it is a human 
posting those links %)


It costs 0.1 cent ($0.001) to have a human solve a reCAPTCHA.


I will look into methods used in this forum and vibe.d forum.


For forum.dlang.org and wiki.dlang.org I created DCaptcha, which 
asks a D programming question: 
https://github.com/CyberShadow/dcaptcha


It is only activated if Akismet or other spam detectors report 
"spam". It used to have many questions of various difficulty, but 
currently it only asks 1 type of question. So far this blocked 
100% of spam.


AFAIK vibe.d forum uses a Bayesian filter which IIRC generally 
works well but had to be tweaked once or twice. This could work 
well for DPaste if it's trained to distinguish D code from 
not-code.




Re: dpaste web site

2015-09-09 Thread nazriel via Digitalmars-d

On Wednesday, 9 September 2015 at 12:50:17 UTC, BBasile wrote:

On Wednesday, 9 September 2015 at 04:17:13 UTC, nazriel wrote:

On Sunday, 30 August 2015 at 15:05:41 UTC, BBasile wrote:

On Wednesday, 26 August 2015 at 05:54:44 UTC, nazriel wrote:

[...]


since mothes 90% of the new content is spam.
http://dpaste.dzfl.pl/pastes?p=8


Ok I've changed algorithm for spam detection
Also tried to remove some of the spam already posted.


There are still some links sent. Either the bot who targets 
DPaste works well or...no i can't believe this actually a human 
being who send this manually ?!




I really have no idea,
I tried to copy and paste those links and indeed they trigger 
recaptcha...
Not sure if recaptcha is so weak or indeed it is a human posting 
those links %)


I will look into methods used in this forum and vibe.d forum.
They are using some 3rd party spam checking services I think.
Maybe it will be worth a shot.

However thx, a lot, i think that the biggest doleance that 
people had was to have an up-to-date compiler.




Re: Member function pointers

2015-09-09 Thread bitwise via Digitalmars-d

On Wednesday, 9 September 2015 at 18:33:41 UTC, Prudence wrote:

On Tuesday, 27 May 2014 at 12:21:40 UTC, d coder wrote:

[...]


What's the current state of this? I'm in need of such behavior 
for win32 interop.


I'm thinking that one can make the above code more general by 
using it in a mixin and automatically generating the funcptr 
signature:



import std.stdio;
import std.concurrency;

extern (C) int getch();
import std.string;


template FancyDelegate(O, D)
{
	const char[] FancyDelegate = "union "~O.stringof~"Delegate { 
"~D.stringof~" dg; struct { "~O.stringof~"* ptr; 
"~D.stringof.replace("delegate(", 
"function("~O.stringof~",").replace(",)", ")")~" funcptr; } }";	
	//const char[] FancyDelegate = "union "~O.stringof~"Delegate { 
"~D.stringof~" dg; struct { "~O.stringof~"* ptr; 
"~D.stringof.replace("delegate(", "function(")~" funcptr; } }";	

}

class X
{
public int z = 2;
public void foo(int x)
{
//writeln(this.z*x);
writeln(x);
}
}

void delegate(int) dg;

mixin(FancyDelegate!(X, typeof(dg)));


void main()
{

auto xX = new X();
XDelegate x;
x.dg = 

//x.dg(3);
x.ptr = 
x.funcptr(xX, 5);
//x.funcptr(5);


getch();
}

Unfortunately this fails when entering the function. I've tried 
various things(passing , etc..., passing nothing(the 
comments, etc.)


I thought a delegate, when called, was called like a member 
function? It seems that a delegate is some magic black box that 
we can't emulate in any way shape or form due to the calling 
conventions used?


struct S {
void fun() { writeln("fun" ); }
}

class C {
void fun() { writeln("fun" ); }
}

void main(string[] args) {
S s;
void delegate() fn1 = 
fn1();

C c = new C();
void delegate() fn2 = 
fn2();

void delegate() fn3;
fn3.ptr = cast(void*)
fn3.funcptr = 
fn3();

void delegate() fn4;
fn4.ptr = cast(void*)c;
fn4.funcptr = 
fn4();
}


Re: Visual Studio Code

2015-09-09 Thread bitwise via Digitalmars-d
On Wednesday, 9 September 2015 at 06:42:15 UTC, Jacob Carlborg 
wrote:

On 2015-08-03 02:24, bitwise wrote:

Just stumbled upon this:

https://code.visualstudio.com/

I see support for Rust and Go, but no D.

If you download it, there is a little smiley/frowny in the 
bottom right

corner for feedback/feature requests.

Or just vote here:

http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7763160-support-the-d-programming-language


I noticed there are (at least) two entries for the D 
programming language. The other one is [1].


[1] 
http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/8214915-d


Yeah.. that was actually there when I initially posted this, but 
it only had ~1 vote. It's actually a waste... I've added a 
comment directing people to the other idea.


Thanks,
   Bit



[Issue 15030] [REG2.068.1] ICE with recursive delegate, -unittest, and std.range

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15030

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d96a64973467d54a91693f87511da7289d1e1b71
fix Issue 15030 - ICE with recursive delegate, -unittest, and std.range

https://github.com/D-Programming-Language/dmd/commit/ea5d85af7abf0b1e36fd42a8d98fd692a765dea0
Merge pull request #5058 from 9rnsr/fix15030

--


Re: Behavior of opEquals

2015-09-09 Thread deadalnix via Digitalmars-d
On Saturday, 5 September 2015 at 09:44:13 UTC, Jacob Carlborg 
wrote:

On 2015-09-05 08:18, Jonathan M Davis wrote:

There is nothing in the spec about supporting operator 
overloading with
free functions, so I don't know where you get the idea that 
it's even
intended to be a feature. UFCS applies to functions which use 
the member
function call syntax, and operators aren't used that way. 
There is no
plan whatsoever to support operator overloading via free 
functions.


Since "a == b" would be lowered to "a.opEquals(b)" one could 
argue that the compile would also try UFCS since it would do 
that if the code had been "a.opEquals(b)" from the beginning.


The voice of reason.


[Issue 15021] [REG2.068.1] linker error with speculative instantiation and -inline

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15021

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/61f79a8aa18a2d551cfeb7c1bc218ebc3f21cfc6
fix Issue 15021 - linker error with speculative instantiation and -inline

https://github.com/D-Programming-Language/dmd/commit/334e29178254ef0f02639b595a75f906e1b357ee
Merge pull request #5055 from 9rnsr/fix15021

--


Re: What is the difference between D and C++ regarding Unique, RefCounted and Scoped?

2015-09-09 Thread ponce via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 20:17:44 UTC, cym13 wrote:


This is subtly missing the main question: isn't C++-like memory 
management of D classes possible with Unique, RefCounted and 
Scoped?



- Unique

C++ has move semantics which make moves explicit. D's Unique is 
more like the deprecated C++'s auto_ptr: it has an opAssign 
overload that changes the owner.


- RefCounted

Only for D structs. std::shared_ptr works for all.





Re: friends with phobos, workaround?

2015-09-09 Thread Idan Arye via Digitalmars-d-learn

On Wednesday, 9 September 2015 at 20:19:44 UTC, Daniel N wrote:
For the record, I think D made the right decision... omitting 
friends.


However there's one case in particular which I find useful, 
anyone see a good workaround for this?


#include 

class Friendly
{
private:
  int val;
  Friendly(int&& val) : val(val) {}
  friend std::unique_ptr 
std::make_unique(int&& val);

};

int main()
{
  auto yay = std::make_unique(1);
  auto nay = new Friendly(1);
}


How about using a mixin 
template(http://dlang.org/template-mixin.html)?





module makeunique;

mixin template MakeUnique(Args...)
{
import std.typecons : Unique;

static Unique!(typeof(this)) makeUnique(Args args)
{
return Unique!Friendly(new typeof(this)(args));
}
}




module friendly;

import makeunique;

struct Friendly
{
private:
int val;
this(int val)
{
this.val = val;
}

public:
mixin MakeUnique!(int);
};





module app;

import std.stdio;
import std.typecons;

import friendly;

void main()
{
auto yay = Friendly.makeUnique(1);
}



Re: Member function pointers

2015-09-09 Thread Manu via Digitalmars-d
On 10 September 2015 at 04:55, Walter Bright via Digitalmars-d
 wrote:
> On 6/10/2013 7:33 AM, Manu wrote:
>>
>> [...]
>
>
> Sorry to say, your n.g. poster is back to its old tricks :-)

We've resolved this issue since 6/10/2013 no? ;)


Re: "Programming in D" paper book is available for purchase

2015-09-09 Thread Paul O'Neil via Digitalmars-d-announce
On 09/08/2015 02:43 AM, Ali Çehreli wrote:
> I have just completed submitting the book at IngramSpark as well. This
> will give the book a chance to appear on book shelves, which I find
> important because I think seeing and touching a book has an effect on
> anybody visiting a book shop.
> 
> Interestingly, the IngramSpark edition has a separate ISBN, less number
> of pages, and has a different price. For example, although the list
> price of the currently available book is $28.50, the IngramSpark edition
> will cost $33.33. This is to be able to give brick-and-mortar
> booksellers sufficient discount so that the book is interesting to them
> to put on their shelves. To me, the difference in price covers the
> shipping cost and eliminates any shipment waits. You go to the store and
> get the book! It feels more natural. :)
> 
> This edition will have 682 pages as opposed to the 798 pages of the
> current book. However, the content is the same. The difference comes
> from slightly smaller font (9.75pt versus 10pt), less margins, and
> inline curly brackets (aka Egyptian brackets) throughout. I have already
> ordered a proof copy...
> 
> Anyway, thanks again,
> Ali
> 

I understand that you may not have the IngramSpark edition yet, so an
answer may have to wait:

Which publisher produces the better book?  Is one bound better, etc.?

-- 
Paul O'Neil
Github / IRC: todayman


[Issue 15034] ICE(glue.c line 1026) Assertion failure: '!fd->vthis->csym'

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15034

Kenji Hara  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Kenji Hara  ---


*** This issue has been marked as a duplicate of issue 15030 ***

--


[Issue 15030] [REG2.068.1] ICE with recursive delegate, -unittest, and std.range

2015-09-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15030

Kenji Hara  changed:

   What|Removed |Added

 CC||enjouzensyou.bo...@gmail.co
   ||m

--- Comment #5 from Kenji Hara  ---
*** Issue 15034 has been marked as a duplicate of this issue. ***

--


Beta D 2.068.2-b1

2015-09-09 Thread Martin Nowak via Digitalmars-d-announce
Due to a regression in 2.068.1 we'll directly follow up with an
unplanned point release 2.068.2.
This is the beta for that point release.

http://downloads.dlang.org/pre-releases/2.x/2.068.2/

Please test any of your code against this beta to help finding bugs.

https://issues.dlang.org/

-Martin


Re: Member function pointers

2015-09-09 Thread Walter Bright via Digitalmars-d

On 9/9/2015 6:52 PM, Manu via Digitalmars-d wrote:

We've resolved this issue since 6/10/2013 no? ;)



:-)


Re: using std.algorithm to find intersection of DateTime[][] arg

2015-09-09 Thread Sebastiaan Koppe via Digitalmars-d-learn

Couldn't you use setIntersection together with reduce?

Doesn't seem like the most efficient solution, but its less 
typing and most likely will have no bugs.


Re: std.experimental.testing formal review

2015-09-09 Thread Brian Schott via Digitalmars-d
On Wednesday, 9 September 2015 at 15:20:41 UTC, Robert burner 
Schadek wrote:
This post marks the start of the two week review process of 
std.experimental.testing.


PR: https://github.com/D-Programming-Language/phobos/pull/3207
Dub: http://code.dlang.org/packages/unit-threaded
Doc: See CyberShadow/DAutoTest for up-to-date documentation 
build


Previous Thread: 
http://forum.dlang.org/post/uzocokshugchescba...@forum.dlang.org


Package-level documentation seems to be missing from the 
auto-generated documentation.


The gen_ut_main link on the side bar is also a 404.

std.experimental.testing.options.Options and 
std.experimental.testing.reflection.TestData fields have no DDoc, 
so they don't show up in the generated documentation.


Is there going to be a shouldEqual that's specialized for 
floating point, or should shouldBeTrue(approxEqual(...)) be used 
instead? (If so, this should be documented)


std.experimental.testing.testcase.TestCase.numTestsRun should be 
@property?






  1   2   >