Re: unittest-cov - results?

2017-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 05, 2017 19:13:21 Jolly James via Digitalmars-d-learn 
wrote:
> On Wednesday, 5 July 2017 at 19:01:06 UTC, Jonathan M Davis wrote:
> > On Wednesday, July 05, 2017 18:50:32 Jolly James via
> >
> > Digitalmars-d-learn wrote:
> >> On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote:
> >> > On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:
> >> >> [...]
> >> >
> >> > where would I find these *.lst files. Searching for '*.lst'
> >> > in the source's root dir doesn't bring any results.
> >>
> >> I have changed the 'build' to 'test' in the command. Now at
> >> least I get the following message: "All unit tests have been
> >> run successfully." which should not actually happen, as my
> >> code contains an 'assert(false);' unittest.
> >
> > If you don't run the tests, you won't get any code coverage.
> > Building with
> >
> > dub test --coverage
>
> The following command does not change anything:
>dub test --coverage --arch=x86_64 --compiler=ldc2
>
> All I get is "All unit tests have been run successfully." in the
> command line.
>

I don't know why you'd need arch if you're running the tests on the same
system that you're building them. And I don't know if ldc has the code
coverage stuff that dmd has or not - that depends on which pieces of it are
in the front end and which pieces are in the backend. I'd suggest trying it
with dmd instead of ldc to see if you get different results. If

dub test --coverage

does work, whereas running it with the extra flags doesn't, then that at
least tells you something about what's going wrong.

> > should do it. As for your assert(false) test failing, was it in
> > the same module with your main in it?
>
> No, this test is actually in module 'tools.array'.

I don't know then. It was just a thought based on what I've seen before.
Clearly, something is making it so that test doesn't run, but I have no idea
what.

dub does have its own forums though, so you probably stand a better chance
of getting useful help there:

http://forum.rejectedsoftware.com/groups/rejectedsoftware.dub/

- Jonathan M Davis



Re: GtkD nothing

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn
Unfortunately, importing that module seems to throw an error for 
some insane reason.


Error 42: Symbol Undefined _D3gtk6All12__ModuleInfoZ 
(gtk.AllGTK.__ModuleInfo)


without importing it in to the project(but directly importing all 
the other modules works fine, e.g., copying and pasting).




Re: GtkD nothing

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn
The module All in GtkD\generated\Gtkd\gtk will allow importing 
everything, e.g.


import gtk = gtk.All;

gtk.MainWindow

etc.


All.d--
module gtk.All;

public import gtk.AboutDialog;
public import gtk.AccelGroup;
public import gtk.AccelLabel;
public import gtk.AccelMap;
public import gtk.Accessible;
public import gtk.Action;
public import gtk.ActionableIF;
public import gtk.ActionableT;
public import gtk.ActionBar;
public import gtk.ActionGroup;
public import gtk.ActivatableIF;
public import gtk.ActivatableT;
public import gtk.Adjustment;
public import gtk.Alignment;
public import gtk.AppChooserButton;
public import gtk.AppChooserDialog;
public import gtk.AppChooserIF;
public import gtk.AppChooserT;
public import gtk.AppChooserWidget;
public import gtk.Application;
public import gtk.ApplicationWindow;
public import gtk.Arrow;
public import gtk.ArrowAccessible;
public import gtk.AspectFrame;
public import gtk.Assistant;
public import gtk.Bin;
public import gtk.BindingEntry;
public import gtk.BindingSet;
public import gtk.BooleanCellAccessible;
public import gtk.Border;
public import gtk.Box;
public import gtk.BuildableIF;
public import gtk.BuildableT;
public import gtk.Builder;
public import gtk.Button;
public import gtk.ButtonAccessible;
public import gtk.ButtonBox;
public import gtk.Calendar;
public import gtk.CellAccessible;
public import gtk.CellAccessibleParentIF;
public import gtk.CellAccessibleParentT;
public import gtk.CellArea;
public import gtk.CellAreaBox;
public import gtk.CellAreaClass;
public import gtk.CellAreaContext;
public import gtk.CellEditable;
public import gtk.CellEditableIF;
public import gtk.CellEditableT;
public import gtk.CellLayoutIF;
public import gtk.CellLayoutT;
public import gtk.CellRenderer;
public import gtk.CellRendererAccel;
public import gtk.CellRendererClass;
public import gtk.CellRendererCombo;
public import gtk.CellRendererPixbuf;
public import gtk.CellRendererProgress;
public import gtk.CellRendererSpin;
public import gtk.CellRendererSpinner;
public import gtk.CellRendererText;
public import gtk.CellRendererToggle;
public import gtk.CellView;
public import gtk.CheckButton;
public import gtk.CheckMenuItem;
public import gtk.CheckMenuItemAccessible;
public import gtk.Clipboard;
public import gtk.ColorButton;
public import gtk.ColorChooserDialog;
public import gtk.ColorChooserIF;
public import gtk.ColorChooserT;
public import gtk.ColorChooserWidget;
public import gtk.ColorSelection;
public import gtk.ColorSelectionDialog;
public import gtk.ComboBox;
public import gtk.ComboBoxAccessible;
public import gtk.ComboBoxText;
public import gtk.Container;
public import gtk.ContainerAccessible;
public import gtk.ContainerCellAccessible;
public import gtk.ContainerClass;
public import gtk.CssProvider;
public import gtk.CssSection;
public import gtk.Dialog;
public import gtk.DragAndDrop;
public import gtk.DrawingArea;
public import gtk.EditableIF;
public import gtk.EditableT;
public import gtk.Entry;
public import gtk.EntryAccessible;
public import gtk.EntryBuffer;
public import gtk.EntryCompletion;
public import gtk.EventBox;
public import gtk.EventController;
public import gtk.Expander;
public import gtk.ExpanderAccessible;
public import gtk.FileChooserButton;
public import gtk.FileChooserDialog;
public import gtk.FileChooserIF;
public import gtk.FileChooserNative;
public import gtk.FileChooserT;
public import gtk.FileChooserWidget;
public import gtk.FileFilter;
public import gtk.Fixed;
public import gtk.FlowBox;
public import gtk.FlowBoxAccessible;
public import gtk.FlowBoxChild;
public import gtk.FlowBoxChildAccessible;
public import gtk.FontButton;
public import gtk.FontChooserDialog;
public import gtk.FontChooserIF;
public import gtk.FontChooserT;
public import gtk.FontChooserWidget;
public import gtk.FontSelection;
public import gtk.FontSelectionDialog;
public import gtk.Frame;
public import gtk.FrameAccessible;
public import gtk.Gesture;
public import gtk.GestureDrag;
public import gtk.GestureLongPress;
public import gtk.GestureMultiPress;
public import gtk.GesturePan;
public import gtk.GestureRotate;
public import gtk.GestureSingle;
public import gtk.GestureSwipe;
public import gtk.GestureZoom;
public import gtk.GLArea;
public import gtk.Gradient;
public import gtk.Grid;
public import gtk.HandleBox;
public import gtk.HBox;
public import gtk.HButtonBox;
public import gtk.HeaderBar;
public import gtk.HPaned;
public import gtk.HScale;
public import gtk.HScrollbar;
public import gtk.HSeparator;
public import gtk.HSV;
public import gtk.IconFactory;
public import gtk.IconInfo;
public import gtk.IconSet;
public import gtk.IconSize;
public import gtk.IconSource;
public import gtk.IconTheme;
public import gtk.IconView;
public import gtk.IconViewAccessible;
public import gtk.Image;
public import gtk.ImageAccessible;
public import gtk.ImageCellAccessible;
public import gtk.ImageMenuItem;
public import gtk.IMContext;
public import gtk.IMContextSimple;
public import 

