Re: Bug with writeln?

2018-09-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 9, 2018 8:30:12 AM MDT Saurabh Das via Digitalmars-d-
learn wrote:
> Thank you for explaining all this.
>
> It is frustrating because the behaviour is very counterintuitive.
>
> I will use a workaround for now.

Ranges are fantastic, and the basic concept is solid, but a number of the
implementation details really weren't worked out well enough in the
beginning, which means that there's a lot of stuff that works reasonably
well with ranges but falls apart on some level in certain circumstances -
and what happens when ranges get copied is a big part of that.

On some level, it's what we get for being the first language to really
implement ranges as part of its standard library. As I understand it, Andrei
didn't create the concept, but AFAIK, it wasn't implemented on any real
scale by anyone prior to them being added to Phobos. And when you're the
first to implement something, you often screw it up on some level. With many
things, D was able to learn from C++ and improve, but this is an area where
we got to make new mistakes. The result is something that's extremely useful
and largely works but which has some problematic corner cases that really
shouldn't be there.

- Jonathan M Davis





Re: [vibe-d/dub] Lin

2018-09-10 Thread Martin Tschierschke via Digitalmars-d-learn

On Friday, 7 September 2018 at 16:37:18 UTC, MamoKupe wrote:

On Friday, 7 September 2018 at 16:20:40 UTC, MamoKupe wrote:

marcinan@marcinan-PC ~/Pulpit/d $ dub init bibe
Package recipe format (sdl/json) [json]: d
Invalid format, "d", enter either "sdl" or "json".
Package recipe format (sdl/json) [json]:
Name [bibe]:
Description [A minimal D application.]:
Author name [Marcin]:
License [proprietary]:
Copyright string [Copyright © 2018, Marcin]:
Add dependency (leave empty to skip) []: vibe-d
Added dependency vibe-d ~>0.8.4



/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
/usr/bin/dmd failed with exit code 1.

On linux Mint with DUB version 1.11.0, built on Sep  1 2018



sudo apt-get install libssl-dev

Solved linking problem for now.


Yes, but this should be detected by dub before compilation as a 
missing dependency not after.
Someone told, that is is possible by adding the right params to 
dub.sdl/.json.
As an traditional error most "lets try vibe.d"-people see, I 
would like to ask for changing this.


Regards mt.


Re: GTKD for android?

2018-09-10 Thread Joakim via Digitalmars-d-learn
On Saturday, 8 September 2018 at 02:59:48 UTC, Josphe Brigmo 
wrote:
I have an app I'm writing using GtkD on windows. Eventually I'd 
like to port it to android. Since I have never been able to 
actually get anything to work on android I'm curious if there 
are any demos with gtkD for android? I'm wondering if I just 
scrap the idea of using it because it won't port without a ton 
of work. Ideally I'd like to just cross compile and it all work 
out except for a few bugs.


The GtkD maintainer said a couple years ago he might try it when 
the Android support was better:


https://forum.dlang.org/post/o4rq0i$dur$1...@digitalmars.com

I don't think anyone's tested it yet, do you know if Gtk supports 
Android well?


The DlangUI maintainer did get his GUI library working on 
Android, as James mentioned:


https://forum.dlang.org/thread/cdekkumjynhqoxvmg...@forum.dlang.org


DlangUI and android

2018-09-10 Thread Josphe Brigmo via Digitalmars-d-learn
Is there an emulator that can run the apks? Android emulator does 
not work, I suppose, because it isn't java. Complains about a 
missing classes.dex file.


I'd rather have an emulator version if possible for quicker dev.


Re: Is there websocket client implementation for D

2018-09-10 Thread Heromyth via Digitalmars-d-learn

On Tuesday, 24 March 2015 at 17:55:38 UTC, Ilya Korobitsyn wrote:

Hello!

Is there any websocket client implementation in D?
I know there is WS server as a part of vibe.d, but it does not 
seem to include client.

Maybe there are some library bindings that I've missed?



We just implemented one in D.
See 
https://github.com/huntlabs/hunt-http/tree/master/examples/WebSocketDemo




dub doesn't work with dmd 1:2.082.0-1.0?

