why `top` report is not consistent with the memory freed by core.stdc.stdlib : free?

2020-11-05 Thread mw via Digitalmars-d-learn

Hi,

I'm trying this:

https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation

using core.stdc.stdlib : malloc and free to manually manage 
memory, I tested two scenarios:


-- malloc & free
-- malloc only

and I use Linux command `top` to check the memory used by the 
program, there is no difference in this two scenarios.


I also tried to use `new` to allocate the objects, and GC.free(). 
The memory number reported by `top` is much less than those 
reported by using core.stdc.stdlib : malloc and free.



I'm wondering why? shouldn't core.stdc.stdlib : malloc and free 
be more raw (low-level) than new & GC.free()? why `top` shows 
stdlib free() is not quite working?


thanks.


Vibe.d build on LDC error

2020-11-05 Thread Vino via Digitalmars-d-learn

Hi All,

  When we try to build vide.d using ldc (dub build) we are 
getting the below error, openssl is already been installed 
(OpenSSL 1.0.2j-fips  26 Sep 2016), hence request your help on 
the same.


openssl.d:84: error: undefined reference to 'OPENSSL_init_ssl'
openssl.d:121: error: undefined reference to 'OPENSSL_sk_num'
openssl.d:128: error: undefined reference to 'OPENSSL_sk_value'
openssl.d:243: error: undefined reference to 'BIO_set_init'
openssl.d:244: error: undefined reference to 'BIO_set_data'
openssl.d:245: error: undefined reference to 'BIO_set_shutdown'
openssl.d:1382: error: undefined reference to 'BIO_get_new_index'
openssl.d:1382: error: undefined reference to 'BIO_meth_new'
openssl.d:1384: error: undefined reference to 'BIO_meth_set_write'
openssl.d:1385: error: undefined reference to 'BIO_meth_set_read'
openssl.d:1386: error: undefined reference to 'BIO_meth_set_ctrl'
openssl.d:1387: error: undefined reference to 
'BIO_meth_set_create'
openssl.d:1388: error: undefined reference to 
'BIO_meth_set_destroy'
openssl.d:899: error: undefined reference to 
'BN_get_rfc3526_prime_2048'

openssl.d:1288: error: undefined reference to 'BIO_set_init'
openssl.d:1290: error: undefined reference to 'BIO_set_data'
openssl.d:1298: error: undefined reference to 'BIO_get_shutdown'
openssl.d:1300: error: undefined reference to 'BIO_set_init'
openssl.d:1302: error: undefined reference to 'BIO_set_data'
openssl.d:1309: error: undefined reference to 'BIO_get_data'
openssl.d:1323: error: undefined reference to 'BIO_get_data'
openssl.d:1339: error: undefined reference to 'BIO_get_shutdown'
openssl.d:1342: error: undefined reference to 'BIO_set_shutdown'
openssl.d:1335: error: undefined reference to 'BIO_get_data'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1
/Project/dlang/ldc-1.24.0/bin/ldc2 failed with exit code 1.

From,
Vino.B


Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-05 Thread Vino via Digitalmars-d-learn

Hi All,

  We recently tested the below components and the test results 
are as below, even though hunt-database is faster than 
mysql-native it is hard to use this package as it lacks on 
documentation, non of the example provided in the documentation 
works, one has to go through the code and find how things works 
to use this package. We have raised this issue in the github and 
it been 3 day's still no update and the last documentation 
(README) was updated 14 month ago, but the latest release of this 
package was released on 2020-Oct-11, version 2.1.9. May I know 
whether is there is any plan for updating the documentation if so 
may know when would the documentation be updated, so that we can 
explore other features of hunt packages (hunt-framework vs vib.d 
framework).


Component : mysql-native + asdf
Executable size : 17 MB
Execution time : 10 secs, 189 ms, 919 μs, and 3 hnsecs

Component : hunt-database + asdf
Executable size : 81 MB
Execution time : 5 secs, 916 ms, 418 μs, and 3 hnsecs


From,
Vino.B



Re: How to use bootstrap with vibe.d.

2020-11-05 Thread James Blachly via Digitalmars-d-learn

On Thursday, 5 November 2020 at 16:22:11 UTC, Alaindevos wrote:
This is from the bootstrap documentation. I think you must 
adapt this to .dt files.


