Re: Why any! with map! is not working here

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 6, 2019 10:21:39 PM MDT rnd via Digitalmars-d-learn wrote: > On Thursday, 6 June 2019 at 21:32:11 UTC, Jonathan M Davis wrote: > > If any is not given a predicate, it defaults to just checking > > whether the element itself is true (requiring that the element > > be bool), which

Re: Using python in D

2019-06-06 Thread rnd via Digitalmars-d-learn
On Friday, 7 June 2019 at 04:39:14 UTC, rikki cattermole wrote: On 07/06/2019 3:54 PM, rnd wrote: How should I 'initialize python' ? The example is probably a good place to begin. https://github.com/ariovistus/pyd/blob/master/examples/simple_embedded/hello.d Thanks for the link. After

Re: Using python in D

2019-06-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/06/2019 3:54 PM, rnd wrote: Edit: I tried above D program and got following error: core.exception.AssertError@/home/abcde/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/embedded.d(53): python not initialized ??:? _d_assert_msg [0x5562d3f3c466]

Re: Why any! with map! is not working here

2019-06-06 Thread rnd via Digitalmars-d-learn
On Thursday, 6 June 2019 at 21:32:11 UTC, Jonathan M Davis wrote: If any is not given a predicate, it defaults to just checking whether the element itself is true (requiring that the element be bool), which is why Marco's suggestion works, but it's a rather odd way to write the code and will

Re: Using python in D

2019-06-06 Thread rnd via Digitalmars-d-learn
Edit: I tried above D program and got following error: core.exception.AssertError@/home/abcde/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/embedded.d(53): python not initialized ??:? _d_assert_msg [0x5562d3f3c466]

Using python in D

2019-06-06 Thread rnd via Digitalmars-d-learn
I have a simple python script file which contains following 3 statements: import pandas df = pandas.read_csv('testfile.csv') print(df[0:3]) Can I incorporate above in a D program? I see there is pyd package for using python in D: https://code.dlang.org/packages/pyd Will following program

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 6, 2019 2:52:42 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 6/6/19 4:49 PM, Steven Schveighoffer wrote: > > Oh wait! It's not empty, it has an empty string as a single member! > > That's definitely a bug. > > OK, not a bug, but not what I would have expected.

Re: Why any! with map! is not working here

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 6, 2019 5:50:36 AM MDT rnd via Digitalmars-d-learn wrote: > On Thursday, 6 June 2019 at 09:49:28 UTC, Jonathan M Davis wrote: > > So, to start, the any portion should be something more like > > > > any!pred(ss); > > > > or > > > > ss.any!pred(); > > > > or > > > > ss.any!pred; >

Re: Why this fails when using unittest?

2019-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/19 1:49 PM, Adam D. Ruppe wrote: On Thursday, 6 June 2019 at 17:40:17 UTC, Machine Code wrote: outside an unittest, this compiles fine: struct A try making it `static struct` instead cannot implicitly convert expression "hehe" of type string to A Why does inside a unittest it

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/19 4:49 PM, Steven Schveighoffer wrote: Oh wait! It's not empty, it has an empty string as a single member! That's definitely a bug. OK, not a bug, but not what I would have expected. From docs: "If T isn't a struct, class, or union, an expression tuple with an empty string is

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/19 4:43 PM, Steven Schveighoffer wrote: On 6/6/19 4:22 PM, Amex wrote: FieldNameTuple!T std.traits.Fields!T are non-empty when T is an interface! An interface cannot contain fields and yet these return non-zero and screws up my code. While I can filter for interfaces it makes me

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/19 4:22 PM, Amex wrote: FieldNameTuple!T std.traits.Fields!T are non-empty when T is an interface! An interface cannot contain fields and yet these return non-zero and screws up my code. While I can filter for interfaces it makes me wonder what else may slip through? Is it a bug or

Re: FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 June 2019 at 20:22:26 UTC, Amex wrote: Is it a bug or what is going on? my suspicion is it is actually the pointer to the vtable getting caught up in it but idk, i didn't really look, just guessing.

Re: typeid, typeinfo, classinfo not returning most derived

2019-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 June 2019 at 20:22:00 UTC, Amex wrote: I i = new D(); It is a bizarre quirk, I think because interfaces do not necessarily point to objects with RTTI (though this can be statically determined, so I am not sure that is valid), but when you do typeid on an interface, it gives

FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