2018-09-10 Thread SuperPrower via Digitalmars-d-learn
dub was working nice until I updated my system (I run 
ArchLinux32) just now. dmd was updated from version 1:2.081.2-1.0 
to 1:2.082.0-1.0 (according to pacman package manager). After 
that, I couldn't invoke dub for anything. Here is the attempt to 
run `dub --vverbose`:


```
Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at 
/var/lib/dub/packages/local-packages.json
Looking for local package map at 
/home/superprower/.dub/packages/local-packages.json
Try to load local package map at 
/home/superprower/.dub/packages/local-packages.json

iterating dir /home/superprower/.dub/packages/
iterating dir /home/superprower/.dub/packages/ entry 
ncurses-master
iterating dir /home/superprower/.dub/packages/ entry 
local-packages.json
iterating dir /home/superprower/.dub/packages/ entry 
d-profile-viewer-1.1.3

No package found in current working directory.
Failed to invoke the compiler /usr/bin/dmd to determine the build 
platform: Error: missing or null command line arguments


Full exception: 
object.Exception@source/dub/compilers/compiler.d(127): Failed to 
invoke the compiler /usr/bin/dmd to determine the build platform: 
Error: missing or null command line arguments



??:? pure @safe bool 
std.exception.enforce!().enforce!(bool).enforce(bool, lazy 
const(char)[], immutable(char)[], uint) [0xa744bd]
??:? dub.platform.BuildPlatform 
dub.compilers.compiler.Compiler.probePlatform(immutable(char)[], 
immutable(char)[][], immutable(char)[]) [0x80759e]
??:? dub.platform.BuildPlatform 
dub.compilers.dmd.DMDCompiler.determinePlatform(ref 
dub.compilers.buildsettings.BuildSettings, immutable(char)[], 
immutable(char)[]) [0x81323f]

??:? [0x810de2]
??:? void 
dub.commandline.PackageBuildCommand.setupPackage(dub.dub.Dub, 
immutable(char)[], immutable(char)[]) [0x910e46]
??:? int dub.commandline.GenerateCommand.execute(dub.dub.Dub, 
immutable(char)[][], immutable(char)[][]) [0x92b158]
??:? int dub.commandline.RunCommand.execute(dub.dub.Dub, 
immutable(char)[][], immutable(char)[][]) [0x92b0ab]
??:? int dub.commandline.runDubCommandLine(immutable(char)[][]) 
[0x9f87e3]

??:? _Dmain [0x9fe3bf]
```