Correct. It looks like flask_bootstrap is just a convenience that 
injects the js and css scripts or script URI for you into master 
flask template.




Re: How add class or struct member after construction?

2020-11-05 Thread Simen Kjærås via Digitalmars-d-learn

On Thursday, 5 November 2020 at 22:48:38 UTC, Marcone wrote:
How add class or struct member after construction? Is it 
possible in D? How?


This depends a lot on what you mean. The short answer is no - you 
cannot. However, given some limitations, it is possible. What 
sort of members do you need to add, and how will you be using 
them?


For instance, this works:

struct S {
import std.variant;
Variant[string] members;

Variant opDispatch(string name)() {
return members[name];
}
Variant opDispatch(string name, T)(T value) {
return members[name] = value;
}
}

unittest {
S s;
s.foo = 13;
assert(s.foo == 13);
}

--
  Simen


Re: How add class or struct member after construction?

2020-11-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 05, 2020 at 10:48:38PM +, Marcone via Digitalmars-d-learn wrote:
> How add class or struct member after construction? Is it possible in
> D? How?

You can't, because D is statically-typed.

However, you *can* implement something equivalent manually by other
means, depending on your use case.  What use do you have in mind?  If
you're more specific about what you're trying to accomplish, we could
figure out a possible implementation for you.


T

-- 
Why waste time learning, when ignorance is instantaneous? -- Hobbes, from 
Calvin & Hobbes


How add class or struct member after construction?

2020-11-05 Thread Marcone via Digitalmars-d-learn
How add class or struct member after construction? Is it possible 
in D? How?


Re: Switch between two structs with csvreader

2020-11-05 Thread Anonymouse via Digitalmars-d-learn

On Thursday, 5 November 2020 at 21:18:52 UTC, Selim Ozel wrote:

auto records = rawtext.csvReader!struct_type1(';');


D is statically typed and `auto` means "deduce this type for me 
based on this one function's return value". It is not like 
JavaScript's `var` whose type may change.


If I'm not mistaken the `csvReader` function returns a range 
struct, and the full type is something long and unwieldy like 
`CsvReader!(struct_type1, cast(Malformed)1, string, dchar, 
string[])`. So just think of `records` as being that.


(You can tell what type it is at compilation with `pragma(msg, 
typeof(records).stringof)`.)



if(aControlCondition) {
records = rawtext.csvReader!struct_type2(';');


Here `csvReader!struct_type2(';')` returns a value of type 
`CsvReader!(struct_type2, ...)`, which is a different type from 
that of `records` (and they're not implicitly convertible). So 
the error message is right. If `auto` worked like `var` your code 
would work, but it doesn't.


You need two different variables and two different `foreach`es. 
For the same code to work on both types, the easy solution is 
templates. Perhaps make the `foreach` part after the reads a 
templated function that accepts any type passed to it?




Switch between two structs with csvreader

2020-11-05 Thread Selim Ozel via Digitalmars-d-learn

Hi There,

I am trying to switch between two structs as I am using the 
csvReader on a raw string. The pseudo-code below throws a "cannot 
implicitly convert" error due to difference between struct_type1 
and struct_type2. I must be doing something wrong or have a wrong 
understanding of how this function works. Could someone give a 
good suggestion on handling this?


Thanks!

Best,
Selim

auto records = rawtext.csvReader!struct_type1(';');
if(aControlCondition) {
records = rawtext.csvReader!struct_type2(';');
}

// Iterate through each data row.   
foreach (record; records) {
writeln(record);
}


Re: Vibe.D TLS problem

2020-11-05 Thread Dukc via Digitalmars-d-learn

On Tuesday, 27 October 2020 at 17:36:53 UTC, Dukc wrote:

```
HTTP connection handler has thrown: Accepting SSL tunnel: 
error:1408F09C:SSL routines:ssl3_get_record:http request 
(336130204)

```


I figured out from the Vibe.D source code that if I enable the 
debug level of the console logger, I should get more info. How do 
I do that (dub project, main controlled by Vibe.D)?





Re: How to use bootstrap with vibe.d.

2020-11-05 Thread Alaindevos via Digitalmars-d-learn

It know it gives you nice buttons.
I suppose to use it you add the bootstrap .js and .css file links 
to the diet templates.