Re: GtkD nothing

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn

On Thursday, 6 July 2017 at 01:06:38 UTC, FoxyBrown wrote:

On Thursday, 6 July 2017 at 01:03:11 UTC, FoxyBrown wrote:

On Thursday, 6 July 2017 at 00:51:40 UTC, FoxyBrown wrote:

[...]


Running it from the command line showed it wasn't finding the 
gtk dll. The path variable is set up correctly. I copied the 
bin dir to the exe and it ran and worked except for missing 
icons. Why is gtkD not finding gtk+ even though it is clearly 
in the path and correct?


Copying over the share dir gets it to work but surely all this 
is avoidable?


So, while the setup isn't smooth and not finding everything, do I 
really have to import every ui element or can I just import the 
entire gtk?




Re: GtkD nothing

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn

On Thursday, 6 July 2017 at 01:03:11 UTC, FoxyBrown wrote:

On Thursday, 6 July 2017 at 00:51:40 UTC, FoxyBrown wrote:

[...]


Running it from the command line showed it wasn't finding the 
gtk dll. The path variable is set up correctly. I copied the 
bin dir to the exe and it ran and worked except for missing 
icons. Why is gtkD not finding gtk+ even though it is clearly 
in the path and correct?


Copying over the share dir gets it to work but surely all this is 
avoidable?


Re: GtkD nothing

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn

On Thursday, 6 July 2017 at 00:51:40 UTC, FoxyBrown wrote:

 import gtk.MainWindow;
 import gtk.Label;
 import gtk.Main;
 import std.stdio;

 pragma(lib, "C:\\DLang\\GtkD\\x86\\gtkd.lib");
 void main(string[] args)
 {
 Main.init(args);
 MainWindow win = new MainWindow("Hello World");
 win.setDefaultSize(200, 100);
 win.add(new Label("Hello World"));
 win.showAll();
 Main.run();
 getchar();
 }


Did all the steps, had to switch over from the 64-bit to the 
32-bit dll of gtk+ to avoid errors(since i couldn't get gtkD to 
compile for 64-bit).


The above code(copied from site) simply runs and exists, I 
added the getchar but it doesn't seem to be executed. a BP on 
the first line is never reached, no errors, nothing, to help 
diagnose the issues.



Any ideas?


Running it from the command line showed it wasn't finding the gtk 
dll. The path variable is set up correctly. I copied the bin dir 
to the exe and it ran and worked except for missing icons. Why is 
gtkD not finding gtk+ even though it is clearly in the path and 
correct?




GtkD nothing

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn

 import gtk.MainWindow;
 import gtk.Label;
 import gtk.Main;
 import std.stdio;

 pragma(lib, "C:\\DLang\\GtkD\\x86\\gtkd.lib");
 void main(string[] args)
 {
 Main.init(args);
 MainWindow win = new MainWindow("Hello World");
 win.setDefaultSize(200, 100);
 win.add(new Label("Hello World"));
 win.showAll();
 Main.run();
 getchar();
 }


Did all the steps, had to switch over from the 64-bit to the 
32-bit dll of gtk+ to avoid errors(since i couldn't get gtkD to 
compile for 64-bit).


The above code(copied from site) simply runs and exists, I added 
the getchar but it doesn't seem to be executed. a BP on the first 
line is never reached, no errors, nothing, to help diagnose the 
issues.



Any ideas?


rdmd issues

2017-07-05 Thread FoxyBrown via Digitalmars-d-learn

