Re: D as a Better C

2017-08-25 Thread Jolly James via Digitalmars-d-announce

On Friday, 25 August 2017 at 15:29:54 UTC, Swoorup Joshi wrote:

On Friday, 25 August 2017 at 08:54:02 UTC, Kagamin wrote:

On Thursday, 24 August 2017 at 19:09:58 UTC, Parke wrote:

What is "intermediate D"?


D with minimal runtime.


5 years later...

D - BetterC++ (no gc)
D - BetterJava (full on gc + other goodie tissue)
D - BetterRust (full interoperability with rust)

Forgive my cynicism


D - BetterC# (no simple and easy-to-use generics, complex 
templates instead)
Phobos - Better.NET (pointless names, weird structure, outdated 
stuff)
DCD - BetterIntelliSense (tends to always not find about ~10 of 
all real possibilities, is rather "patched into" IDEs/editors 
than integrated)


Re: ffmpeg

2017-08-19 Thread Jolly James via Digitalmars-d-learn

On Saturday, 19 August 2017 at 02:50:44 UTC, Johnson Jones wrote:

Trying to get it to work.



You could just try to use/call the ffmeg executable as wrapper. 
For sure, not the best, but proabably the easiest solution. Afaik 
it also supports pipes.


Re: Release D 2.075.0 does not install on Windows 10 with VS2017

2017-07-20 Thread Jolly James via Digitalmars-d-announce

On Thursday, 20 July 2017 at 16:28:54 UTC, jan wrote:

seems like i am not the first one to have that problem.

please fix.


everything working fine from here :)
Maybe you should state what exactly is not working for you and 
paste some error messages...


Re: Remove instance from array

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

On Thursday, 6 July 2017 at 08:15:10 UTC, Andrea Fontana wrote:

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

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

[...]




Part of CoreCLR's 'List':


[...]



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


q = q.remove(1); // Remove element with index 1
q = q.remove(x => x == instance); // Remove all items that 
match instance


thx


Re: dub + local dependencies

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

On Thursday, 6 July 2017 at 00:12:25 UTC, Mike Parker wrote:

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


thx


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 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.


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 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 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 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'.


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?


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'?


Re: Linking external *.lib files

2017-06-21 Thread Jolly James via Digitalmars-d-learn

*push*



Re: Templated Lists

2017-06-16 Thread Jolly James via Digitalmars-d

On Saturday, 17 June 2017 at 00:28:50 UTC, Ali Çehreli wrote:

On 06/16/2017 05:02 PM, Jolly James wrote:
If I did well on my quick research, C#'s generic lists are 
exactly that. :)




C#'s generics allow to specify one datatype T that is used, some 
kind of similar to a template. So, a generic list can contain 
only elements of type T. That what makes it generic is that M$ 
had to implement this class only once and now it can be used with 
any datatype by simply specifying  it ( → List ).




With std.algorithm.remove:

import std.algorithm;

void main() {
auto arr = [ 1, 2, 3, 4, 5, 6 ];

arr = arr.remove(5);// Removes element at index 
3

assert(arr == [ 1, 2, 3, 4, 5 ]);

arr = arr.remove!(e => e % 2);  // Removes elements with 
odd values

assert(arr == [ 2, 4 ]);
}


Thank you very much :)




Re: Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

On Saturday, 17 June 2017 at 00:33:01 UTC, Jolly James wrote:

On Saturday, 17 June 2017 at 00:09:41 UTC, Jolly James wrote:

Let's assume, I have the following 2 dub packages:


pkgBASE:
(depends on public DUB package)
source/
lib/
pkgAPP:
(depends on pkgBASE)
source/


I have added pkgBASE via add-path. This wasn't a problem at 
all.


Unfortunately, the public DUB package requires to be linked 
with the libs from pkgBASE/lib. What do I have to add to 
pkgBASE's dub.json?


Side-note: the lib/ should not be moved for portability reasons 
if this is possible




My bad solution:


"lflags": [
"-Llib\\"
],



but this requires the lib folder to be part of pkgAPP, not 
pkgBASE where I would like to have it. Does anyone have an idea?


Re: Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

On Saturday, 17 June 2017 at 00:09:41 UTC, Jolly James wrote:

Let's assume, I have the following 2 dub packages:


pkgBASE:
(depends on public DUB package)
source/
lib/
pkgAPP:
(depends on pkgBASE)
source/


