Re: -L--demangle=dlang doesn't work

2018-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 6 January 2018 at 05:44:28 UTC, Venkat wrote: Why does gcc say "unknown demangling style `dlang'" ? Do I need GDC for demangling to work ? 85198AB7DE24894B5F742FBD5/libvibe-d_data.a

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 18:00:34 UTC, thedeemon wrote: On Friday, 5 January 2018 at 17:59:32 UTC, thedeemon wrote: Tuple!( staticMap!(Arr, ColumnTypes) ) res; // array of tuples Sorry, I meant tuple of arrays, of course. Hi Deemon, Thank you very much, I tested your code,

-L--demangle=dlang doesn't work

2018-01-05 Thread Venkat via Digitalmars-d-learn
Why does gcc say "unknown demangling style `dlang'" ? Do I need GDC for demangling to work ? 85198AB7DE24894B5F742FBD5/libvibe-d_data.a

Re: Templates for DRY code

2018-01-05 Thread codephantom via Digitalmars-d-learn
On Saturday, 6 January 2018 at 03:08:19 UTC, Ali Çehreli wrote: It's hard to find a balance between fully explicit and fully automatic. I find myself going back and forth between those two extremes. Ali Code is something that humans write and read (and read far more than write). So I

Re: Templates for DRY code

2018-01-05 Thread Ali Çehreli via Digitalmars-d-learn
On 01/05/2018 06:14 PM, codephantom wrote: > On Saturday, 6 January 2018 at 01:33:11 UTC, Ali Çehreli wrote: >> One solution is to wrap ~= in a function template. Now the conversion >> is automatically made to the element type of the array: >> ... >> . >> I think append() could be a part of

Re: Templates for DRY code

2018-01-05 Thread codephantom via Digitalmars-d-learn
On Saturday, 6 January 2018 at 01:33:11 UTC, Ali Çehreli wrote: One solution is to wrap ~= in a function template. Now the conversion is automatically made to the element type of the array: ... . I think append() could be a part of std.array but I can't find anything like that in Phobos.

Templates for DRY code

2018-01-05 Thread Ali Çehreli via Digitalmars-d-learn
Nothing new here... I'm just reminded of how templates can help with DRY (don't repeat yourself) code. Here is a piece of code that uses an alias to be flexible on the element type: import std.conv; alias MyType = double;// <-- Nice, MyType is used twice below void main() {

Re: what's the scope of a static variable inside a local function?

2018-01-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 05, 2018 17:17:47 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 1/5/18 5:07 PM, Jonathan M Davis wrote: > > but doesn't print out anything about main or f. I don't know if that's a > > bug or not, since the only way that I can think of to make it work > > would be to

Re: Upcasting slice of class elements

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 6:04 PM, H. S. Teoh wrote: On Fri, Jan 05, 2018 at 10:16:04PM +, Nordlöw via Digitalmars-d-learn wrote: Why isn't class X {} class Y : X {} X[] xs = cast(X[])(Y[].init); compilable in safe D? What's unsafe about such a cast? Your original code snippet seems

Re: Upcasting slice of class elements

2018-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 05, 2018 at 10:16:04PM +, Nordlöw via Digitalmars-d-learn wrote: > Why isn't > > class X {} > class Y : X {} > X[] xs = cast(X[])(Y[].init); > > compilable in safe D? > > What's unsafe about such a cast? Your original code snippet seems redundant. If you wanted an

Re: Upcasting slice of class elements

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 5:16 PM, Nordlöw wrote: Why isn't     class X {}     class Y : X {}     X[] xs = cast(X[])(Y[].init); compilable in safe D? Hm... given that there is no other reference to xs, it should work. But obviously you have a different example in mind, as this makes no sense? This

Re: Upcasting slice of class elements

2018-01-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 January 2018 at 22:16:04 UTC, Nordlöw wrote: Why isn't class X {} class Y : X {} X[] xs = cast(X[])(Y[].init); compilable in safe D? What's unsafe about such a cast? class X {} class Y : X {} class Z : X {} Y[] ys = Y[].init; X[] xs = cast(X[])(ys); xs[0] = new Z;

Re: what's the scope of a static variable inside a local function?

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 5:07 PM, Jonathan M Davis wrote: but doesn't print out anything about main or f. I don't know if that's a bug or not, since the only way that I can think of to make it work would be to have the compiler invisibly add a static destructor to the module to clean them up, and that would

Upcasting slice of class elements

2018-01-05 Thread Nordlöw via Digitalmars-d-learn
Why isn't class X {} class Y : X {} X[] xs = cast(X[])(Y[].init); compilable in safe D? What's unsafe about such a cast?