rdmd -m64 Build.d
Error: can't run 'C:\Program 
Files\VS\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64', check PATH


The path exists, but since it doesn't tell me what it is trying 
to run, I have no clue. The path contains link.exe.






Re: [BEGINNER] reccurence! and sequence!

2017-07-05 Thread Ali Çehreli via Digitalmars-d-learn

On 07/05/2017 04:38 PM, helxi wrote:

>> 
>> sequence!((a, n) => a[0] + 1)(1).take(10).writeln;
>> // [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
>> // because a[0] is always 1
>>
>> recurrence!((a, n) => a[0] + 1)(1).take(10).writeln;
>> // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>> // because a[0] refers to the previous value
>> 
>
> Oh thank you. Just 2 follow-up questions:
>> recurrence!((a, n) => a[0] + 1)(1).take(10).writeln;
> 1. In the last example of reccurence, what does n in (a,n) refer to?

n is "the index of the current value". Each time the lambda is called,

  a[n] is what is being generated
  a[n-1] is the previous value
  a[0] is the same as a[n-1]? (I find this confusing)

> 2. How would you chain until! with reccurence? For example I want to
> compute 1, 10, 100, ..., (until the value remains smaller than 1000_000)?

import std.stdio;
import std.algorithm;
import std.range;

void main() {
auto r = recurrence!((a, n) => a[n-1] * 10)(1);
auto u = r.until!(a => a >= 1_000_000);
writeln(u);
}

[1, 10, 100, 1000, 1, 10]

Ali



Re: dub + local dependencies

2017-07-05 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 6 July 2017 at 00:09:46 UTC, Mike Parker wrote:



You have a few options:

* Use a path dependency:
"dependencies": {
 "xyz": { "path": "path/to/xyz" }
}

* Use add-local with a version on the command line:
dub add-local path/to/xyz  0.0.1

* Use add-local or add-paths and specify a version as described 
by `dub add-paths -h`


Sorry -- extraneous `s` on the `path` bit.

And for the record:

https://code.dlang.org/docs/commandline#add-local
https://code.dlang.org/docs/commandline#add-path
https://code.dlang.org/package-format?lang=json#version-specs


Re: dub + local dependencies

2017-07-05 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:34:36 UTC, Jolly James wrote:
WARNING: A deprecated branch based version specification is 
used for the dependency xyz.

Please use numbered versions instead.
Also note that you can still use the dub.selections.json file 
to override a certain dependency to use a branch instead.



The problem is: xyz is a local package and therefor I don't 
know how to specify its version. So in the dub.json of the 
package abc requiring xyz is written:




"dependencies": {
"xyz": "~master"
},



Is there a cleaner solution?


You have a few options:

* Use a path dependency:
"dependencies": {
 "xyz": { "path": "path/to/xyz" }
}

* Use add-local with a version on the command line:
dub add-local path/to/xyz  0.0.1

* Use add-local or add-paths and specify a version as described 
by `dub add-paths -h`


Re: [BEGINNER] reccurence! and sequence!

2017-07-05 Thread helxi via Digitalmars-d-learn

On Monday, 26 June 2017 at 10:34:22 UTC, ag0aep6g wrote:

On 06/26/2017 11:51 AM, helxi wrote:

[...]


`a` is a tuple of the run-time arguments you pass to 
`sequence`. In this example, no arguments are passed (empty 
parens at the end of the call), so `a` is empty.



[...]


a[0] = 1
a[1] = 2


[...]


`a` isn't used in the string lambda, and it's not considered an 
element of the range. So n starts at 0 and this just prints 
0+2, 1+2, 2+2, etc.



[...]


`a` is still not used in the string lambda, but `recurrence` 
uses the values in `a` as the first elements of the range. `n` 
is incremented accordingly (to 1), so this prints:


1 = a[0],
3 = (n = 1) + 2,
4 = (n = 2) + 2,
etc.

Another difference between `sequence` and `recurrence` is that 
`a` always refers to the same initial value(s) in `sequence`, 
while in `recurrence` it gets updated and refers to the 
previous element(s) of the range:



sequence!((a, n) => a[0] + 1)(1).take(10).writeln;
// [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
// because a[0] is always 1

recurrence!((a, n) => a[0] + 1)(1).take(10).writeln;
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// because a[0] refers to the previous value



Oh thank you. Just 2 follow-up questions:

recurrence!((a, n) => a[0] + 1)(1).take(10).writeln;
1. In the last example of reccurence, what does n in (a,n) refer 
to?
2. How would you chain until! with reccurence? For example I want 
to compute 1, 10, 100, ..., (until the value remains smaller than 
1000_000)?


Re: Question on @nothrow

2017-07-05 Thread Ali Çehreli via Digitalmars-d-learn

On 06/02/2017 12:35 AM, Vasileios Anagnostopoulos wrote:
> On Friday, 2 June 2017 at 07:33:05 UTC, Vasileios Anagnostopoulos wrote:

>> But still I believe that @nothrow should be mandatory if there is no
>> possibility for a function to throw something. I understand that in
>> the DLL/LIB level this is not possible. However, at least in the .di
>> level it should be there.
>>
>> And if you want my two cents, after reading a lot I came to the
>> "personal" conclusion that Exception objects are wrong. For me it is
>> enough to have something like

> Or simply
>
> void A() {
>  raise;
> }
>
> void B() nothrow {
> }
>
>
> void D () nothrow { //the compiler inferred from body that D cannever 
throw

>
> try {
>  A();
> } else {
>   B();
> }
>
> }

If I understand you correctly, you want the compiler to force the 
programmer to be explicit about @nothrow. That's an interesting idea... 
I don't have strong opinions on the matter.