I have added pkgBASE via add-path. This wasn't a problem at all.

Unfortunately, the public DUB package requires to be linked 
with the libs from pkgBASE/lib. What do I have to add to 
pkgBASE's dub.json?


Side-note: the lib/ should not be moved for portability reasons 
if this is possible


Re: Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

Let's assume, I have the following 2 dub packages:


pkgBASE:
(depends on public DUB package)
source/
lib/
pkgAPP:
(depends on pkgBASE)
source/


I have added pkgBASE via add-path. This wasn't a problem at all.

Unfortunately, the public DUB package requires to be linked with 
the libs from pkgBASE/lib. What do I have to add to pkgBASE's 
dub.json?


Re: Templated Lists

2017-06-16 Thread Jolly James via Digitalmars-d

On Friday, 16 June 2017 at 23:38:46 UTC, Ali Çehreli wrote:

On 06/16/2017 04:08 PM, Jolly James wrote:

On Friday, 16 June 2017 at 19:42:44 UTC, Cym13 wrote:

I'm unclear about your intent: do you want a compile-time list


I am looking for something similar to C#'s generic list.


std.variant.Variant perhaps?

  https://dlang.org/phobos/std_variant.html

import std.variant;

void main() {
Variant[] arr;
arr ~= Variant(42);
arr ~= Variant("hello");
}

Also consider Algebraic in that module.

Ali


Thx, but I do not need to mix different types (using variant). 
Assuming I use simply an dynamic array, how does one remove an 
specific item?


Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

Let's assume, I have the following 2 dub packages:

pkgBASE:
source/
lib/

pkgAPP:



Re: Templated Lists

2017-06-16 Thread Jolly James via Digitalmars-d

On Friday, 16 June 2017 at 19:42:44 UTC, Cym13 wrote:

I'm unclear about your intent: do you want a compile-time list


I am looking for something similar to C#'s generic list.


interface IList
{
int Count { get; }

void Add(T item);
void Remove(T item);

T this[int index];

// [...]
}


Templated Lists

2017-06-16 Thread Jolly James via Digitalmars-d
I know that there are arrays, some strange container classes and 
so on.


But how does one create and use a templated list in D that 
supports adding, removing and sorting items? One that can be used 
for structs and for classes?


Re: DMD VS2017 Support

2017-06-04 Thread Jolly James via Digitalmars-d

On Monday, 1 May 2017 at 18:30:53 UTC, Rainer Schuetze wrote:



On 01.05.2017 10:03, Igor wrote:

On Monday, 1 May 2017 at 01:54:30 UTC, evilrat wrote:

[...]


That was it. It didn't occur to me that this was the problem 
because I
payed closed attention during VisualD installation and saw it 
properly
recognized where DMD was installed but for some reason the 
path wasn't
set in Options. Once I did set it, compile and build worked. 
Thanks

evilrat!

So in conclusion it seems the problem is in VisualD 
installation which
doesn't set the path properly even though it recognizes where 
DMD is
installed. Hope the author takes a look at this problem so 
beginners

wanting to try D don't give up on a problem like this.


VS 2017 uses a "private" registry that the Visual D installer 
doesn't have access to. I'll change the registry location in 
the next release.


Please note that the next dmd installer will also detect VS2017 
and setup directories correctly in sc.ini: 
https://github.com/dlang/installer/pull/227


Today I saw that a new DMD version had been released. So I 
downloaded it (dmd-2.074.1.exe).


Unfortunately, the installer does *not* detect VS2017, instead it 
asks me to install VS2013 for x64 support.


Re: DMD VS2017 Support

2017-05-24 Thread Jolly James via Digitalmars-d
On Wednesday, 24 May 2017 at 03:21:56 UTC, Vladimir Panteleev 
wrote:

On Tuesday, 23 May 2017 at 23:11:30 UTC, Jolly James wrote:
Come one, let's be ones: If DMD has no x64 linker, VS 
integration is not a bit optional.


Unlike some other operating systems, 64-bit Windows versions 
can run 32-bit software just fine. If you require targeting 
Win64 (or the Microsoft C runtime), that is specific to your 
use case.


That's true. But when D's GC does not trigger early enough, my 
program runs out of memory (due to the 2 GB limit of 32 bit 
process), x64 solves this more or less. As a side note: I am 
talking about allocating huge arrays.



And, again, Visual Studio is not required if you want to target 
Win64 - only the necessary toolchain components (linker and C 
runtime), which you can also obtain from an SDK.


