Re: Updating D-based apps without recompiling it

2016-03-23 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 12:21:33 UTC, Ozan wrote: Hi Enterprise applications in productive environments requires smooth updating mechanisms without recompiling or reinstalling. It's not possible to stop an enterprise application, then run "dub --reforce" and wait until finish. Mostly

Re: Updating D-based apps without recompiling it

2016-03-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-03-23 18:15, Jesse Phillips wrote: Do you have an example of this being done in any other language? In Erlang it's possible to hot swap code. I'm not sure how it works though. But if we're talking servers, the easiest is to have multiple instances and restart one at the time with

Re: Something wrong with GC

2016-03-23 Thread ag0aep6g via Digitalmars-d-learn
On 22.03.2016 16:56, ag0aep6g wrote: I've filed an issue: https://issues.dlang.org/show_bug.cgi?id=15821 And it's been fixed: https://github.com/D-Programming-Language/druntime/pull/1519 Since the issue was a regression, the fix was made against the stable branch. It's going to be in the

Re: Variant.type bug ?

2016-03-23 Thread Chris Wright via Digitalmars-d-learn
Consider the `coerce` method: http://dpldocs.info/experimental-docs/std.variant.VariantN.coerce.html Example: import std.variant; class A {} class B : A {} void main() { A b = new B; auto bb = Variant(b).coerce!B; assert (bb !is null); }

Re: Updating D-based apps without recompiling it

2016-03-23 Thread Chris Wright via Digitalmars-d-learn
On Wed, 23 Mar 2016 12:21:33 +, Ozan wrote: > Enterprise applications in productive environments requires smooth > updating mechanisms without recompiling or reinstalling. The industry standard is to build on a build server and stop the application to update, but to have enough redundancy

Re: byChunk odd behavior?

2016-03-23 Thread cym13 via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 03:17:05 UTC, Hanh wrote: Thanks for your help everyone. I agree that the issue is due to the misusage of an InputRange but what is the semantics of 'take' when applied to an InputRange? It seems that calling it invalidates the range; in which case what is the

getOverloads, but also include all the imported members

2016-03-23 Thread Yuxuan Shui via Digitalmars-d-learn
Say: module one; void func(int a){} / module two; import one; void func(float a){} Is there a way to get both func() in module two?

If I understand const right...

2016-03-23 Thread cy via Digitalmars-d-learn
a = a + 1 a is const, a + 1 is const, yet a can't be assigned to a + 1. And I think the reason is like... const(int) a = 23; while(something()) { a = a + 1; } in the first iteration, a is set to 23, and the value of "a + 1" is 24, but where is the computer gonna store that 24? It can't

Re: If I understand const right...

2016-03-23 Thread ag0aep6g via Digitalmars-d-learn
On 23.03.2016 21:52, cy wrote: const(int)[2] a = [23,24]; const(int)* b = a; Should be: const(int)* b = a.ptr; writeln(," always constant"); writeln(a, " always constant"); There's some subtlety here. `a` itself is not const, but its elements are. `a` being a fixed-sized array, you can't

Re: pass a struct by value/ref and size of the struct

2016-03-23 Thread kinke via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 07:35:49 UTC, ZombineDev wrote: If the object is larger than the size of a register on the target machine, it is implicitly passed by ref That's incorrect. As Johan pointed out, this is somewhat true for the Win64 ABI (but it firstly copies the argument before

inout and templates don't mix...

2016-03-23 Thread cy via Digitalmars-d-learn
halp There's a module that tries to define complex operations on both const and non-const structs, since it's the same operation for both. So every function that invokes those operations is copy-pasted twice, just with "const" added. Switching to inout to eliminate that huge amount of code

Re: If I understand const right...

2016-03-23 Thread ag0aep6g via Digitalmars-d-learn
On 23.03.2016 22:26, ag0aep6g wrote: On 23.03.2016 22:18, cy wrote: On Wednesday, 23 March 2016 at 21:10:49 UTC, ag0aep6g wrote: [...] b = new int(*b + 1); Here "b" is pointing to mutable heap allocated data, which got cast to constant. with b = b + 1, it's still constant memory. It's