To add to this discussion, there is the "Checked vs unchecked 
exceptions" thread currently active on the general newsgroup:


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

Ali



Re: Question on @nothrow

2017-07-05 Thread Yuxuan Shui via Digitalmars-d-learn

On Wednesday, 31 May 2017 at 09:31:48 UTC, Jonathan M Davis wrote:
On Wednesday, May 31, 2017 08:18:07 Vasileios Anagnostopoulos 
via Digitalmars-d-learn wrote:

[...]


Well, if you're not doing checked exceptions, the interesting 
question is really what _doesn't_ throw rather than what 
throws, because if the compiler knows that a function doesn't 
throw, it can optimize out the exception handling mechanisms 
that are normally required.


I don't think this is possible in current D? @nothrow functions 
can still throw Error.


Re: Question on @nothrow

2017-07-05 Thread Yuxuan Shui via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 08:18:07 UTC, Vasileios 
Anagnostopoulos wrote:

Hi,

after reading various articles bout the "supposed" drawbacks of 
checked exceptions I started to have questions on @nothrow. Why 
there exists and not a @throws annotation enforced by the 
compiler? I understand that people are divided on checked 
exceptions and each side has some valid points. But explicitly 
marking a function as throwing "something" is another subject. 
Why have the dlang community reached to the decision to use 
@nothrow and not a @throws?


Adding @throws to a function requires changing all the functions 
downstream. Adding @nothrow doesn't.


Re: unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 19:01:06 UTC, Jonathan M Davis wrote:
On Wednesday, July 05, 2017 18:50:32 Jolly James via 
Digitalmars-d-learn wrote:

On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote:
> On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:
>> [...]
>
> where would I find these *.lst files. Searching for '*.lst' 
> in the source's root dir doesn't bring any results.


I have changed the 'build' to 'test' in the command. Now at 
least I get the following message: "All unit tests have been 
run successfully." which should not actually happen, as my 
code contains an 'assert(false);' unittest.


If you don't run the tests, you won't get any code coverage. 
Building with


dub test --coverage


The following command does not change anything:
  dub test --coverage --arch=x86_64 --compiler=ldc2
All I get is "All unit tests have been run successfully." in the 
command line.



should do it. As for your assert(false) test failing, was it in 
the same module with your main in it?


No, this test is actually in module 'tools.array'.



Re: unittest-cov - results?

2017-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 05, 2017 18:50:32 Jolly James via Digitalmars-d-learn 
wrote:
> On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote:
> > On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:
> >> On Wednesday, 5 July 2017 at 17:46:01 UTC, Jolly James wrote:
> >>> [...]
> >>
> >> For every file a `.lst` file is generated (it's the same
> >> how `-cov` behaves at DMD).
> >> These .lst files contain the original source code with number
> >>
> >> of hits of a respective line:
> >>   2|auto copy = new char[s.length + 1];
> >>   2|copy[0 .. s.length] = s[];
> >>   2|copy[s.length] = 0;
> >>
> >> Maybe you haven't seen the lst files?
> >>
> >>
> >> Btw if you use Travis, you can use an `after_success` event to
> >> your `.travis.yml` to upload the results to CodeCov for a nice
> >> visuals & PR integration:
> >>
> >> ```
> >>
> >> after_success:
> >>  - bash <(curl -s https://codecov.io/bash)
> >>
> >> ```
> >>
> >> We do this on most dlang repos, e.g.
> >> https://github.com/dlang/phobos/pull/5503
> >
> > where would I find these *.lst files. Searching for '*.lst' in
> > the source's root dir doesn't bring any results.
>
> I have changed the 'build' to 'test' in the command. Now at least
> I get the following message: "All unit tests have been run
> successfully." which should not actually happen, as my code
> contains an 'assert(false);' unittest.

If you don't run the tests, you won't get any code coverage. Building with

dub test --coverage

should do it. As for your assert(false) test failing, was it in the same
module with your main in it? I ran into a bug in dub not all that long ago
where the tests in the module with main in it weren't actually being run
even though the other tests were. (which reminds me, I should verify that
again and report it).

- Jonathan M Davis



Re: unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:

On Wednesday, 5 July 2017 at 17:46:01 UTC, Jolly James wrote:

[...]


For every file a `.lst` file is generated (it's the same 
how `-cov` behaves at DMD).
These .lst files contain the original source code with number 
of hits of a respective line:


  2|auto copy = new char[s.length + 1];
  2|copy[0 .. s.length] = s[];
  2|copy[s.length] = 0;

Maybe you haven't seen the lst files?


Btw if you use Travis, you can use an `after_success` event to 
your `.travis.yml` to upload the results to CodeCov for a nice 
visuals & PR integration:


```
after_success:
 - bash <(curl -s https://codecov.io/bash)
```

We do this on most dlang repos, e.g. 
https://github.com/dlang/phobos/pull/5503


where would I find these *.lst files. Searching for '*.lst' in 
the source's root dir doesn't bring any results.


I have changed the 'build' to 'test' in the command. Now at least 
I get the following message: "All unit tests have been run 
successfully." which should not actually happen, as my code 
contains an 'assert(false);' unittest.


Re: unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:

On Wednesday, 5 July 2017 at 17:46:01 UTC, Jolly James wrote:

[...]


For every file a `.lst` file is generated (it's the same 
how `-cov` behaves at DMD).
These .lst files contain the original source code with number 
of hits of a respective line:


  2|auto copy = new char[s.length + 1];
  2|copy[0 .. s.length] = s[];
  2|copy[s.length] = 0;

Maybe you haven't seen the lst files?