Re: what's the scope of a static variable inside a local function?

2018-01-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 05, 2018 16:59:38 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 1/5/18 4:44 PM, Marc wrote: > >> void foo() { > >> void baa() { > >> static int n; > >> writeln(n++); > >> } > >> } > >> > >> void main() { > >> static int x; > >> foo(); > >>

Re: Help optimizing UnCompress for gzipped files

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 3:09 PM, Christian Köstlin wrote: On 05.01.18 15:39, Steven Schveighoffer wrote: Yeah, I guess most of the bottlenecks are inside libz, or the memory allocator. There isn't much optimization to be done in the main program itself. D compiles just the same as C. So theoretically you

Re: what's the scope of a static variable inside a local function?

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 4:44 PM, Marc wrote: void foo() { void baa() {     static int n;     writeln(n++); } } void main() {  static int x;  foo();  doSomething(x); } does x and n has same lifetime, i.e, program's execution or n is longer available onde foo() call reach out of scope?

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread Brian via Digitalmars-d-learn
On Friday, 5 January 2018 at 15:38:17 UTC, Binghoo Dang wrote: On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: ~~ struct User { int id; string name; string email; } class ORM { } auto db

what's the scope of a static variable inside a local function?

2018-01-05 Thread Marc via Digitalmars-d-learn
void foo() { void baa() { static int n; writeln(n++); } } void main() { static int x; foo(); doSomething(x); } does x and n has same lifetime, i.e, program's execution or n is longer available onde foo() call reach out of scope?

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread Brian via Digitalmars-d-learn
On Friday, 5 January 2018 at 12:19:11 UTC, thedeemon wrote: On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: db.select(User).where(email.like("*@hotmail.com")).limit(10); You need to read about templates in D, here's a good guide:

Re: Help optimizing UnCompress for gzipped files

2018-01-05 Thread Christian Köstlin via Digitalmars-d-learn
On 05.01.18 15:39, Steven Schveighoffer wrote: > Yeah, I guess most of the bottlenecks are inside libz, or the memory > allocator. There isn't much optimization to be done in the main program > itself. > > D compiles just the same as C. So theoretically you should be able to > get the same

Re: Consequences of casting away immutable from pointers

2018-01-05 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 5 January 2018 at 18:13:11 UTC, H. S. Teoh wrote: On Fri, Jan 05, 2018 at 05:50:34PM +, jmh530 via Digitalmars-d-learn wrote: Be careful with that: class C { int x; } immutable C c = new C(5); auto i = c.x; C y = cast(C) c; y.x = 10;

Re: Consequences of casting away immutable from pointers

2018-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 05, 2018 at 05:50:34PM +, jmh530 via Digitalmars-d-learn wrote: > On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer wrote: > > > > Yes, this is undefined behavior. > > > > https://dlang.org/spec/const3.html#removing_with_cast > > > > The compiler assumes x is going

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread thedeemon via Digitalmars-d-learn
On Friday, 5 January 2018 at 17:59:32 UTC, thedeemon wrote: Tuple!( staticMap!(Arr, ColumnTypes) ) res; // array of tuples Sorry, I meant tuple of arrays, of course.

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread thedeemon via Digitalmars-d-learn
On Friday, 5 January 2018 at 17:50:13 UTC, thedeemon wrote: Here's my version of solution. I've used ordinary arrays instead of std.container.array, since the data itself is in GC'ed heap anyway. I used csv file separated by tabs, so told csvReader to use '\t' for delimiter. And since lines

Re: Consequences of casting away immutable from pointers

2018-01-05 Thread jmh530 via Digitalmars-d-learn
On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer wrote: Yes, this is undefined behavior. https://dlang.org/spec/const3.html#removing_with_cast The compiler assumes x is going to be 5 forever, so instead of loading the value at that address, it just loads 5 into a register (or

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread thedeemon via Digitalmars-d-learn
On Friday, 5 January 2018 at 13:09:25 UTC, Vino wrote: Sorry, I'm asking what problem are you solving, what the program should do, what is its idea. Not what code you have written. Hi, I am trying to implement data dictionary compression, and below is the function of the program, Function

Re: Array is already defined

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 16:55:50 UTC, Steven Schveighoffer wrote: On 1/5/18 11:39 AM, Vino wrote: Hi Steve,  if we add the braces we are getting the Error: undefined identifier Datacol void main () { Array!int Keycol; static foreach(i; 0 .. 3) { {     typeof(read()[i])

Re: Array is already defined

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 11:39 AM, Vino wrote: Hi Steve,  if we add the braces we are getting the Error: undefined identifier Datacol void main () { Array!int Keycol; static foreach(i; 0 .. 3) { {     typeof(read()[i]) Datacol;     Datacol.insertBack(sort(read[i].dup[]).uniq);    

Re: Array is already defined

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 16:07:49 UTC, Steven Schveighoffer wrote: On 1/5/18 10:56 AM, Vino wrote: On Friday, 5 January 2018 at 15:28:58 UTC, Jonathan M Davis wrote: On Friday, January 05, 2018 15:22:49 Vino via Digitalmars-d-learn wrote: Hi All,   Request your help on how to unset or

Re: Can I use D with the Microsoft universal windows platform?

2018-01-05 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 18:33:27 UTC, Ozan wrote: Hi Are there any use cases or libraries for using D in Microsoft's universal windows platform environment? It would be nice to have XBOX Apps build on D ;-) Regards Ozan I made a half functioning winrt wrapper once but eventually I

Re: Array is already defined

2018-01-05 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 05, 2018 at 03:56:30PM +, Vino via Digitalmars-d-learn wrote: [...] > Hi Jonathan, > > Sorry , not able to get you, can you please point our as to where we > need to added the braces in the below example. Try this: void main () { Array!int Keycol;

Re: Array is already defined

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 10:56 AM, Vino wrote: On Friday, 5 January 2018 at 15:28:58 UTC, Jonathan M Davis wrote: On Friday, January 05, 2018 15:22:49 Vino via Digitalmars-d-learn wrote: Hi All,   Request your help on how to unset or delete an array, in the below example, we get an error "Common  is already

Re: C++ Interop

2018-01-05 Thread Timothee Cour via Digitalmars-d-learn
see also https://github.com/Syniurge/Calypso/ although I'm having lots of issues using it on OSX On Fri, Jan 5, 2018 at 9:02 AM, qznc via Digitalmars-d-learn wrote: > I'm exploring [0] C++ interop after watching Walter's presentation [1]. > > I hit a block with

Re: Array is already defined

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 15:28:58 UTC, Jonathan M Davis wrote: On Friday, January 05, 2018 15:22:49 Vino via Digitalmars-d-learn wrote: Hi All, Request your help on how to unset or delete an array, in the below example, we get an error "Common is already defined". Auto fn1 () {

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread Binghoo Dang via Digitalmars-d-learn
On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: ~~ struct User { int id; string name; string email; } class ORM { } auto db = new ORM; auto users =

why does unittest mangled name now contains full file path instead of fully qualified module name?

2018-01-05 Thread Timothee Cour via Digitalmars-d-learn
why does unittest mangled name now contains full file path instead of fully qualified module name? seems like a regression, previous behavior seemed better and not dependent on installation path.

Re: Array is already defined

2018-01-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 05, 2018 15:22:49 Vino via Digitalmars-d-learn wrote: > Hi All, > > Request your help on how to unset or delete an array, in the > below example, we get an error "Common is already defined". > > Auto fn1 () { > Array!string Text; > Array!string Number; > return tuple(Text,

Array is already defined

2018-01-05 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to unset or delete an array, in the below example, we get an error "Common is already defined". Auto fn1 () { Array!string Text; Array!string Number; return tuple(Text, Number); } Void main () { static foreach(i; 0 .. 2) { typeof(fn1()[i]) Common;

Re: Help optimizing UnCompress for gzipped files

2018-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/5/18 1:01 AM, Christian Köstlin wrote: On 04.01.18 20:46, Steven Schveighoffer wrote: On 1/4/18 1:57 PM, Christian Köstlin wrote: Thanks Steve, this runs now faster, I will update the table. Still a bit irked that I can't match the C speed :/ But, I can't get your C speed to duplicate

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread Michael via Digitalmars-d-learn
On Friday, 5 January 2018 at 12:19:11 UTC, thedeemon wrote: On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: db.select(User).where(email.like("*@hotmail.com")).limit(10); You need to read about templates in D, here's a good guide:

Re: Consequences of casting away immutable from pointers

2018-01-05 Thread jmh530 via Digitalmars-d-learn
On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer wrote: Yes, this is undefined behavior. https://dlang.org/spec/const3.html#removing_with_cast The compiler assumes x is going to be 5 forever, so instead of loading the value at that address, it just loads 5 into a register (or

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 13:09:25 UTC, Vino wrote: On Friday, 5 January 2018 at 12:47:39 UTC, thedeemon wrote: On Friday, 5 January 2018 at 12:40:41 UTC, Vino wrote: What exactly are you trying to do in Master()? Please find the full code, Sorry, I'm asking what problem are you

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 12:47:39 UTC, thedeemon wrote: On Friday, 5 January 2018 at 12:40:41 UTC, Vino wrote: What exactly are you trying to do in Master()? Please find the full code, Sorry, I'm asking what problem are you solving, what the program should do, what is its idea. Not

C++ Interop

2018-01-05 Thread qznc via Digitalmars-d-learn
I'm exploring [0] C++ interop after watching Walter's presentation [1]. I hit a block with classes as template parameters. This means vector works, but vector does not. D seems to map vector!Foo to vector. Likewise shared_ptr is a problem. Any way to fix that on the D side? The ugly

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread thedeemon via Digitalmars-d-learn
On Friday, 5 January 2018 at 12:40:41 UTC, Vino wrote: What exactly are you trying to do in Master()? Please find the full code, Sorry, I'm asking what problem are you solving, what the program should do, what is its idea. Not what code you have written.

Re: Dub and libraries

2018-01-05 Thread Arek via Digitalmars-d-learn
On Thursday, 4 January 2018 at 19:05:59 UTC, Russel Winder wrote: Is it the case that, for library things on the Dub repository, Dub will only create library archives, .a, that it is unable to create shared objects and DLLs? If they have "targetType" set to "dynamicLibrary" dub creates

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread Vino via Digitalmars-d-learn
On Friday, 5 January 2018 at 12:10:33 UTC, thedeemon wrote: On Friday, 5 January 2018 at 09:09:00 UTC, Vino wrote: Thank you very much, can you suggest the best way around this issue. What exactly are you trying to do in Master()? The code seems very broken. Each time you write read[i] is

Re: weird exception on windows

2018-01-05 Thread Szabo Bogdan via Digitalmars-d-learn
On Monday, 18 December 2017 at 22:49:30 UTC, unleashy wrote: On Friday, 15 December 2017 at 21:56:48 UTC, Steven Schveighoffer wrote: On 12/15/17 10:08 AM, Kagamin wrote: Maybe this https://issues.dlang.org/show_bug.cgi?id=18084 Thanks for looking into this. I created a PR to fix. Szabo,

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread thedeemon via Digitalmars-d-learn
On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: db.select(User).where(email.like("*@hotmail.com")).limit(10); You need to read about templates in D, here's a good guide: https://github.com/PhilippeSigaud/D-templates-tutorial Basically you can write a function

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread thedeemon via Digitalmars-d-learn
On Friday, 5 January 2018 at 09:09:00 UTC, Vino wrote: Thank you very much, can you suggest the best way around this issue. What exactly are you trying to do in Master()? The code seems very broken. Each time you write read[i] is will call read() and read the whole file, you're going to

Re: Error: variable i cannot be read at compile time

2018-01-05 Thread Vino via Digitalmars-d-learn
On Thursday, 4 January 2018 at 18:49:21 UTC, Ali Çehreli wrote: On 01/04/2018 08:51 AM, Vino wrote: > auto read () { [...] > return tuple(Ucol1, Ucol2, Ucol3, rSize); > } read() returns a tuple of values of different types. > for(int i = 0; i < Size; i++) { > typeof(read()[i]) Datacol;

Re: What could this OptLink Error mean?

2018-01-05 Thread user789 via Digitalmars-d-learn
On Thursday, 4 January 2018 at 21:33:58 UTC, Dukc wrote: On Saturday, 30 December 2017 at 00:49:48 UTC, user1234 wrote: The deps have to be rebuild too. After downloading dmd 78, it started to work. It's likely you were right about the issue, DUB rebuilt everything after detecting new

Re: How do i activate the latest nightly without knowing the date ?

2018-01-05 Thread user789 via Digitalmars-d-learn
On Thursday, 4 January 2018 at 22:07:39 UTC, user789 wrote: On Thursday, 4 January 2018 at 20:37:16 UTC, user789 wrote: On Thursday, 4 January 2018 at 20:28:47 UTC, user789 wrote: After using the script to setup DMD nightly i read in the output that i have to run "source

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread user789 via Digitalmars-d-learn
On Friday, 5 January 2018 at 08:34:00 UTC, user789 wrote: On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: ~~ struct User { int id; string name; string email; } class ORM { } auto db = new

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread user789 via Digitalmars-d-learn
On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: ~~ struct User { int id; string name; string email; } class ORM { } auto db = new ORM; auto users =