Re: Variant.type bug ?

2016-03-23 Thread Voitech via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 19:18:50 UTC, Chris Wright wrote: Consider the `coerce` method: http://dpldocs.info/experimental-docs/std.variant.VariantN.coerce.html Example: import std.variant; class A {} class B : A {} void main() { A b = new B; auto bb = Variant(b).coerce!B;

Compiler Specific dub Dependencies

2016-03-23 Thread Jack Stouffer via Digitalmars-d-learn
Is there any way in dub to specify that a module should only be linked and compiled for DMD and not for LDC? I am using the Economic Modeling containers library, and because it uses std.experimental.allocator, it can't be used with LDC through dub. I have coded in such a way with static if's

Re: If I understand const right...

2016-03-23 Thread cy via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 21:10:49 UTC, ag0aep6g wrote: Just to be 100% clear: you're adding to the pointer here, No, that's what I meant to do. b = new int(*b + 1); Here "b" is pointing to mutable heap allocated data, which got cast to constant. with b = b + 1, it's still constant

Re: If I understand const right...

2016-03-23 Thread ag0aep6g via Digitalmars-d-learn
On 23.03.2016 22:18, cy wrote: On Wednesday, 23 March 2016 at 21:10:49 UTC, ag0aep6g wrote: [...] b = new int(*b + 1); Here "b" is pointing to mutable heap allocated data, which got cast to constant. with b = b + 1, it's still constant memory. It's stack memory. Its constness isn't any

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread wobbles via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 11:57:49 UTC, ParticlePeter wrote: I need to parse an ascii with multiple tokens. The tokens can be seen as keys. After every token there is a bunch of lines belonging to that token, the values. The order of tokens is unknown. I would like to read the file in as

Re: parsing HTML for a web robot (crawler) like application