Btw if you use Travis, you can use an `after_success` event to 
your `.travis.yml` to upload the results to CodeCov for a nice 
visuals & PR integration:


```
after_success:
 - bash <(curl -s https://codecov.io/bash)
```

We do this on most dlang repos, e.g. 
https://github.com/dlang/phobos/pull/5503


where would I find these *.lst files. Searching for '*.lst' in 
the source's root dir doesn't bring any results.


Re: unittest-cov - results?

2017-07-05 Thread Seb via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 17:46:01 UTC, Jolly James wrote:

How does unit testing with dub work?

dub build --arch=x86_64 --build=unittest-cov --force 
--compiler=ldc2


After execution, there is no result output in the command line.


For every file a `.lst` file is generated (it's the same 
how `-cov` behaves at DMD).
These .lst files contain the original source code with number of 
hits of a respective line:


  2|auto copy = new char[s.length + 1];
  2|copy[0 .. s.length] = s[];
  2|copy[s.length] = 0;

Maybe you haven't seen the lst files?


Btw if you use Travis, you can use an `after_success` event to 
your `.travis.yml` to upload the results to CodeCov for a nice 
visuals & PR integration:


```
after_success:
 - bash <(curl -s https://codecov.io/bash)
```

We do this on most dlang repos, e.g. 
https://github.com/dlang/phobos/pull/5503


Re: Remove instance from array

2017-07-05 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 05, 2017 at 05:07:14PM +, Jolly James via Digitalmars-d-learn 
wrote:
> On Wednesday, 5 July 2017 at 16:55:43 UTC, bachmeier wrote:
> > On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:
> > 
> > > Here in D everything looks like climbing mount everest. When you
> > > ask how to use D's containers you are recommended to use dynamic
> > > arrays instead. When you look at the docs for std.algorithm, e.g.
> > > the .remove section, you get bombed with things like
> > > 'SwapStrategy.unstable', asserts and tuples, but you aren't told
> > > how to simply remove 1 specific element.
> > 
> > If you feel that there is a problem with the docs, you should file a
> > bug: https://dlang.org/bugstats.php
> > 
> > The documentation is still not perfect, but the only way to improve
> > it is to file bugs when you see something that needs fixing.
> 
> unfortunately, it's not that the docs would be wrong or something that
> can be easily corrected. Nope, the docs do everything right, they show
> you what the existing things do. But what they don't do is how to get
> stuff done.  imho some additional, useful guides would be nice.

No, that's a sign that the docs are not good enough.  Describing what
existing things do is only the bare minimum of documentation. *Good*
documentation should also tell you what you can use it for, and give
examples of how to do it, preferably examples that address the most
common use cases first, and then, if necessary, a discussion of more
details later.

The very first example in the docs for std.algorithm.mutation.remove is
not suitable as a first example, because it already throws something
unexpected in your face, i.e., that remove() doesn't change the incoming
range directly.  It should have shown the *correct* way of removing an
element as a first example, i.e.:

a = a.remove(1);

And *then* talk about the details later.

Here's my fix for this:

https://github.com/dlang/phobos/pull/5548

In the future, please do file a bug for these kinds of documentation
issues.  D needs *good* documentation, not just bare-minimum
documentation.


T

-- 
Long, long ago, the ancient Chinese invented a device that lets them see 
through walls. It was called the "window".


unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

How does unit testing with dub work?

dub build --arch=x86_64 --build=unittest-cov --force 
--compiler=ldc2


After execution, there is no result output in the command line.


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:55:43 UTC, bachmeier wrote:

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

Here in D everything looks like climbing mount everest. When 
you ask how to use D's containers you are recommended to use 
dynamic arrays instead. When you look at the docs for 
std.algorithm, e.g. the .remove section, you get bombed with 
things like 'SwapStrategy.unstable', asserts and tuples, but 
you aren't told how to simply remove 1 specific element.


If you feel that there is a problem with the docs, you should 
file a bug: https://dlang.org/bugstats.php


The documentation is still not perfect, but the only way to 
improve it is to file bugs when you see something that needs 
fixing.


unfortunately, it's not that the docs would be wrong or something 
that can be easily corrected. Nope, the docs do everything right, 
they show you what the existing things do. But what they don't do 
is how to get stuff done. imho some additional, useful guides 
would be nice.


Re: Remove instance from array

2017-07-05 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

Here in D everything looks like climbing mount everest. When 
you ask how to use D's containers you are recommended to use 
dynamic arrays instead. When you look at the docs for 
std.algorithm, e.g. the .remove section, you get bombed with 
things like 'SwapStrategy.unstable', asserts and tuples, but 
you aren't told how to simply remove 1 specific element.


If you feel that there is a problem with the docs, you should 
file a bug: https://dlang.org/bugstats.php


The documentation is still not perfect, but the only way to 
improve it is to file bugs when you see something that needs 
fixing.


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote:

[...]


Thank you! :)


But why a containers so complicated in D?

[...]




Part of CoreCLR's 'List':


   public bool Remove(T item)
   {
   int index = IndexOf(item);
   if (index >= 0)
   {
   RemoveAt(index);
   return true;
   }

   return false;
   }
// 
https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Collections/Generic/List.cs



If there isn't already, maybe something similar to this should 
get part of Phobos. I think this could be really useful.


Re: Remove instance from array

2017-07-05 Thread Igor Shirkalin via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote:
On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin 
wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


Perhaps, for all references to i it should look like:
a = a.filter!(a => a !is i).array;


Thank you! :)


But why a containers so complicated in D?

In C# I would go for a generic List, which would support 
structs and classes, where I simply could call '.Remove(T 
item)' or '.RemoveAt(int index)'. I would know how this works, 
because the method names make sense, the docs are straight 
forward.