So you are telling me "not working at all" is not worth 
releasing a fix? xD


Again, everything should be already working. We are talking 
about a convenience feature that automatically sets up the D 
compiler's configuration file, nothing more. That's all there 
is to the "integration". You can trivially do the same thing by 
hand, or set up your environment accordingly - all in a 
fraction of the time it took you to write these pointless 
complaints on this forum.


I admit, you are right in some points. Nevertheless, have you 
ever tried letting a novice configuring this stuff? The 'sc.ini' 
is neither easy to read nor logic. In my particular case I am 
overchallenged by this task.


Re: DMD VS2017 Support

2017-05-23 Thread Jolly James via Digitalmars-d

On Monday, 22 May 2017 at 23:58:37 UTC, Vladimir Panteleev wrote:
Additionally, Visual Studio integration is an optional feature 
of the Windows version, and of course VS2017 is just one 
supported version of VS.
Come one, let's be ones: If DMD has no x64 linker, VS integration 
is not a bit optional.


The scope of the problem may seem larger to you because you are 
affected by it personally, however at any point in time there 
may be any number of fixes queued for release of similar 
relative importance. Making an urgent release for every such 
occurrence would be impractical, if not impossible given the 
necessary work involved with making each new release.


So you are telling me "not working at all" is not worth releasing 
a fix? xD


Re: DMD VS2017 Support

2017-05-22 Thread Jolly James via Digitalmars-d

On Monday, 22 May 2017 at 07:28:23 UTC, Vladimir Panteleev wrote:

On Sunday, 21 May 2017 at 22:47:44 UTC, Jolly James wrote:

On Monday, 1 May 2017 at 18:30:53 UTC, Rainer Schuetze wrote:
Please note that the next dmd installer will also detect 
VS2017 and setup directories correctly in sc.ini: 
https://github.com/dlang/installer/pull/227


I really like this philosophy:
"It does not work, a fix is available, but it won't be rolled 
out (for now). Who cares about those who cannot use the broken 
software?"


Please don't antagonize volunteer contributors who are actually 
creating and improving things. We have a release process for a 
reason, we can't ship every single change immediately. If you 
require a solution urgently, use a workaround or build it from 
source yourself.


My message was neither addressed directly to anybody of the 
volunteer contributors (I have a huge respect of them and their 
great work), nor to anyone at the D Foundation directly. I just 
wanted to critize the whole release cycle stuff itself.


I mean, if for any circumstance, e.g. like the VS2017 thing 
(which did not suddenly appear from one day to another anyway), 
the whole software cannot be used without larger fiddling (in 
this case: setting up NSIS + plugins), it seems quite strange to 
not simply update the installer, which would be a work for a few 
minutes - and after that everybody would be happy.
But to be honest, I don't think that this is a problem of D. More 
or less, this is something that appears everywhere in the world 
of open-source. Here it annoys and chases away users, in the 
corporate sector you could not do so, as this would cause the 
company's ruin.


Re: DMD VS2017 Support

2017-05-21 Thread Jolly James via Digitalmars-d

On Monday, 1 May 2017 at 18:30:53 UTC, Rainer Schuetze wrote:
Please note that the next dmd installer will also detect VS2017 
and setup directories correctly in sc.ini: 
https://github.com/dlang/installer/pull/227


I really like this philosophy:
"It does not work, a fix is available, but it won't be rolled out 
(for now). Who cares about those who cannot use the broken 
software?"


Re: DMD 2.074.0

2017-05-04 Thread Jolly James via Digitalmars-d

On Thursday, 4 May 2017 at 16:43:27 UTC, jj wrote:

the installer does not work for VS 2017 - that sucks!!!


see also: 
https://forum.dlang.org/post/oe7usu$bvf$1...@digitalmars.com


String Comparison Operator

2017-04-30 Thread Jolly James via Digitalmars-d-learn

Is there a String Comparison Operator in D?


Re: DMD VS2017 Support

2017-04-20 Thread Jolly James via Digitalmars-d

On Thursday, 20 April 2017 at 17:10:05 UTC, Meta wrote:

On Thursday, 20 April 2017 at 17:06:15 UTC, Mike Parker wrote:

On Thursday, 20 April 2017 at 14:44:54 UTC, Meta wrote:

On Thursday, 20 April 2017 at 14:29:28 UTC, Jolly James wrote:
What has the DMD compiler to do with a VS plugin that I am 
not using?