I downgraded dmd for now, but what may be the cause of this? I 
couldn't find anything related to this particular error (`missing 
or null command line arguments`).


Re: traits getOverload of a template method

2018-09-10 Thread Timoses via Digitalmars-d-learn

On Thursday, 6 February 2014 at 23:06:03 UTC, QAston wrote:

How do i get aliases to overloads of a template method like

Class A
{
int a(T)(T tq,T tw);
int a(T)(T tq);
}
__traits(getOverloads, A, "a(int)")doesnt work


Is there any way to "select" overloaded template functions?

I require to select one of `std.bitmanip.peek`

import std.bitmanip : peek;
import std.system : Endian;
alias myPeek = peek!(int, Endian.bigEndian, 
immutable(ubyte)[]);


Error:
template std.bitmanip.peek matches more than one template 
declaration:
/dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(3269): 
peek(T, Endian endianness = Endian.bigEndian, R)(R range) if 
(canSwapEndianness!T && isForwardRange!R && is(ElementType!R : 
const(ubyte)))

and
/dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(3306): 
peek(T, Endian endianness = Endian.bigEndian, R)(R range, size_t* 
index) if (canSwapEndianness!T && isForwardRange!R && 
hasSlicing!R && is(ElementType!R : const(ubyte)))


How to "select" one?


Re: traits getOverload of a template method

2018-09-10 Thread aliak via Digitalmars-d-learn

On Monday, 10 September 2018 at 12:57:25 UTC, Timoses wrote:

On Thursday, 6 February 2014 at 23:06:03 UTC, QAston wrote:

[...]


Is there any way to "select" overloaded template functions?

I require to select one of `std.bitmanip.peek`

import std.bitmanip : peek;
import std.system : Endian;
alias myPeek = peek!(int, Endian.bigEndian, 
immutable(ubyte)[]);


Error:
template std.bitmanip.peek matches more than one template 
declaration:

/dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(3269):
  peek(T, Endian endianness = Endian.bigEndian, R)(R range) if 
(canSwapEndianness!T && isForwardRange!R && is(ElementType!R : 
const(ubyte)))

and
/dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(3306):
  peek(T, Endian endianness = Endian.bigEndian, R)(R range, 
size_t* index) if (canSwapEndianness!T && isForwardRange!R && 
hasSlicing!R && is(ElementType!R : const(ubyte)))


How to "select" one?


Can you either:

alias myPeek = () => peek!(int, Endian.bigEndian, 
immutable(ubyte)[])();

Or
alias myPeek = (size_t *index) => peek!(int, Endian.bigEndian, 
immutable(ubyte)[])(index);


??


Re: traits getOverload of a template method

2018-09-10 Thread aliak via Digitalmars-d-learn

On Monday, 10 September 2018 at 13:46:08 UTC, aliak wrote:

On Monday, 10 September 2018 at 12:57:25 UTC, Timoses wrote:


How to "select" one?


Can you either:

alias myPeek = () => peek!(int, Endian.bigEndian, 
immutable(ubyte)[])();

Or
alias myPeek = (size_t *index) => peek!(int, Endian.bigEndian, 
immutable(ubyte)[])(index);


??


With the Range arg as well of course.


Re: Making mir.random.ndvariable.multivariateNormalVar create bigger data sets than 2

2018-09-10 Thread 9il via Digitalmars-d-learn

On Tuesday, 27 February 2018 at 09:23:49 UTC, kerdemdemir wrote:

I need a classifier in my project.
Since it is I believe most easy to implement I am trying to 
implement logistic regression.


[...]


Mir Random v1.0.0 has new `range` overloads that can work 
NdRandomVariable.

Example: https://run.dlang.io/is/jte3gx


Re: Process in parallel and output result to stdout theread-safely

2018-09-10 Thread Dr.No via Digitalmars-d-learn

On Saturday, 8 September 2018 at 14:26:45 UTC, ag0aep6g wrote:

On 09/03/2018 08:13 PM, Dr.No wrote:

But it in the middle of output, I got output like this:

outjson = {"barCode":"20","ade":"20"}♪◙outjson = 
{"barCode":"X21","ade":"21"}


also there's that extra ♪◙ character. Thos sounds memory 
violation somewhere.
This only happens when using parallel. Any guess what's 
possibily happeing?


If that only ever happens at line breaks, then that doesn't 
necessarily look like memory corruption to me.


Yes, it does only happens at line breaks. I hadn't realized that 
until you mentioned. It does gets in place of \r and \n, that's 
why there's all in one line when this happens. Thankfor for the 
notice.


I looked around a bit and found code page 437 [1]. It has those 
characters at 0xD and 0xA which is where ASCII has \r and \n. 
So it might be that code page 437 is used when displaying that 
particular entry. Why that would happen, I have no idea.


So I guessed that something changed the console code page. I've 
tried to call call chcp 65001 at program's start up. Not worked. 
Tried inside the main loop. Also not worked.


To get better help, you should post a complete test case that 
people can just copy/paste. That includes imports, a `main` 
function, and the command you use to compile. Also add 
information about your environment (OS, compiler version).




I made a reduced version where you can do just dmd -run hello.d. 
The application does convert alot of PDF files to text then do 
some parsing (I've removed this not needed part). In my code, at 
iteration 28 I got those character (♪◙), which is the error. I 
hope you can reproduce this error on your machine as well. I got 
some PDF files and duplicated them just for testing purpose. If 
for some reason you didn't get the same error immediately, try 
duplicate the PDFs and try again. I believe this can reproduce 
the erro.



Here's the resources to compile the application:

source code: https://pastebin.com/RwrUikQS
PDF files + pdf to text application: 
https://drive.google.com/file/d/1uKjJX4pQIEWVK4vujUsm0ln2yHS7z5ZZ/view?usp=sharing

OS: Windows 10 64-bit
compiler: DMD32 D Compiler v2.080.0 (same issue happens on ldc)
command line: dmd -run hello.d

Thank you very much for your time.