Here in D everything looks like climbing mount everest. When 
you ask how to use D's containers you are recommended to use 
dynamic arrays instead. When you look at the docs for 
std.algorithm, e.g. the .remove section, you get bombed with 
things like 'SwapStrategy.unstable', asserts and tuples, but 
you aren't told how to simply remove 1 specific element.


I don't know c sharp, but I can tell everything about c++ and 
python. To climb a everest in python you have to know almost 
nothing, in c++ you have to know almost everything. In D you have 
to be smarter, you do not need to climb a everest but you have to 
know minimum to do that. Spend a year in learning and get the 
best result in minutes).


mysql-native ResultRange + map

2017-07-05 Thread crimaniak via Digitalmars-d-learn

Hi all!

After some hard time with debugging, I found ResultRange returned 
by query() and Prepared::query() of mysql-native package can't be 
combined with map() because after map() it becomes empty 
resultset.


Code (conn.queryRows just a wrapper for query(Connections, sql) ):

immutable sql = "SELECT id FROM "~tableName~" ORDER BY id";

	conn.queryRows(sql).each!(row => writeln("each:", 
row[0].to!string));


	string[] applied = conn.queryRows(sql).map!(row => 
row[0].to!string).array;

writeln("applied:", applied);

foreach(row; conn.queryRows(sql))
writeln("foreach: ", row[0].to!string);

	conn.queryRows(sql).map!(row => row[0].to!string).each!(row => 
writeln("map-each:", row));


foreach(row; conn.queryRows(sql).map!(row => row[0].to!string))
writeln("foreach-map: ", row);

stdout.flush;

Result:
SELECT id FROM versionupdate ORDER BY id
each:.Script20161013_create_database
each:.Script20161221_sites_table
each:.Script20161227_update_users_devices
each:.Script20170121_ownerid
each:.Script20170124_create_clients
each:.Script20170213_no_unique_site_name
each:.Script20170215_remove_site_sn
each:.Script20170228_remove_site_index
each:.Script20170301_add_linkNo
each:.Script20170301_fix_sites_indexes
each:.Script20170310_demo_client
each:.Script20170513_max_dev_number
SELECT id FROM versionupdate ORDER BY id
applied:[]
SELECT id FROM versionupdate ORDER BY id
foreach: .Script20161013_create_database
foreach: .Script20161221_sites_table
foreach: .Script20161227_update_users_devices
foreach: .Script20170121_ownerid
foreach: .Script20170124_create_clients
foreach: .Script20170213_no_unique_site_name
foreach: .Script20170215_remove_site_sn
foreach: .Script20170228_remove_site_index
foreach: .Script20170301_add_linkNo
foreach: .Script20170301_fix_sites_indexes
foreach: .Script20170310_demo_client
foreach: .Script20170513_max_dev_number
SELECT id FROM versionupdate ORDER BY id
SELECT id FROM versionupdate ORDER BY id

As you see simple each() and foreach() works, but all examples 
with map() involved always empty. Can anybody explain such 
strange behavior?




Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote:
On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin 
wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


Perhaps, for all references to i it should look like:
a = a.filter!(a => a !is i).array;


Thank you! :)


But why a containers so complicated in D?

In C# I would go for a generic List, which would support 
structs and classes, where I simply could call '.Remove(T item)' 
or '.RemoveAt(int index)'. I would know how this works, because 
the method names make sense, the docs are straight forward.


Here in D everything looks like climbing mount everest. When you 
ask how to use D's containers you are recommended to use dynamic 
arrays instead. When you look at the docs for std.algorithm, e.g. 
the .remove section, you get bombed with things like 
'SwapStrategy.unstable', asserts and tuples, but you aren't told 
how to simply remove 1 specific element.


Re: Remove instance from array

2017-07-05 Thread Igor Shirkalin via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


Perhaps, for all references to i it should look like:
a = a.filter!(a => a !is i).array;


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


Re: Remove instance from array

2017-07-05 Thread Igor Shirkalin via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


Re: Remove instance from array

2017-07-05 Thread Andrea Fontana via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


Maybe: http://dlang.org/phobos/std_algorithm_mutation.html#.remove

?


dub + local dependencies

2017-07-05 Thread Jolly James via Digitalmars-d-learn
WARNING: A deprecated branch based version specification is 
used for the dependency xyz.

Please use numbered versions instead.
Also note that you can still use the dub.selections.json file 
to override a certain dependency to use a branch instead.



The problem is: xyz is a local package and therefor I don't know 
how to specify its version. So in the dub.json of the package abc 
requiring xyz is written:




"dependencies": {
"xyz": "~master"
},



Is there a cleaner solution?


Re: how to harvest the results of tasks from a taskpool?

2017-07-05 Thread Martin Tschierschke via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 13:55:22 UTC, Martin wrote:

Hi,

i have a coulpe of different machines with MySQL Servers 
running on it.
Now, i want to execute queries for all Databases at the same 
time and collect the Result to process it.


I am new to the parallelism - so maybe i understand something 
totaly wrong.

What i tring is something like this:


{
 auto tPool = new TaskPool();
 forach(server ; servers)
 {
  auto task = task!queryWorker(query);
  tPool.put(task);
 }

 tPool.finish(true);
//> how to collect the results now? <---

}

row[] queryWorker(string query) {

 //rows = result of the query

 return rows;
}


btw.. how to markup code in this forum?
I tested a much simpler approach with the following 
setup/structure?:


// a shared array of results where each result is again an array;
Rows results[];