You said in your original post "DMD installer only offers to 
install VS2013". This isn't the DMD installer but the Visual 
D installer that installs the plugin for the appropriate 
version of Visual Studio. As Mike said, though, you can also 
just edit sc.ini if you don't want to use Visual D.


It actually does offer to install both VS 2013 and Visual D.


Wow, I did not know that. Seems a little excessive.


But anyway, that's how it is.

By the way: installing VS2013 is only offered to you, if no 
compatible version (atm VS2015 or older) is found on your machine.


Re: DMD VS2017 Support

2017-04-20 Thread Jolly James via Digitalmars-d

On Thursday, 20 April 2017 at 05:02:37 UTC, Mike Parker wrote:

On Thursday, 20 April 2017 at 04:58:55 UTC, Mike Parker wrote:

[...]


I should add that Mike's suggestion to edit sc.ini should do 
the trick, but I find it convenient to have both toolsets 
installed.


I'll give it a try, thanks to you and Mike J.! 


Re: DMD VS2017 Support

2017-04-20 Thread Jolly James via Digitalmars-d

On Thursday, 20 April 2017 at 00:13:29 UTC, Meta wrote:

On Wednesday, 19 April 2017 at 20:47:51 UTC, Jolly James wrote:

[...]


Please ignore Mike's answer. Visual D is maintained by Rainers 
Schuetze and is hosted here[1] on github. From the readme:


For more information on installation, a quick tour of Visual D 
with some screen shots and feedback, please visit the project 
home for Visual D at 
http://rainers.github.io/visuald/visuald/StartPage.html.