2019-06-06 Thread Amex via Digitalmars-d-learn
FieldNameTuple!T std.traits.Fields!T are non-empty when T is an interface! An interface cannot contain fields and yet these return non-zero and screws up my code. While I can filter for interfaces it makes me wonder what else may slip through? Is it a bug or what is going on?

typeid, typeinfo, classinfo not returning most derived

2019-06-06 Thread Amex via Digitalmars-d-learn
- x 0x004b71e0 {Interface for main.I} {m_init={length=0 ptr=0x}, name="main.I", vtbl={length=0 ptr=0x}, ...} object.TypeInfo_Class {TypeInfo_Class} [TypeInfo_Class]D0006: Error: Type resolve failed m_init {length=0 ptr=0x}

Re: Why this fails when using unittest?

2019-06-06 Thread Machine Code via Digitalmars-d-learn
On Thursday, 6 June 2019 at 17:40:17 UTC, Machine Code wrote: outside an unittest, this compiles fine: struct A { enum A foo = "hehe"; this(string a) { m_a = a; } alias m_a this; string m_a; } but if you

Re: Why this fails when using unittest?

2019-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 June 2019 at 17:40:17 UTC, Machine Code wrote: outside an unittest, this compiles fine: struct A try making it `static struct` instead cannot implicitly convert expression "hehe" of type string to A Why does inside a unittest it doesn't work? the constructor

Why this fails when using unittest?

2019-06-06 Thread Machine Code via Digitalmars-d-learn
outside an unittest, this compiles fine: struct A { enum A foo = "hehe"; this(string a) { m_a = a; } alias m_a this; string m_a; } but if you wrap this a unittest {} and compile with dmd -unittest -run

Re: Why any! with map! is not working here

2019-06-06 Thread rnd via Digitalmars-d-learn
On Thursday, 6 June 2019 at 09:49:28 UTC, Jonathan M Davis wrote: So, to start, the any portion should be something more like any!pred(ss); or ss.any!pred(); or ss.any!pred; where pred is whatever the predicate is. Apparently, following also works: any(ss.map!(a => a > 127)) // as

Re: Reading .pem files for secured

2019-06-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 6 June 2019 at 11:08:18 UTC, Dukc wrote: We were both wrong :-). It turned out that the correct way to initialize a SecureD RSA private key is to feed contents of .pem in without ANY processing. Ah, they made it even easier :)

Re: Reading .pem files for secured

2019-06-06 Thread Dukc via Digitalmars-d-learn
On Friday, 31 May 2019 at 12:17:14 UTC, Sebastiaan Koppe wrote: On Friday, 31 May 2019 at 10:35:46 UTC, Dukc wrote: But then came a problem that I need to feed the key from .pem to initialize RSA class. Just base64 decode the PEM data (without the ) and feed it to RSA.this(ubyte[]

Re: Get module file path from ModuleInfo

2019-06-06 Thread Andre Pany via Digitalmars-d-learn
On Thursday, 6 June 2019 at 10:16:17 UTC, Jacob Carlborg wrote: On Thursday, 6 June 2019 at 04:20:52 UTC, Andre Pany wrote: Hi, I want to enhance a unittest framework to also report the results in SonarQube Generic Execution format. This format lists the file paths. The unittest framework

Re: Get module file path from ModuleInfo

2019-06-06 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 6 June 2019 at 04:20:52 UTC, Andre Pany wrote: Hi, I want to enhance a unittest framework to also report the results in SonarQube Generic Execution format. This format lists the file paths. The unittest framework loops through the modules and collects the module name and the

Re: Why any! with map! is not working here

2019-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 6, 2019 3:01:11 AM MDT rnd via Digitalmars-d-learn wrote: > I am trying to check if any character in the string is > 127 by > following function: > > import std.algorithm.searching; > import std.algorithm.iteration; > bool isBinary(char[] ss){ >return (any!(map!(a => a >

Why any! with map! is not working here

2019-06-06 Thread rnd via Digitalmars-d-learn
I am trying to check if any character in the string is > 127 by following function: import std.algorithm.searching; import std.algorithm.iteration; bool isBinary(char[] ss){ return (any!(map!(a => a > 127)(ss))); } However, I am getting this error: Error: variable ss cannot be read at

Re: Not able to use this C++ library in D

2019-06-06 Thread Kagamin via Digitalmars-d-learn
You should declare methods too, see example https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d