// using parallel foreach
foreach(i,server;servers.parallel){
 result[i] = request(server).array;;
}
Now every array of rows is accessible in result[]?

Tested this construct with parallel curl requests:

time ./parallel_curl
Site www.dlang.org. Page has length:31607
Site forum.dlang.org. Page has length:24358
Site code.dlang.org. Page has length:36477
Site www.google.com. Page has length:10628

real0m0.836s
user0m0.137s
sys 0m0.034s

Without parallel:

real0m2.424s
user0m0.722s
sys 0m0.209s

This is the code:

import std.stdio;
import std.net.curl;
import std.parallelism;
void main()
{
enum string[] tospider = 
["www.dlang.org","forum.dlang.org","code.dlang.org","www.google.com"];

char[][tospider.length] results;
foreach(i,site;tospider.parallel){
 results[i] = get(site);
}

foreach(i,e;results){
writeln("Site ", tospider[i],". Page has 
length:",e.length);

}
}


Will try to use this approach to collect some elastic seach 
results and look if it speeds up on an 8 core machine.






Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


how to harvest the results of tasks from a taskpool?

2017-07-05 Thread Martin via Digitalmars-d-learn

Hi,

i have a coulpe of different machines with MySQL Servers running 
on it.
Now, i want to execute queries for all Databases at the same time 
and collect the Result to process it.


I am new to the parallelism - so maybe i understand something 
totaly wrong.

What i tring is something like this:


{
 auto tPool = new TaskPool();
 forach(server ; servers)
 {
  auto task = task!queryWorker(query);
  tPool.put(task);
 }

 tPool.finish(true);
//> how to collect the results now? <---

}

row[] queryWorker(string query) {

 //rows = result of the query

 return rows;
}


btw.. how to markup code in this forum?


Re: Need simple sound

2017-07-05 Thread Martin Tschierschke via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 10:19:54 UTC, Sebastiaan Koppe wrote:
On Wednesday, 5 July 2017 at 09:43:05 UTC, Martin Tschierschke 
wrote:
On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe 
wrote:

On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote:
On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe 
wrote:

Portaudio is simple as well. And nice cross platform.


are there any bindings?


Sure, see http://code.dlang.org/packages/portaudio


Sorry, for that question but now, as I have several different 
options -
all not 'overdocumented' -  so what would be the shortest 
possible D program waiting for input and playing a sound from 
a file in parallel?


Something short like the single-file dub example...?

#!/usr/bin/env dub
/+ dub.sdl:
name "hello"
+/
void main() {

 writef("Do you like the music?");
  char[] answer;
  answer = readln();
  writef("This was your Answer: ", answer);

}


This one plays a wav file. Couldn't get dub to do single-file 
on it. It kept giving linker errors. (Took example from 
https://github.com/v--/portaudio/blob/master/examples/pa_test.d)

[...]

 Lerror:
stderr.writefln("error %s", 
to!string(Pa_GetErrorText(err)));

return 1;
}

Thank you!

Without the error handling it would be quite simple :-)
So, the following process starts the music in main, it is just to 
clarify the process for me: In main:


//1
PaStream* stream;
Sound input = decodeWAV("FILE.wav");
auto audio = Audio(input);
Pa_Initialize();
Pa_OpenDefaultStream(,...input...,);
//2
Pa_StartStream(stream);
//3
Pa_StopStream(stream);
Pa_CloseStream(stream);

For my purpose I will try to encapsulate it all in 3 additional 
own methods on top of it:

//1
 auto myinput = InitWav("File.wav");
//2
 PlaySound(myinput,volume=default, length=max_length);
//3
 StopSound(myinput);

With a new Struct myinput to handle input,audio and stream.

Thank you all for your help!




Re: weird error message

2017-07-05 Thread crimaniak via Digitalmars-d-learn

On Sunday, 2 July 2017 at 01:06:29 UTC, Ali Çehreli wrote:

On 07/01/2017 04:56 PM, crimaniak wrote:

> about very long error messages generated in some
> cases.

Please submit a bug report. The compiler may be able to 
abbreviate certain types. For example, in this case most of the 
error message text is values of a static array elements.


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


Re: Append to 'map' result

2017-07-05 Thread Jean-Louis Leroy via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 01:43:46 UTC, Ali Çehreli wrote:

On 07/04/2017 05:52 PM, Jean-Louis Leroy wrote:

On Wednesday, 5 July 2017 at 00:28:01 UTC, Ali Çehreli wrote:

On 07/04/2017 04:57 PM, Jean-Louis Leroy wrote:

[...]
No time to dig deeper but this is because the two ranges that 
chain()
receives do not have a common type. (Rather, that type is 
'void'):


[...]




This is related to TypeInfo.init, which unfortunately is *not* 
the .init property in this case. :( Luckily, it will be fixed 
in 2.075. This is what object.d has:

[...]
So, unfortunately, most Phobos range functions cannot be used 
with TypeInfo as they would invariably touch ElementType. Here 
is a halfway workaround that uses each() instead of map(): :/


Aaah, so I was not doing anything wrong ;-)

I was trying to factor this code:

  foreach (i; k.interfaces) {
if (i.classinfo in classMap) {
  v.bases ~= classMap[i.classinfo];
}
  }
  if (k.base in classMap) {
v.bases ~= classMap[k.base];
  }

i.e. process the class base along with the interfaces in the same 
loop. I dwelled on it because my goal with this project is to 
learn (and evaluate) D.


Anyway, I am building my own graph of enriched ClassInfo objects; 
once that is done, I won't be impacted with the bug anymore.


Thanks for the diagnostic...

J-L




Re: Cannot implicitly convert expression (struct this)