2016-03-23 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 09:06:37 UTC, Rene Zwanenburg wrote: Adam's dom.d will get you pretty far. I believe it can also handle documents that aren't completely well-formed. https://github.com/adamdruppe/arsd/blob/master/dom.d HTML-docs here:

Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
I need to parse an ascii with multiple tokens. The tokens can be seen as keys. After every token there is a bunch of lines belonging to that token, the values. The order of tokens is unknown. I would like to read the file in as a whole string, and split the string with: splitter(fileString,

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 11:57:49 UTC, ParticlePeter wrote: Stupid typos: I need to parse an ascii file with multiple tokens. ... ... to do this with a lazy result range and without new allocations.

Re: Updating D-based apps without recompiling it

2016-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 12:21:33 UTC, Ozan wrote: Has someone experience with handling upgrading/updating D-Apps on the fly? The way I always did it was to simply have old and new running side-by-side in the transition. So, without stopping the old version, compile the new one and

Updating D-based apps without recompiling it

2016-03-23 Thread Ozan via Digitalmars-d-learn
Hi Enterprise applications in productive environments requires smooth updating mechanisms without recompiling or reinstalling. It's not possible to stop an enterprise application, then run "dub --reforce" and wait until finish. Mostly only few functions need to be replaced. Has someone

Re: Checking if a port is listening

2016-03-23 Thread Lucien via Digitalmars-d-learn
On Saturday, 19 March 2016 at 18:24:38 UTC, Marc Schütz wrote: On Saturday, 19 March 2016 at 09:55:13 UTC, Lucien wrote: const int MAX = 64; Socket[] sockets = new Socket[MAX]; string ipb = "192.168.0."; for (int i = 1; i < MAX; i++) { Here's the reason for your SEGV: You

Re: inout and templates don't mix...

2016-03-23 Thread Ali Çehreli via Digitalmars-d-learn
On 03/23/2016 02:31 PM, cy wrote: > struct Someop(Type) { >Type thing; >void foo() { > thing.bar(); >} > } > > struct Foo { >void bar() { > import std.stdio: writeln; > writeln("bar"); >} > } > > struct Bar { >void thingy(inout(Foo) foo) inout { > auto

How do you append to a dynamic array using move semantics?

2016-03-23 Thread cy via Digitalmars-d-learn
struct Thing { @disable this(this); } ... items ~= move(item); // Error: struct Thing is not copyable because it is annotated with @disable ++items.length move(items[$-1],item); // Error: struct Thing is not copyable because it is annotated with @disable appender(items).put(move(item));

Re: How do you append to a dynamic array using move semantics?

2016-03-23 Thread ag0aep6g via Digitalmars-d-learn
On 24.03.2016 00:26, cy wrote: ++items.length move(items[$-1],item); // Error: struct Thing is not copyable because it is annotated with @disable You got the order of arguments wrong here. Source goes first, target second. Works for me with `move(item, items[$-1]);`.

Re: Compiler Specific dub Dependencies

2016-03-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 20:30:04 UTC, Jack Stouffer wrote: Is there any way in dub to specify that a module should only be linked and compiled for DMD and not for LDC? I am using the Economic Modeling containers library, and because it uses std.experimental.allocator, it can't be used

Re: How do you append to a dynamic array using move semantics?

2016-03-23 Thread ag0aep6g via Digitalmars-d-learn
On 24.03.2016 00:44, ag0aep6g wrote: On 24.03.2016 00:26, cy wrote: ++items.length move(items[$-1],item); // Error: struct Thing is not copyable because it is annotated with @disable You got the order of arguments wrong here. Source goes first, target second. Works for me with `move(item,

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread Simen Kjaeraas via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 18:10:05 UTC, ParticlePeter wrote: Thanks Simen, your tokenCounter is inspirational, for the rest I'll take some time for testing. My pleasure. :) Testing it on your example data shows it to work there. However, as stated above, the documentation says it's

Re: Variant.type bug ?

2016-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 08:01:36 UTC, Voitech wrote: Hi Variant stores variant.type as not the "highest" in hierarchy. Yeah, it stores the static type. You can use it to get that then do a normal dynamic cast to test for a more derived type.

Re: parsing HTML for a web robot (crawler) like application

2016-03-23 Thread Martin Tschierschke via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 09:06:37 UTC, Rene Zwanenburg wrote: [...] Adam's dom.d will get you pretty far. I believe it can also handle documents that aren't completely well-formed. https://github.com/adamdruppe/arsd/blob/master/dom.d Thank you! This forum has an incredible fast auto

Re: Something wrong with GC

2016-03-23 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 22 March 2016 at 13:46:41 UTC, stunaep wrote: So what am I do to? Just learn more about available containers and their semantics. Maybe you don't need Array!T when there is a simple T[]. If you think you do need Array, then think about memory management: where are you going to

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread Simen Kjaeraas via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 11:57:49 UTC, ParticlePeter wrote: I need to parse an ascii with multiple tokens. The tokens can be seen as keys. After every token there is a bunch of lines belonging to that token, the values. The order of tokens is unknown. I would like to read the file in as

Re: Finding out names in shared libraries

2016-03-23 Thread Ozan via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 15:17:18 UTC, Ozan wrote: If I want to use a class or a function in a shared library, it is necessary to use funny names like "D7myclass10getMyClassFZC7myclass7MyClass". Is it possible to get a list of all the names in shared library? What is the schema behind

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 14:20:12 UTC, Andrea Fontana wrote: Any input => output example? Sure, it is ensight gold case file format: FORMAT type: ensight gold GEOMETRY model: 1exgold2.geo** VARIABLE scalar per node: 1 Stress

Finding out names in shared libraries

2016-03-23 Thread Ozan via Digitalmars-d-learn
Hi If I want to use a class or a function in a shared library, it is necessary to use funny names like "D7myclass10getMyClassFZC7myclass7MyClass". Is it possible to get a list of all the names in shared library? What is the schema behind these names? Is there a listing for "D7", "10",

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 12:00:15 UTC, ParticlePeter wrote: On Wednesday, 23 March 2016 at 11:57:49 UTC, ParticlePeter wrote: Stupid typos: I need to parse an ascii file with multiple tokens. ... ... to do this with a lazy result range and without new allocations. Any input =>

Re: parsing HTML for a web robot (crawler) like application

2016-03-23 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 09:02:37 UTC, Martin Tschierschke wrote: Hello! I want to set up a web robot to detect changes on certain web pages or sites. Any hint to similar projects or libraries at dub or git to look at, before starting to develop my own RegExp for parsing? Best regards

Re: Variant.type bug ?

2016-03-23 Thread Voitech via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 12:52:24 UTC, Adam D. Ruppe wrote: On Wednesday, 23 March 2016 at 08:01:36 UTC, Voitech wrote: Hi Variant stores variant.type as not the "highest" in hierarchy. Yeah, it stores the static type. You can use it to get that then do a normal dynamic cast to test

Re: parsing HTML for a web robot (crawler) like application

2016-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 10:49:03 UTC, Nordlöw wrote: HTML-docs here: http://dpldocs.info/experimental-docs/arsd.dom.html Indeed, though the docs are still a work in progress (the lib is now about 6 years old, but until recently, ddoc blocked me from using examples in the comments so

parsing fastq files with D

2016-03-23 Thread eastanon via Digitalmars-d-learn
Fastq is a format for storing DNA sequences together with the associated quality information often encoded in ascii characters. It is typically made of 4 lines for example 2 fastq entries would look like this. @seq1 TTAAAT + ?+BBB/DHH@ @seq2 GACCCTTTGCA + ?+BHB/DIH@ I do not have a lot

Re: How do you append to a dynamic array using move semantics?

2016-03-23 Thread cy via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 23:44:55 UTC, ag0aep6g wrote: You got the order of arguments wrong here. Source goes first, Oh, derp. Thanks. Right then... it works as expected.

Re: Finding out names in shared libraries

2016-03-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-03-23 16:17, Ozan wrote: Hi If I want to use a class or a function in a shared library, it is necessary to use funny names like "D7myclass10getMyClassFZC7myclass7MyClass". Is it possible to get a list of all the names in shared library? What is the schema behind these names? Is there

Re: Does something like std.algorithm.iteration:splitter with multiple seperators exist?

2016-03-23 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 15:23:38 UTC, Simen Kjaeraas wrote: Without a bit more detail, it's a bit hard to help. std.algorithm.splitter has an overload that takes a function instead of a separator: import std.algorithm; auto a = "a,b;c"; auto b = a.splitter!(e => e == ';'

Re: byChunk odd behavior?

2016-03-23 Thread Chris Wright via Digitalmars-d-learn
On Wed, 23 Mar 2016 03:17:05 +, Hanh wrote: > In Scala, 'take' consumes bytes from the iterator. So the same code > would be buffer = range.take(N).toArray import std.range, std.array; auto bytes = byteRange.takeExactly(N).array; There's also take(N), but if the range contains fewer than N

Variant.type bug ?

2016-03-23 Thread Voitech via Digitalmars-d-learn
Hi Variant stores variant.type as not the "highest" in hierarchy. Like this A a= new A; A b = new B; //B:A Variant bVar=Variant(b); bVar.type will be typeid(A) not typeid(B). Is this intentional ? If so is there a way to get "concrete" type of "b" variable like when passing to template

parsing HTML for a web robot (crawler) like application

2016-03-23 Thread Martin Tschierschke via Digitalmars-d-learn
Hello! I want to set up a web robot to detect changes on certain web pages or sites. Any hint to similar projects or libraries at dub or git to look at, before starting to develop my own RegExp for parsing? Best regards mt.

Re: parsing HTML for a web robot (crawler) like application

2016-03-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 23 March 2016 at 09:02:37 UTC, Martin Tschierschke wrote: Hello! I want to set up a web robot to detect changes on certain web pages or sites. Any hint to similar projects or libraries at dub or git to look at, before starting to develop my own RegExp for parsing? Best regards