There's a forum dedicated to IDE discussions 
(http://forum.dlang.org/group/digitalmars.D.ide), where you can 
leave your comments and suggestions. Bug reports can be filed 
to the D bugzilla database for Component VisualD.


Have fun, Rainer Schuetze

1. https://github.com/dlang/visuald


What has the DMD compiler to do with a VS plugin that I am not 
using?


Re: DMD VS2017 Support

2017-04-19 Thread Jolly James via Digitalmars-d
I cannot even fix it myself because DMD is looking for 
"bin\link.exe". But with VS2017 the path would actually be 
something like "\bin\HostX64\x64".


The lost Group

2017-04-19 Thread Jolly James via Digitalmars-d
https://forum.dlang.org/group/D does not appear in the forum's 
index or sidebar.


DMD VS2017 Support

2017-04-19 Thread Jolly James via Digitalmars-d
DMD does not support VS2017. Therefore I cannot link x64 
applications. DMD installer only offers to install VS2013 (what I 
am absolutely not going to do, as that would be a real shame with 
the disk space it consumes).


Any plans for supporting VS2017?


Re: Howto catch SocketOSException?

2017-03-27 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 21:57:29 UTC, Jolly James wrote:

On Sunday, 26 March 2017 at 18:50:13 UTC, bauss wrote:

[...]


If you want try to help me, mabye this helps you:
https://github.com/CyberShadow/ae/blob/master/net/asockets.d#L1237


Finally found the bug: I had a logical error in the way how I 
used this code.


Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 18:50:13 UTC, bauss wrote:

On Sunday, 26 March 2017 at 11:46:39 UTC, Jolly James wrote:

[...]


Chances are it's invoked in another thread and thus you can't 
catch it like that.


To sum it up.

Ex.

void thisFunctionThrows() { ... }

void ableToCatch() {
try {
thisFunctionThrows();
}
catch (Exception e) {
// We can catch the exception ...
}
}

void notAbleToCatch() {
try {
spawn();
}
catch (Exception e) {
// We cannot catch the exception ...
}
}

void ableToCatchToo() {
spawn(); // We're able to handle the exception, 
because the try/catch is handled in the thread that calls the 
function that throws.

}


If you want try to help me, mabye this helps you:
https://github.com/CyberShadow/ae/blob/master/net/asockets.d#L1237


Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 11:35:00 UTC, Jolly James wrote:

On Sunday, 26 March 2017 at 02:41:46 UTC, Adam D. Ruppe wrote:

On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote:
You can ignore the loop()-method. It is not called as the 
application will never reach this statement, because it 
cannot, because it crashes already in the listen()-method in 
consequence of the exception that does not get caught by the 
try-catch block.


Try putting it in the try anyway and see what happens.

It is an async socket library, they can do weird things.\


Unfortunately not working either. I should not forget to 
mention that the exception also raises when the code does not 
contain the loop()-call.


Found out something: You cannot catch any exception thrown in the 
listen()-method in general.



■ Original code:
auto addressInfos = getAddressInfo(addr, to!string(port), 
AddressInfoFlags.PASSIVE, SocketType.STREAM, ProtocolType.TCP);



■ Modified one:

AddressInfo[] addressInfos;

try
{
	addressInfos = getAddressInfo(addr, to!string(port), 
AddressInfoFlags.PASSIVE, SocketType.STREAM, ProtocolType.TCP);

}
catch(SocketOSException e)
{
throw new Exception("Invalid address: " ~ addr, e);
}



■ Not working try-catch:

try
{
tcp.listen(2345, "127.0.0.1c");
socketManager.loop();
}
catch (Exception e)
{
return;
}


Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 02:41:46 UTC, Adam D. Ruppe wrote:

On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote:
You can ignore the loop()-method. It is not called as the 
application will never reach this statement, because it 
cannot, because it crashes already in the listen()-method in 
consequence of the exception that does not get caught by the 
try-catch block.


Try putting it in the try anyway and see what happens.

It is an async socket library, they can do weird things.\


Unfortunately not working either. I should not forget to mention 
that the exception also raises when the code does not contain the 
loop()-call.


Re: Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 01:22:24 UTC, bauss wrote:

On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote:

[...]


This part:
catch (std.socket.SocketOSException e)

[...]


[...]


I know that inheritance stuff, but none (!) of them catches that 
strange exception either. You can ignore the loop()-method. It is 
not called as the application will never reach this statement, 
because it cannot, because it crashes already in the 
listen()-method in consequence of the exception that does not get 
caught by the try-catch block.



std.socket.SocketOSException@std\socket.d(975): getaddrinfo 
error: Unknow host.


	0x004205BE in pure @safe bool 
std.exception.enforce!(bool).enforce(bool, lazy object.Throwable)
	0x0040D3A2 in @trusted std.socket.AddressInfo[] 
std.socket.getAddressInfo!(immutable(char)[], 
std.socket.AddressInfoFlags, std.socket.SocketType, 
std.socket.ProtocolType).getAddressInfo(const(char[]), 
immutable(char)[], std.socket.AddressInfoFlags, 
std.socket.SocketType, std.socket.ProtocolType).__lambda7()
	0x0040D37B in @safe std.socket.AddressInfo[] 
std.socket.getAddressInfo!(immutable(char)[], 
std.socket.AddressInfoFlags, std.socket.SocketType, 
std.socket.ProtocolType).getAddressInfo(const(char[]), 
immutable(char)[], std.socket.AddressInfoFlags, 
std.socket.SocketType, std.socket.ProtocolType) at 
C:\dlang\dmd2\windows\bin\..\..\src\phobos\std\socket.d(945)
	0x00404DAF in ushort ae.net.asockets.TcpServer.listen(ushort, 
immutable(char)[]) at C:\Users\jolly\src\ae\net\asockets.d(1242)

0x00416749 in _Dmain at C:\Users\jolly\src\app.d(48)
	0x00423597 in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
	0x0042355B in void rt.dmain2._d_run_main(int, char**, extern 
(C) int function(char[][])*).runAll()

0x0042345C in _d_run_main
0x00417D74 in main at C:\Users\jolly\src\ae\net\asockets.d(7)
0x00443EBD in mainCRTStartup
0x757362C4 in BaseThreadInitThunk
0x773C0FD9 in RtlSubscribeWnfStateChangeNotification
0x773C0FA4 in RtlSubscribeWnfStateChangeNotification


↑ stacktrace


Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn

How do you catch an std.socket.SocketOSException?


The following does not work, as the exception occurs anyway and 
leads to a crash:



import ae.net.asockets;

void main(string[] args)
{
TcpServer tcp = new TcpServer();

try
{
tcp.listen(2345, "127.0.0.1c");
// '...c' makes the IP address invalid
}
catch (std.socket.SocketOSException e)
{
return;
}
catch (Exception e)
{
return;
}

socketManager.loop();
}


Output:
std.socket.SocketOSException@std\socket.d(975): getaddrinfo 
error: Unknown Host


Re: About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 17:57:31 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 22 February 2017 at 17:53:21 UTC, Jolly James 
wrote:

No matter how I try, I am always getting:
Error: none of the overloads of '__ctor' are callable using 
argument types (Data*), candidates are: (my-project)


I don't know the library, so I'd have to see the Data class, 
but you might just be using  when you should be using 
plain data.


Silly me!
Now I used Xamarin's Find-Usage-Feature, found one usage in ae 
and realized that there is no reason for using the keyword `new`, 
as Data is a struct (and so one does not need `new` unlike in C#) 
...


Re: About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 22 February 2017 at 17:06:51 UTC, Jolly James wrote:
On Wednesday, 22 February 2017 at 17:01:11 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 22 February 2017 at 16:55:03 UTC, Jolly James 
wrote:
Well, what are these void-arrays for real? I mean, they 
contain data what does not make them really void, does it?


They represent an array of anything; the user can pass ubyte[] 
to it, or int[] to it, or char[] to it, or anything else (even 
string if it is in void[] or const void[]).



And how to I get received data out of Data.content[]?
How to use TcpConnection.send()? E.g. for sending a string?


Cast it to `const(ubyte)[]` then use it as a bag of bytes. 
That's almost always what you want to do inside.


The function signature uses `in void[]` instead of `ubyte[]` 
because void will accept strings and other stuff too, whereas 
ubyte specifically requires it to be typed as bye.


You want to use it INTERNALLY as bytes, but the external 
interface can accept almost anything.


Thank you very much!
Now it makes sense and I understand.


But I have one problem: How to use the constructor of the Data 
class?


No matter how I try, I am always getting:
Error: none of the overloads of '__ctor' are callable using 
argument types (Data*), candidates are: (my-project)


Re: About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 17:01:11 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 22 February 2017 at 16:55:03 UTC, Jolly James 
wrote:
Well, what are these void-arrays for real? I mean, they 
contain data what does not make them really void, does it?


They represent an array of anything; the user can pass ubyte[] 
to it, or int[] to it, or char[] to it, or anything else (even 
string if it is in void[] or const void[]).



And how to I get received data out of Data.content[]?
How to use TcpConnection.send()? E.g. for sending a string?


Cast it to `const(ubyte)[]` then use it as a bag of bytes. 
That's almost always what you want to do inside.


The function signature uses `in void[]` instead of `ubyte[]` 
because void will accept strings and other stuff too, whereas 
ubyte specifically requires it to be typed as bye.


You want to use it INTERNALLY as bytes, but the external 
interface can accept almost anything.


Thank you very much!
Now it makes sense and I understand.


Re: Class Order Style

2017-02-22 Thread Jolly James via Digitalmars-d-learn
On Tuesday, 21 February 2017 at 23:06:23 UTC, Jonathan M Davis 
wrote:
On Tuesday, February 21, 2017 22:41:40 Lenny Lowood via 
Digitalmars-d-learn wrote:

[...]


It's completely a stylistic preference. There are a number of 
different ways to order your member variables and functions, 
and there are several different ways to apply attributes to 
them.


[...]


thank you!


About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn
For sure, some might know ae. I am trying to use it as TcpServer. 
I got almost everything working fine concerning connection 
establishment and disconnecting. But there is one thing that 
makes it hard for me to understand, how to handle data.


https://github.com/CyberShadow/ae/blob/master/net/asockets.d

Well, what are these void-arrays for real? I mean, they contain 
data what does not make them really void, does it?


And how to I get received data out of Data.content[]?
How to use TcpConnection.send()? E.g. for sending a string?


Re: Class Order Style

2017-02-20 Thread Jolly James via Digitalmars-d-learn

On Monday, 20 February 2017 at 13:50:26 UTC, ketmar wrote:
just add ddoc documentation to 'em, and then it doesn't matter 
in which order they are declared: people will generate 
documentation to find out how to use your code. ;-)


ah okay, thx


But what about this?


class A
{
private:
   int a;
   int b;
public:
   int c;
   int d;
}

or

class A
{
   private
   {
   int a;
   int b;
   }
   public
   {
   int c;
   int d;
   }
}


Class Order Style

2017-02-20 Thread Jolly James via Digitalmars-d-learn

How to sort the members of a class?

like:

1. properties
then
2. private 3. methods
4. ctors

... and so on. are there any recommendations?


And what is better?


class A
{
private:
   int a;
   int b;
public:
   int c;
   int d;
}

or

class A
{
   private
   {
   int a;
   int b;
   }
   public
   {
   int c;
   int d;
   }
}