2017-07-05 Thread Andre Pany via Digitalmars-d-learn

On Friday, 23 June 2017 at 15:52:10 UTC, Kagamin wrote:

On Thursday, 22 June 2017 at 09:57:44 UTC, Andre Pany wrote:

This line raises the error:
TestStruct s2 = TestStruct(Reason.FU);
Error: cannot implicitly convert expression ("Fu") of type 
Reason to InitialEnum!(Reason)


While this line is working fine:
TestStruct s1 = {reason: Reason.FU};


I think these should be equivalent, report a bug.


Issue 17552 created:
http://forum.dlang.org/post/mailman.3688.1498412595.31550.digitalmars-d-b...@puremagic.com

Kind regards
André


Re: About Dub capabilities

2017-07-05 Thread Seb via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 06:06:18 UTC, Dukc wrote:

On Tuesday, 4 July 2017 at 21:02:55 UTC, Martin Nowak wrote:
preGenerate-/preBuildCommands are your friends to compile C++ 
code using dub.


Hod did I not notice them... but that answers the question, 
thanks.


See https://github.com/dlang-community/drepl/pull/63 for an 
example on how simple c/c++ files can be compiled "on-the-fly".


Re: Need simple sound

2017-07-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 09:43:05 UTC, Martin Tschierschke 
wrote:
On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe 
wrote:

On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote:
On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe 
wrote:

Portaudio is simple as well. And nice cross platform.


are there any bindings?


Sure, see http://code.dlang.org/packages/portaudio


Sorry, for that question but now, as I have several different 
options -
all not 'overdocumented' -  so what would be the shortest 
possible D program waiting for input and playing a sound from a 
file in parallel?


Something short like the single-file dub example...?

#!/usr/bin/env dub
/+ dub.sdl:
name "hello"
+/
void main() {

 writef("Do you like the music?");
  char[] answer;
  answer = readln();
  writef("This was your Answer: ", answer);

}


This one plays a wav file. Couldn't get dub to do single-file on 
it. It kept giving linker errors. (Took example from 
https://github.com/v--/portaudio/blob/master/examples/pa_test.d)


**dub.sdl
name "audio"
description "plays audio file"
authors "Sebastiaan Koppe"
dependency "portaudio" version="==1.0.0"
dependency "wave-d" version="~>1.0.6"

configuration "executable" {
  mainSourceFile "audio.d"
  targetType "executable"
}

**audio.d
import std.stdio;
import waved;
import deimos.portaudio;
import std.conv, std.stdio;
import std.algorithm : min;

struct Audio {
float* samples;
size_t frames;
size_t position;
}

extern(C) int callback(const(void)* inputBuffer, void* 
outputBuffer,

 size_t framesPerBuffer,
 const(PaStreamCallbackTimeInfo)* 
timeInfo,

 PaStreamCallbackFlags statusFlags,
 void *userData)
{
auto pout = cast(float*)outputBuffer;
Audio* audio = cast(Audio*)userData;

enum vol = 0.2f;
size_t frames = min(audio.frames - audio.position, 
framesPerBuffer);


foreach(i; 0 .. frames)
*pout++ = vol * audio.samples[i + audio.position];
foreach(i; frames .. framesPerBuffer)
*pout++ = 0;

audio.position += framesPerBuffer;
return frames == framesPerBuffer ? paContinue : paComplete;
}

int main()
{
PaStream* stream;
PaError err;

Sound input = decodeWAV("my_wav_file.wav");
string answer;

auto audio = Audio(input.samples.ptr, input.samples.length);

if ((err = Pa_Initialize()) != paNoError) goto Lerror;

if ((err = Pa_OpenDefaultStream(,
0,
input.channels,
paFloat32,
cast(double)input.sampleRate,
paFramesPerBufferUnspecified,
,
))
!= paNoError) goto Lerror;

if ((err = Pa_StartStream(stream)) != paNoError) goto Lerror;

writef("Do you like the music?");
answer = readln();
writefln("This was your Answer: %s", answer);

if ((err = Pa_StopStream(stream)) != paNoError) goto Lerror;
if ((err = Pa_CloseStream(stream)) != paNoError) goto Lerror;
if ((err = Pa_Terminate()) != paNoError) goto Lerror;

return 0;
 Lerror:
stderr.writefln("error %s", to!string(Pa_GetErrorText(err)));
return 1;
}


Re: Need simple sound

2017-07-05 Thread Martin Tschierschke via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe wrote:

On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote:
On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe 
wrote:

Portaudio is simple as well. And nice cross platform.


are there any bindings?


Sure, see http://code.dlang.org/packages/portaudio


Sorry, for that question but now, as I have several different 
options -
all not 'overdocumented' -  so what would be the shortest 
possible D program waiting for input and playing a sound from a 
file in parallel?


Something short like the single-file dub example...?

#!/usr/bin/env dub
/+ dub.sdl:
name "hello"
+/
void main() {

 writef("Do you like the music?");
  char[] answer;
  answer = readln();
  writef("This was your Answer: ", answer);

}







Re: Need simple sound

2017-07-05 Thread Sebastiaan Koppe via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote:

On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe wrote:

Portaudio is simple as well. And nice cross platform.


are there any bindings?


Sure, see http://code.dlang.org/packages/portaudio


Re: About Dub capabilities

2017-07-05 Thread Dukc via Digitalmars-d-learn

On Tuesday, 4 July 2017 at 21:02:55 UTC, Martin Nowak wrote:
preGenerate-/preBuildCommands are your friends to compile C++ 
code using dub.


Hod did I not notice them... but that answers the question, 
thanks.