Re: Beta D 2.071.0-b1

2016-03-23 Thread ag0aep6g via Digitalmars-d-announce

On 24.03.2016 02:49, Martin Nowak wrote:

http://dlang.org/changelog/2.071.0.html


The changelog page has the wrong version number is the heading and in 
the download link.


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 of D expirience and I am writing a simple 
parser to help work with  these files. Ideally it should be fast 
with low memory footprint. I am working with very large files of 
this type and can be  up to 1GB.


module fastq;

import std.stdio;
import std.file;
import std.exception;
import std.algorithm;
import std.string;

struct Record{

string sequence;
string quals;
string name;
}

auto Records(string filename){

static auto toRecords(S)(S str){

auto res = findSplitBefore(str,"+\n");

auto seq = res[0];
auto qual = res[1];

return Record(seq,qual);
}

string text = cast(string)std.file.read(filename);

enforce(text.length > 0 && text[0] == '@');
text = text[1 .. $];

auto entries = splitter(text,'@');

return map!toRecords(entries);
}

The issue with this is that the "+" character can be part of the 
quality information and I am using it to split the quality 
information from the sequence information. and ends up splitting 
the quality information which is wrong.
Ideally I do not want to use regex and I have heard of ragel for 
parsing but never used it. Such a solution would also be welcome, 
since I read it can be very fast.


Which is the idiomatic way to capture, sequence name (starts with 
@ character and the first entry) the sequence, (line2) the 
quality scores( line 4)


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

--- Comment #11 from ag0ae...@gmail.com ---
(In reply to hsteoh from comment #10)
> Why aren't we fixing this in git HEAD?!

It's a regression. Those are fixed against stable, from which point releases
are built. As far as I understand, stable is merged back into master from time
to time (don't know if there are any rules about it). So the fix should reach
master eventually.

--


Re: Females in the community.

2016-03-23 Thread QAston via Digitalmars-d

On Thursday, 24 March 2016 at 04:05:53 UTC, Adam D. Ruppe wrote:

On Wednesday, 23 March 2016 at 10:46:22 UTC, QAston wrote:
I could point to the building you're sitting in. Most likely 
made almost exclusively by males.


LOL. I happened to spend most the day today with a group of 
women... building something. (I was there too, of course, but 
I'm practically one of the sisters myself and they all did more 
work than me anyway. The other five are all non-controversially 
women.)


I read this message out loud to them. We all got a good laugh.

Y'all should stick to arguing about the color of the bikeshed.


Point taken :D


[Issue 15816] ICE void ddmd.dclass.__assert(int) with error: anonymous classes not allowed

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15816

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0480c90718a73af2cefc39ae92828b7555e9a797
fix Issue 15816 - ICE void ddmd.dclass.__assert(int) with error: anonymous
classes not allowed

An invalid anonymous class declaration has no chance to get internal `ident` (=
"__anonclassXX"), because its `parent` is set by `Dsymbol.addMember` before the
`semantic` is invoked.

Name all `ClassDeclaration` instances during the constructions, then the
problematic assertion can be removed.

https://github.com/D-Programming-Language/dmd/commit/fc3beb0e1b1d36eabe090d73db2829ad02975c75
Merge pull request #5565 from 9rnsr/fix15816

Issue 15816 - ICE void ddmd.dclass.__assert(int) with error: anonymous classes
not allowed

--


Re: Females in the community.

2016-03-23 Thread Mike Parker via Digitalmars-d
On Thursday, 24 March 2016 at 04:19:06 UTC, Vladimir Panteleev 
wrote:

On Thursday, 24 March 2016 at 03:43:04 UTC, Mike Parker wrote:
Spell checkers don't catch everything. If they did, there 
would have been many fewer edits to make in my manuscript for 
Learning D. They can't catch phrases that are worded 
ambiguously, or that come off in a way they weren't intended. 
They can't sentences that are incorrect, but that you didn't 
realize until after you posted. And so on. Every time I find 
I've made a mistake in something I post in these forums, I 
have to make a new post to correct it. And I'm not the only 
one. Just look how often people reply to themselves with a sed 
command.


Do you also not use email, then?


My emails aren't generally available for public consumption.


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: Females in the community.

2016-03-23 Thread Vladimir Panteleev via Digitalmars-d

On Thursday, 24 March 2016 at 03:43:04 UTC, Mike Parker wrote:
Spell checkers don't catch everything. If they did, there would 
have been many fewer edits to make in my manuscript for 
Learning D. They can't catch phrases that are worded 
ambiguously, or that come off in a way they weren't intended. 
They can't sentences that are incorrect, but that you didn't 
realize until after you posted. And so on. Every time I find 
I've made a mistake in something I post in these forums, I have 
to make a new post to correct it. And I'm not the only one. 
Just look how often people reply to themselves with a sed 
command.


Do you also not use email, then?


Re: Females in the community.

2016-03-23 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 23 March 2016 at 10:46:22 UTC, QAston wrote:
I could point to the building you're sitting in. Most likely 
made almost exclusively by males.


LOL. I happened to spend most the day today with a group of 
women... building something. (I was there too, of course, but I'm 
practically one of the sisters myself and they all did more work 
than me anyway. The other five are all non-controversially women.)


I read this message out loud to them. We all got a good laugh.

Y'all should stick to arguing about the color of the bikeshed.


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 I didn't bother. I've fixed 
that now though, but haven't finished writing them all up).



Basic idea though for web scraping:

auto document = new Document();
document.parseGarbage(your_html_string);

// supports most the CSS syntax, and you might also know it from 
jQuery

Element[] elements = document.querySelectorAll("css selector");
// or if you just want the first hit or null if none...
Element element = document.querySelector("css selector");


And once you have a reference:

element.innerText
element.innerHTML

to print its contents in some form.



You can do a lot more too (a LOT more), but just these functions 
should get you started.



The parseGarbage function will also need you to compile in the 
characterencodings.d file from my same github. It will handle 
charset detection and translation as well as tag soup parsing. I 
use it for a lot of web scraping myself.


Re: Some crazy ideas from a high level perspective

2016-03-23 Thread Adam D. Ruppe via Digitalmars-d

On Tuesday, 22 March 2016 at 20:52:26 UTC, cym13 wrote:
[2]: 
https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d


simpledisplay has some examples in its docs:

http://dpldocs.info/experimental-docs/simpledisplay.html

I haven't actually written plotting examples yet, but it is the 
same basic operations as Pong... drawing lines and circles.


Re: Females in the community.

2016-03-23 Thread Mike Parker via Digitalmars-d

On Thursday, 24 March 2016 at 03:43:04 UTC, Mike Parker wrote:


They can't sentences that are incorrect, but that you didn't


And here's an example of what I'm talking about. On this forum, I 
would normally just let it go, but on a modern forum I can edit 
my post.


Re: Females in the community.

2016-03-23 Thread Mike Parker via Digitalmars-d

On Wednesday, 23 March 2016 at 22:26:15 UTC, Walter Bright wrote:


Newsgroups are like the C++ of forum technology...


Don't conflate the NNTP protocol with the shortcomings of 
whatever newsreader you're using. Mine, for example, does spell 
checking. (Thunderbird FWIW)


Spell checkers don't catch everything. If they did, there would 
have been many fewer edits to make in my manuscript for Learning 
D. They can't catch phrases that are worded ambiguously, or that 
come off in a way they weren't intended. They can't sentences 
that are incorrect, but that you didn't realize until after you 
posted. And so on. Every time I find I've made a mistake in 
something I post in these forums, I have to make a new post to 
correct it. And I'm not the only one. Just look how often people 
reply to themselves with a sed command.


NNTP is a dinosaur. Modern forum software offers so many features 
that people take for granted now. I fully understand why people 
find it annoying that those features aren't available here. A few 
years back, there were a couple of threads suggesting a move to a 
real web forum and I know where you stand on the issue. But as 
the community grows, it's absolutely going to become a necessity 
to make the transition at some point. I would even argue that 
continuing to rely on NNTP as the backend may actually hinder 
forum participation because people just aren't used to it. The 
web interface presents a web forum, which it totally is not in 
modern terms.


I spent a lot of time in my newsreader through the 90s, but that 
was then. Let's move into the 21st century already!


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 
with LDC through dub. I have coded in such a way with static 
if's that LDC will still compile without it, but dub will try 
to compile it anyway because it's in the dependencies JSON 
dictionary.


I would try using a default configuration with a platform 
specification. Never done it before, but it would look like this 
in SDLang:


configuration "default-app" {
platforms "dmd"
}

http://code.dlang.org/package-format?lang=sdl#configuration-settings
http://code.dlang.org/package-format?lang=json#configuration-settings


Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread thedeemon via Digitalmars-d

On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote:

On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote:

Could you try to point out whats wrong with map & filter?

It's hard to do stuff like this:

assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a); if(a%3==0) 
put(a);}).equal([1,9,3,25,6,49]));


Is it a bug or you forgot 0 here?

How it looks with Phobos today:

auto r = new Generator!int({
9.iota.each!((a) { if (a % 2) yield(a*a); if (a % 3 == 0) 
yield(a); });

});
assert(r.equal([0,1,9,3,25,6,49]));

Probably much less efficient, of course.


[Issue 15825] dmd's -transition=checkimports reports a false positive for tuple __dollar

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15825

--- Comment #1 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a13a024a02ab62ba88cbe0f87815032d931f3090
fix Issue 15825 - dmd's -transition=checkimports reports a false positive for
tuple __dollar

`ArrayScopeSymbol.search` repeatedly creates __dollar symbol for tuple `length`
propery.

https://github.com/D-Programming-Language/dmd/commit/cf273f717fb45ae4c0393c2eab7f0c4ed9e6e9ef
Merge pull request #5567 from 9rnsr/fix15825

Issue 15825 - dmd's -transition=checkimports reports a false positive for tuple
__dollar

--


[Issue 15779] DWARF EH fails when using stack stomping (-gx)

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15779

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #6 from Walter Bright  ---
https://github.com/D-Programming-Language/dmd/pull/5569

--


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

hst...@quickfur.ath.cx changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #10 from hst...@quickfur.ath.cx ---
Why aren't we fixing this in git HEAD?!

--


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 
undefined, so future changes (even optimizations and bugfixes) to 
Phobos could make it stop working:


"This predicate must be an equivalence relation, that is, it must 
be reflexive (pred(x,x) is always true), symmetric (pred(x,y) == 
pred(y,x)), and transitive (pred(x,y) && pred(y,z) implies 
pred(x,z)). If this is not the case, the range returned by 
chunkBy may assert at runtime or behave erratically."



But some additional thoughts from my sided:
I get all the lines of the file into one range. Calling array 
on it should give me an array, but how would I use find to get 
an index into this array?
With the indices I could slice up the array into four slices, 
no allocation required. If there is no easy way to just get an 
index instead of an range, I would try to use something like 
the tokenCounter to find all the indices.


The chunkBy example should not allocate. chunkBy itself is lazy, 
as are its sub-ranges. No copying of string contents is 
performed. So unless you have very specific reasons to use 
slicing, I don't see why chunkBy shouldn't be good enough.


Full disclosure:
There is a malloc call in RefCounted, which is used for 
optimization purposes when chunkBy is called on a forward range. 
When chunkBy is called on an array, that's a 6-word allocation 
(24 bytes on 32-bit, 48 bytes on 64-bit), happening once. There 
are no other dependencies that allocate.


Such is the beauty of D. :)

--
  Simen


[Issue 15782] [Reg 2.071-devel] Alias no longer strips qualifiers from user defined types

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15782

--- Comment #8 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/5fb53481fccbe800f083aeaa867d0dd541efbe67
fix Issue 15782 - Alias no longer strips qualifiers from user defined types

https://github.com/D-Programming-Language/phobos/commit/fed12920a6bfc6cbb37da8e7568cf555005632f1
Merge pull request #4094 from MartinNowak/fix15782

--


Re: Beta D 2.071.0-b1

2016-03-23 Thread deadalnix via Digitalmars-d-announce

On Thursday, 24 March 2016 at 01:49:25 UTC, Martin Nowak wrote:

First beta for the 2.071.0 release.

This release comes with many import and lookup related changes 
and fixes. You might see a lot of deprecation warnings b/c of 
these changes. We've added the -transition=import switch and 
-transition=checkimports [¹] switches to ease updating existing 
code.


http://dlang.org/download.html#dmd_beta 
http://dlang.org/changelog/2.071.0.html


Please report any bugs at https://issues.dlang.org

-Martin

[¹]: -transition=checkimports currently has a bug that creates 
false positive warnings about the $ symbols, this will be fixed 
in the next beta (Bugzilla 15825)


No bug report for it, but a PR: 
https://github.com/deadalnix/pixel-saver/pull/53


Beta D 2.071.0-b1

2016-03-23 Thread Martin Nowak via Digitalmars-d-announce
First beta for the 2.071.0 release.

This release comes with many import and lookup related changes and
fixes. You might see a lot of deprecation warnings b/c of these changes.
We've added the -transition=import switch and -transition=checkimports
[¹] switches to ease updating existing code.

http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.071.0.html

Please report any bugs at https://issues.dlang.org

-Martin

[¹]: -transition=checkimports currently has a bug that creates false
positive warnings about the $ symbols, this will be fixed in the next
beta (Bugzilla 15825)


Re: static ctors in shared libs

2016-03-23 Thread bitwise via Digitalmars-d

On Friday, 18 March 2016 at 18:52:25 UTC, Jacob Carlborg wrote:

On 17/03/16 21:27, bitwise wrote:
I've been doing some work on shared libraries for OSX, and 
have come

across a potential problem, which I'm not sure what to do with.

Currently, when a thread is spawned, that thread calls all the 
TLS
ctors, then runs the thread entry point function, and finally 
calls the

TLS dtors before the thread terminates.

Example, for windows:

https://github.com/D-Programming-Language/druntime/blob/15a227477a344583c4748d95492703901417f4f8/src/core/thread.d#L236


So, the question is, how do dynamic libraries interact here?

Example: A dynamic library contains D modules with TLS ctors. 
If I start
a few threads, and then load a dynamic library, shouldn't the 
TLS ctors

in the dynamic library be called for each running thread? If my
assumption is correct, the next question is, how do you do 
this?


I don't think you can hijack each thread and have it run the 
TLS ctors,
and you can run them all from the thread loading the shared 
library
because of synchronization issues. So what's the solution? 
Should TLS
ctors in dynamic libraries simply be specified not to run, or 
could they
somehow be run lazily at the first TLS access in a dynamic 
library?


Any thoughts on this would be appreciated.


How does it behave on Linux? It already supports dynamic 
libraries.


After looking at the elf implementation, Johannes's explanation 
seems to be correct. I don't think it's the best solution though.


I'm wondering if the _exact_ behavior of the current solution was 
intentional. It seems like everything will work fine as long as 
you only use statically linked shared libs, so I'm wondering if 
dynamic linking was fully considered at the time the current 
solution was written. As far as dynamic linking goes, I don't 
like how the current solution works. It can lead to very 
confusing problems, and I think it would be better to do an 
all-or-nothing approach:


-statically linked shared libs always have shared static ctors 
called
-statically linked shared libs always have TLS static ctors 
called for all new threads
-dynamically linked shared libs always have shared static ctors 
called
-dynamically linked shared libs NEVER have TLS static ctors 
called for ANY thread


I can see how one could argue for benefits of the current 
approach, but I don't think it's worth exposing people to that 
kind of confusion, to have partially working TLS static ctors.


Thoughts?

Bit


Re: GSOC 16 - Flatbuffer support or Protocol Buffer Support for D Language.

2016-03-23 Thread Dragos Carp via Digitalmars-d
On Wednesday, 23 March 2016 at 20:40:10 UTC, Joseph Rushton 
Wakeling wrote:

On Saturday, 19 March 2016 at 07:41:16 UTC, Timothee Cour wrote:
can https://github.com/msoucy/dproto be used as a starting 
point?


Out of curiosity, what's actually missing in dproto that a GSoC 
project could address?


Here is a short comparison dproto vs. mainline support efforts: 
https://github.com/dcarp/protobuf/issues/5.


Re: static ctors in shared libs

2016-03-23 Thread bitwise via Digitalmars-d

On Friday, 18 March 2016 at 16:23:00 UTC, Johannes Pfau wrote:

Am Fri, 18 Mar 2016 14:35:41 +
schrieb Marc Schütz :

[...]


Thanks for the explanation!

When I first looked at the elf implementation, I was confused by 
what was goign on with 
pinLoadedLibraries()/inheritLoadedLibraries(). With this problem 
in mind though, it all makes sense now.


Bit


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, items[$-1]);`.


Though it should compile the other way around, too. And it does for me.


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]);`.


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)); // Error: template 
std.array.Appender!(Thing[]).Appender.put cannot deduce function 
from argument types !()(Thing)


...?


Re: Silicon Valley D Meetup March 24, 2016

2016-03-23 Thread Ali Çehreli via Digitalmars-d-announce

Reminder...

On 03/17/2016 11:40 AM, Ali Çehreli wrote:

Stefan Brus has accepted to repeat his Berlin meetup presentation for us
remotely at his 3am! :D

"Intro to Game Development in D"

   http://www.meetup.com/D-Lang-Silicon-Valley/events/229370428/

As always, we will post a Google hangouts link at the start of the
presentation at around 7pm Pacific time.

Ali




[Issue 15825] New: dmd's -transition=checkimports reports a false positive for tuple __dollar

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15825

  Issue ID: 15825
   Summary: dmd's -transition=checkimports reports a false
positive for tuple __dollar
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: blocker
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

cat > bug.d << CODE
template anySatisfy(T...)
{
alias anySatisfy = T[$ - 1];
}

alias T = anySatisfy!(int);
CODE

dmd -transition=checkimports -c bug

bug.d(3): Deprecation: local import search method found variable
bug.anySatisfy!int.__dollar instead of variable bug.anySatisfy!int.__dollar

This creates an enormous amount of output when compiling a normal library and
renders -transition=checkimports almost unusable.

--


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 op = Someop(foo);

The following is a workaround for this example:

  auto op = Someop!Foo(foo);

I'm not sure whether Someop's implicit constructor should take part in 
deducing Someop's Type template parameter.


Ali



Re: Females in the community.

2016-03-23 Thread Walter Bright via Digitalmars-d

On 3/23/2016 3:53 AM, Bruno Medeiros wrote:

On 23/03/2016 10:51, Bruno Medeiros wrote:

OMG, this irrelevant, flamebait thread.

One thing I like with Rust is that they have a modern forum software
(discourse.org) for their community forums, in particular one that
requires registration and an associated email (unlike newsgroups where
anyone can post and emails can be spoofed easily). Even though this
registration is easy, this seems to deter a lot of these random,
anonymous, quasi-troll accounts with not much to say. (I'm not talking
about karabuta specifically but other posters in general, in this thread
and other threads)



Ugh, I'm getting quite used to being able to correct spelling errors in my posts
too, and I can't do it with the newsgroups.


No spelling checker seems to deter a lot of these random, anonymous, poor 
spellers :-)




Newsgroups are like the C++ of forum technology...


Don't conflate the NNTP protocol with the shortcomings of whatever newsreader 
you're using. Mine, for example, does spell checking. (Thunderbird FWIW)




Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread crimaniak via Digitalmars-d

On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote:

On Monday, 21 March 2016 at 11:35:49 UTC, Timothee Cour wrote:
assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a);}).equal([1, 
9, 25, 49]))

I support idea to have such feature, sometimes it really need.



Could you try to point out whats wrong with map & filter?

assert(9.iota.filter!"a%2".map!"a*a".equal([1, 9, 25, 49])


map: 1 element -> 1 element
filter: 1 element -> 0..1 element(s)

emit: 1 element -> 0..infinite elements

This feature is more generic then map() and filter() together. 
But proposed implementation is not good. I think this is good 
place for generator function with yield.
If map() will accept generators and process it as expected, 
different from ordinary functions, then additional emit() method 
is not needed. And filter() too :)




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 need to start at 0, 
because otherwise `sockets[0]` is `null`. When you add that to 
the SocketSet, it will trigger the segfault. I guess you want 
to skip the 0 because it represents the subnet address; in that 
case, you simply mustn't add `sockets[0]` to the set.


But then there is another problems: You're using `select()` the 
wrong way. The point of using select() is that you can check 
things asynchronously. Your code should be structured like this 
(pseudo code):


auto ss = new SocketSet();
for(i; 1 .. MAX) {
auto s = new Socket(...);
s.blocking = false;
s.connect(...);
ss.add(s);
}

while(ss.count > 0) {
auto write_ss = ss.dup;
auto status = Socket.select(null /* read */, write_ss /* 
write */, null /* error */, 500.msecs);

// for a connect()ing socket, writeability means connected
if(status < 0)
writeln("interrupted, retrying");
else if(status == 0)
writeln("timeout, retrying");
else {
writeln(status, " socket(s) changed state");
for(fd; 0 .. write_ss.maxfd+1) {
// check whether this socket has changed
if(!write_ss.isSet(fd)) continue;
// if yes, remove it from the original SocketSet
ss.remove(fd);
writeln("successfully connected to 192.168.0.", 
fd+1);

}
}
}


This code works fine :
--
import std.stdio;
import std.socket;
import std.conv;
import core.time;
import core.thread;

void main()
{
const int MAX = 254, TRIES = 5;
Socket[] sockets = new Socket[MAX];
string ipb = "192.168.0.";
SocketSet ss = new SocketSet();


for (int i = 0; i < MAX; i++) {
string ip = ipb~to!string(i+1);

Socket s = new Socket(AddressFamily.INET, 
std.socket.SocketType.STREAM, ProtocolType.TCP);

s.blocking = false;
InternetAddress ia = new InternetAddress(ip, 22);
sockets[i] = s;
s.connect(ia);
ss.add(s);
}
Thread.sleep(100.msecs);
for (int t = 0; t < TRIES; t++)
{
SocketSet write_ss = ss;
int status = Socket.select(null, write_ss, null, 
100.msecs);


if(status < 0)
writeln("interrupted, retrying");
else if(status == 0)
{
writeln("timeout, retrying");
} else {
writeln(status, " socket(s) changed state");
for (int i = 0; i < write_ss.tupleof[1] -2; i++) {

string ip = "192.168.0."~to!string(i+1);
Socket fd = sockets[i];
if(!ss.isSet(fd))
continue;
ss.remove(fd);
writeln("successfully connected to ", ip);
}
}
}
writeln("DONE");
}
--

When I remove the Thread.sleep, it doesn't find all adresses. Why 
?


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 duplication causes an error, I 
can't figure out how to fix.


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 op = Someop(foo);
op.foo();
  }
}

void main() {
  Foo foo;
  Bar bar;
  bar.thingy(foo);
}

=>

Error: struct derp.Someop cannot deduce function from argument 
types !()(inout(Foo))


if I put in Someop!(typeof(foo))(foo) it gives the error:

Error: variable derp.Someop!(inout(Foo)).Someop.thing only 
parameters or stack based variables can be inout


...even though Someop is a struct allocated on the stack.

What I'm dealing with is like:

struct Bar {
  void thingy(Foo foo) {
auto op = Someop(foo);
//...lotsastuff...
op.foo();
  }
  void thingy(const(Foo) foo) const {
auto op = Someop(foo);
//...lotsastuff...
op.foo();
  }
  // repeat ad-nauseum...
}


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 stack memory. Its constness isn't any more physical than with `new`.


PS: You can also allocate an explicitly immutable int:


b = new immutable(int)(*b + 1);



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 more physical than with `new`.


Re: Is C++ trying to be like D?

2016-03-23 Thread _d0s_ via Digitalmars-d

On Saturday, 19 March 2016 at 13:46:14 UTC, Anonymouse wrote:

On Saturday, 19 March 2016 at 13:23:55 UTC, Bauss wrote:
Looking at C++14 and the proposed features for C++17 - 
https://en.wikipedia.org/wiki/C%2B%2B17


It looks a lot like C++ is trying to become similar to D.

I believe that shows D's design pattern has been superior to 
C++'s from the start and there's no way C++ will ever be able 
to implement the same features of D in the same smooth and 
"user-friendly" behavior.


What's your opinion?


A much more common take on it is "why use D at all now that C++ 
is getting similar features", ignoring convenience.


(I don't subscribe to it.)


Just that awesome new features are planned, doesn't mean they get 
implemented. On of mine, and i think also of many other cpp 
programmsters, highly anticipated features are C++ Modules. We 
are waiting years already to get to a usable solution ... yet 
nothing has integrated into the cpp standard :3


D on the other hand has all those awesome features, and D has 
them now. Sometimes it's a little rough on the edges, but in 
general it's really great *.* I hope D will start to grow faster. 
And seeing it currently at Tiobe index rank 20 makes me hope that 
it will be way more widespread in future.


<3 D ftw xD



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 memory.




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 actually change anything 
when the elements are not mutable. Things would be different with a 
dynamic array.



writeln(a[0]," always constant");
writeln(," always constant");


The address of a local variable isn't exactly const/immutable in the 
sense of the type system, I think. It simply doesn't change during the 
run of the function, and afterwards it's not considered alive anymore.



writeln(b," always mutable");
writeln(*b, "constant");


Yup and yup.


b = b + 1;


Just to be 100% clear: you're adding to the pointer here, not to the 
value that's being pointed at. It's 24, because that's the second item 
in `a`.


You can also allocate a whole new int and add set it to `*b + 1`. I 
think that's closer to your original goal.



b = new int(*b + 1);



writeln(*b, "also constant, but a different one.");

something like that...




Re: GSOC 16 - Flatbuffer support or Protocol Buffer Support for D Language.

2016-03-23 Thread Rajat Kumar via Digitalmars-d

On Saturday, 19 March 2016 at 07:51:34 UTC, Joakim wrote:

On Saturday, 19 March 2016 at 06:18:06 UTC, Rajat Kumar wrote:

Hello.
I am Rajat Kumar, a junior year university student from India. 
I have working experiences in languages like C,C++ and Python. 
I am really really interested in working in D language. I want 
to work in the project - Flatbuffer Suport or Protocol Buffer 
Support.
It is now the time to write the proposal. I need some 
suggestion for the same. What are the key points, do I need to 
mention in the proposal?

thank you.


Good question.  According to the GSoC docs, the D Foundation 
can provide some guidance:


"Most organizations have their own proposal guidelines or 
templates. You should be extraordinarily careful to conform to 
these. Most organizations have many, many proposals to review. 
Failure to follow simple instructions is highly likely to land 
you at the bottom of the heap."

http://write.flossmanuals.net/gsocstudentguide/writing-a-proposal/

I don't know that we have any such guideline or template for D, 
Craig?


At the very least, you should follow the general instructions 
google provides at that link.


I have modified the proposal from the last suggestions. Please 
have a look at my proposal on Flatbuffers Support in D. So that I 
can submit it finally to Google.

https://docs.google.com/document/d/1wPDsjfUS8vbpzydi9GqfI9J-zbIS7JL1ZleGRk_42Qg/edit?usp=sharing



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 
store it where 23 is, because that's constant data. In a register 
variable? What about the next iteration? A runtime queue of 
previously calculated consts that builds up with each iteration?


...not gonna happen. So since there's nowhere to store that 24 
(without some non-const variable to store it in), you can't point 
"a" at the new address, even if 24 itself would fit inside 
another constant bit of memory just fine.


I'm actually used to the runtime queue thing, from scheme and the 
like. "a = a + 1" allocates a new bit of memory, made immutable 
and never changed from then on, storing "a + 1" in it and 
pointing a at it. And if "a + 1" has already been calculated, it 
finds that old value and reuses it.


So I think that's why you can't assign to a constant variable, is 
that there's no locating/initializing of new constant memory on 
the fly, to have a place to put that 24, 25, etc. Variables, even 
mutable variables, always have the same address, and any of us 
who are confused can think of assigment as a storage operation, 
more like erlang's "=>" rather than scheme's "(let)".


To "change" an address, you have to use a mutable pointer (or the 
like). The variable will always have the same address, but 
there's a second address stored at that address, and since the 
storage is mutable, that second address can be changed, by 
mutating the memory stored at the first address.


So like...

const(int)[2] a = [23,24];
const(int)* b = a;
writeln(," always constant");
writeln(a, " always constant");
writeln(a[0]," always constant");
writeln(," always constant");
writeln(b," always mutable");
writeln(*b, "constant");
b = b + 1;
writeln(*b, "also constant, but a different one.");

something like that...


Re: GSOC 16 - Flatbuffer support or Protocol Buffer Support for D Language.

2016-03-23 Thread Joseph Rushton Wakeling via Digitalmars-d

On Saturday, 19 March 2016 at 07:41:16 UTC, Timothee Cour wrote:
can https://github.com/msoucy/dproto be used as a starting 
point?


Out of curiosity, what's actually missing in dproto that a GSoC 
project could address?


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 that LDC 
will still compile without it, but dub will try to compile it 
anyway because it's in the dependencies JSON dictionary.


Re: GtkD 3.3.0 released, GTK+ with D.

2016-03-23 Thread Gerald via Digitalmars-d-announce

On Wednesday, 23 March 2016 at 18:16:02 UTC, Mike Wey wrote:
GtkD is a D binding and OO wrapper of Gtk+ and is released on 
the LGPL

license.

A new version of GTK was released today, and with that comes a 
new GtkD release so you can use the new features in D.


GtkD 3.3.0 is now available on gtkd.org:
http://gtkd.org/download.html


Awesome, thanks for all of your continued hard work on this Mike. 
Look forward to trying it!


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 a whole string, and split 
the string with:

splitter(fileString, [token1, token2, ... tokenN]);

And would like to get a range of strings each starting with 
tokenX and ending before the next token.


Does something like this exist?

I know how to parse the string line by line and create new 
strings and append the appropriate lines, but I don't know how 
to do this with a lazy result range and new allocations.


This isn't tested, but this is my first thought:

void main(){
string testString = "this:is:a-test;"
foreach(str; testString.multiSlice([":","-",";"]))
   writefln("Got: %s", str);
}

auto multiSlice(string string, string[] delims){
   struct MultiSliceRange{
string m_str;
string[] m_delims;
bool empty(){
   return m_str.length == 0;
}

void popFront(){
   auto idx = findNextIndex;
   m_str = m_str[idx..$];
   return;
}

string front(){
auto idx = findNextIndex;
return m_str[0..idx];
}
private long findNextIndex(){
long foundIndex=-1;
foreach(delim; m_delims){
if(m_str.canFind(delim)){
if(foundIndex == -1 || m_str.indexOf(delim) 
>= 0)){

 foundIndex = m_str.indexOf(delim);
}
}
}
return foundIndex;
}
   }

   return MultiSliceRange(string, delims);
}


Again, totally untested, but I think logically it should work. ( 
No D compiler on this machine so it mightn't even compile :] )


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

ag0ae...@gmail.com changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from ag0ae...@gmail.com ---
(In reply to hsteoh from comment #8)
> Oh, was this only fixed in stable?

Yup.

> I'm testing with latest git HEAD.

I'm closing as fixed again, assuming it works for you with stable.

--


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;
assert (bb !is null);
}


Magnificent! Thank you ! :)


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 passing 
a pointer to it!), but it's not for the 32-bit x86 and x86_64 
System V (used on all non-Windows platforms) ABIs. System V is 
especially elaborate and may pass structs up to twice the size of 
a register in 2 registers. Bigger structs passed by value are 
blitted into the function arguments stack in memory. They are 
then accessed by the callee via a stack offset, that's correct, 
but I wouldn't call that implicit-by-ref-passing, as copying does 
take place, unless the optimizer decides it's unnecessary.


So passing structs > 64-bit by value on Win64 never pays off 
(there's always an indirection); using `const ref(T)` where 
possible makes sure you at least elide the copy. But then again, 
you'll very soon find out that it's not really an option as 
rvalues cannot be passed byref in D, something a lot of people 
[including myself if not already obvious :)] hate about D.


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

--- Comment #8 from hst...@quickfur.ath.cx ---
Oh, was this only fixed in stable?

I'm testing with latest git HEAD.

--


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

--- Comment #7 from ag0ae...@gmail.com ---
(In reply to hsteoh from comment #6)
> This bug has not yet been (fully) fixed:
> 
> --
> import std.stdio;
> class Wrapper
> {
> typeof(stdin.byLine()) src;
> }
> void main()
> {
> auto x = new Wrapper();
> x.src = stdin.byLine();
> }
> --
> 
> Run as 'echo | ./program'. Output:
> 
> --
> core.exception.InvalidMemoryOperationError@src/core/exception.d(693):
> Invalid memory operation
> --

Works for me. Are you testing with stable?

--


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 that users don't see 
any interruption of service. That's how Google and Amazon do it.

There are a bare handful of systems that let you avoid that process. In 
general, it's hard enough for humans to reason about how their 
application's durable state will handle application updates; adding 
volatile state into the picture is much harder, and for little gain.


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

hst...@quickfur.ath.cx changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #6 from hst...@quickfur.ath.cx ---
This bug has not yet been (fully) fixed:

--
import std.stdio;
class Wrapper
{
typeof(stdin.byLine()) src;
}
void main()
{
auto x = new Wrapper();
x.src = stdin.byLine();
}
--

Run as 'echo | ./program'. Output:

--
core.exception.InvalidMemoryOperationError@src/core/exception.d(693): Invalid
memory operation
--

--


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 recommended way to get a few bytes and 
keep on advancing.


Doing *anything* to a range invalidates it (or at least you 
should expect it to), a range is read-once. Never reuse a range. 
Some ranges can be saved in order to use a copy of it, but never 
expect a range to be implicitely reusable.



For instance, to read a ushort, I use
range.read!(ushort)()
Unfortunately, it reads a single value.

For now, I use a loop

foreach (element ; range.enumerate) {
  buffer[i] = range.front;
  range.popFront();
  }

Is there a more idiomatic way to do the same thing?


Two ways, the first one being for reference:

import std.range: enumerate;
foreach (element, index ; range.enumerate) {
buffer[index] = element;
}

And the other one

In Scala, 'take' consumes bytes from the iterator. So the same 
code would be

buffer = range.take(N).toArray


Then just do that!

import std.range, std.array;
auto buffer = range.take(N).array;

auto example = iota(0, 200, 5).take(5).array;
assert(example == [0, 5, 10, 15, 20]);



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 elements, it 
will only give you as many as the range contains. If If you're trying to 
deserialize something, takeExactly is probably better.


http://dpldocs.info/experimental-docs/std.range.takeExactly.html
http://dpldocs.info/experimental-docs/std.array.array.1.html


Re: Females in the community.

2016-03-23 Thread Chris Wright via Digitalmars-d
On Wed, 23 Mar 2016 14:40:07 -0400, Andrei Alexandrescu wrote:
> I'm not sure what was being implied, but just to clarify a few simple
> facts: Janice and I never interacted on IRC.

I was comparing reactions to you with reactions to Janice. I did not 
intend to imply that you harassed anyone. The portions of your conduct 
that I have seen have been professional.


Re: Females in the community.

2016-03-23 Thread Andrei Alexandrescu via Digitalmars-d

On 03/23/2016 12:42 AM, Vladimir Panteleev wrote:

On Tuesday, 22 March 2016 at 20:37:27 UTC, Chris Wright wrote:

On Tue, 22 Mar 2016 19:33:47 +, deadalnix wrote:


On Tuesday, 22 March 2016 at 18:19:16 UTC, Chris Wright wrote:

There was Janice Caron, who was helpful and eager and got a fair bit
of code into phobos. From what I recall, she was not well treated by
the community.



[citation needed]


It was on IRC in a private channel. I don't keep IRC logs for more
than five years.


Janice Caron's last post was in 2008. I've been on #d since 2006, and
the first time I've seen Andrei on IRC was in 2010.

Additionally, I've met Andrei in person on multiple occasions.

I find this extremely hard to believe.


I'm not sure what was being implied, but just to clarify a few simple 
facts: Janice and I never interacted on IRC. She and I had a meaningful 
private correspondence for a good while, during which she also revealed 
her identity. I do remember a flamewar in this forum that she found 
harassing, which I did not take part to and which is not easy to find 
and follow because some posts have been removed at the posters' request. 
We'd do good to generally avoid colportage of rumor. And of course, 
making this forum friendlier and more welcoming is something we always 
should aspire to. Thanks! -- Andrei




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 next release. But it's not yet in 
master, which means it's also not going to be in the nightlies for now.


[Issue 12391] DirEntries throws in foreach

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12391

--- Comment #6 from Jason Spashett  ---
Could we not take something out of python's book (or some other language):

os.walk https://docs.python.org/2/library/os.html

(1) This [os.walk] gives an opportunity to have an error handler during the
walk. 
(2) alternatively a parameter that accepts a range that becomes a list of
errors.
(3) something else...

#2 doesn't seem that flexible looking at it, #1 would seem to be the way, as it
acts as a predicate in python too, if an exception is thrown from the error
handler the walk is stopped, otherwise it is not.

Often times I would like to ignore errors but log them. Other times better to
stop the traversal.

--


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 == ';' || e == ',');
assert(equal(b, ["a", "b", "c"]));

However, not only are the separators lost in the process, it 
only allows single-element separators. This might be good 
enough given the information you've divulged, but I'll hazard a 
guess it isn't.


My next stop is std.algorithm.chunkBy:

auto a = ["a","b","c", "d", "e"];
auto b = a.chunkBy!(e => e == "a" || e == "d");
auto result = [
tuple(true, ["a"]), tuple(false, ["b", "c"]),
tuple(true, ["d"]), tuple(false, ["e"])
];

No assert here, since the ranges in the tuples are not arrays. 
My immediate concern is that two consecutive tokens with no 
intervening values will mess it up. Also, the result looks a 
bit messy. A little more involved, and according to 
documentation not guaranteed to work:


bool isToken(string s) {
return s == "a" || s == "d";
}

bool tokenCounter(string s) {
static string oldToken;
static bool counter = true;
if (s.isToken && s != oldToken) {
oldToken = s;
counter = !counter;
}
return counter;
}

unittest {
import std.algorithm;
import std.stdio;
import std.typecons;
import std.array;

auto a = ["a","b","c", "d", "e", "a", "d"];
auto b = a.chunkBy!tokenCounter.map!(e=>e[1]);
auto result = [
["a", "b", "c"],
["d", "e"],
["a"],
["d"]
];
writeln(b);
writeln(result);
}

Again no assert, but b and result have basically the same 
contents. Also handles consecutive tokens neatly (but 
consecutive identical tokens will be grouped together).


Hope this helps.

--
  Simen


Thanks Simen,
your tokenCounter is inspirational, for the rest I'll take some 
time for testing.


But some additional thoughts from my sided:
I get all the lines of the file into one range. Calling array on 
it should give me an array, but how would I use find to get an 
index into this array?
With the indices I could slice up the array into four slices, no 
allocation required. If there is no easy way to just get an index 
instead of an range, I would try to use something like the 
tokenCounter to find all the indices.






GtkD 3.3.0 released, GTK+ with D.

2016-03-23 Thread Mike Wey via Digitalmars-d-announce

GtkD is a D binding and OO wrapper of Gtk+ and is released on the LGPL
license.

A new version of GTK was released today, and with that comes a new GtkD 
release so you can use the new features in D.


GtkD 3.3.0 is now available on gtkd.org:
http://gtkd.org/download.html

--
Mike Wey


[Issue 11791] std.file.write failed to write huge files

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11791

Dmitry Olshansky  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||dmitry.o...@gmail.com
 Resolution|INVALID |---

--- Comment #7 from Dmitry Olshansky  ---
> If you want to write more you must use a stream and write several buffers or 
> use append(). std.stdio.File works because it doesn't bulk-write.

Personally std.file could just write huge memory chunks in multiple write
calls. There is no requirement for it to be single syscall.

--


Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread Tamas via Digitalmars-d

On Wednesday, 23 March 2016 at 17:29:55 UTC, Nick Treleaven wrote:

On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote:

On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote:

Could you try to point out whats wrong with map & filter?

It's hard to do stuff like this:

assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a); if(a%3==0) 
put(a);}).equal([1,9,3,25,6,49]));


Seems doable:
mapFilter!((a){if(a%2) return some(a*a); if(a%3==0) return 
some(a); return none;})


This one emits only 1 element when a==3. (BTW what is `mapFilter` 
and `some`?)


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 a listing for "D7", "10",
"FZC7", "7" and so on?


Not exactly sure what you need. But it's possible to get all classes at 
runtime like this [1].


For functions, there's really no pretty way to do that. You can either 
implement runtime reflection using compile time reflection, which will 
most likely require you to modify the code you want to inspect. Or you 
can inspect the symbol table in the binary/shared library, which is a 
bit complicated and platform dependent.


[1] 
https://github.com/D-Programming-Language/druntime/blob/master/src/object.d#L973


--
/Jacob Carlborg


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 the new code.


--
/Jacob Carlborg


Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread Nick Treleaven via Digitalmars-d

On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote:

On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote:

Could you try to point out whats wrong with map & filter?

It's hard to do stuff like this:

assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a); if(a%3==0) 
put(a);}).equal([1,9,3,25,6,49]));


Seems doable:
mapFilter!((a){if(a%2) return some(a*a); if(a%3==0) return 
some(a); return none;})


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 only few 
functions need to be replaced.


Has someone experience with handling upgrading/updating D-Apps 
on the fly?


Working with dynamic libraries or distributed components is not 
secure enough,
but maybe there are solutions, maybe around base calls and 
functions or completely different.



Regards, Ozan


Do you have an example of this being done in any other language? 
Essentially whatever code is being replaced, you're going to need 
to recompile it. If you're not using dynamic/shared libraries 
Adam is pointing you in the right direction.


If it is a desktop application then it is probably easiest if it 
communicates to a local service that provides the "replaceable" 
functions, when you stand up the new service the app can transfer 
the communication to it.


I can't speak to your security concerns.


Re: Females in the community.

2016-03-23 Thread deadalnix via Digitalmars-d

On Wednesday, 23 March 2016 at 11:33:55 UTC, QAston wrote:
Why don't we look past the superficial stuff in the language 
and assume good intent?


Because some people have nothing of substance to contribute, but 
still want to feel superior.




Re: Females in the community.

2016-03-23 Thread Ola Fosheim Grøstad via Digitalmars-d

On Wednesday, 23 March 2016 at 12:35:59 UTC, QAston wrote:
And yes, I'm saying that the world of programming has a history 
of accepting "weird" people. That's partially because we have a 
clear measurment: either your stuff works or it doesn't. No 
need for identity wars. Computing was dominated by women after 
the ww2, it was shifted towards men later on. Maybe it will 
shift back. Who cares - we all have so much in common as 
programmers that it doesn't really matter which parts of your 
body hang down.


Fair enough, but here is some background worth mentioning.

In high school I went to a section that was geared towards 
computers and electronics. We started with 3 girls and lots of 
boys from all over the city. After a year we only had 1 girl 
left, and I don't recall any of the boys quitting. She was a 
cute, natural, bubbly girl, but in order to get an easier time 
she changed into a more silent/serious and mainstream girl which 
made her more accepted by the teenage boys. When we had classes 
with another class with more girls the boys dampened their 
comments... basically the presence of girls made them moderate 
themselves and act less obnoxious towards others (both boys and 
girls). Studies generally say that mixed groups do provide a more 
satisfactory environment. That'a probably true for online forums 
too.


In the army I had the same kind of experience. Male dominating 
and somewhat rough. The women that persists in such environments 
tend to take on less feminine manners too in order to gain 
respect. Although we also had a very feminine, extremely pretty, 
sergeant who did gain some respect, but her first inspection got 
very awkward, the men lost words, stuttered, giggled and 
generally had trouble keeping a straight face. She totally 
enjoyed it! So gender does create very real differences, 
sometimes suppressing (forcing women to become more like men), 
sometimes empowering.


In the academic sector the situation was better. Still male 
dominated, but more general awareness of gender issues. Still, as 
a teacher you can see that one strong female student in a male 
dominated group can do well and take the group leader position, 
but that more average students might benefit from having 
all-female groups.


I have absolutely no doubt that women are just a good programmers 
as men, but in my experience women in informatics tends to 
gravitate towards topics where they get to work with other people 
in addition to the technology. At one department meeting where we 
discussed how to attract more women to the Comp. Sci. department, 
one of the very bright professors said that she wasn't sure if we 
actually would do those women a favour since pure computer 
science is such a dull and meaningless topic... ;-) Of course, 
the gender percentage is not the real issue, the real issue is to 
make the study attainable and enjoyable for all. If only a small 
percentage of all women find it meaningful, then that is quite 
understandable and hardly a disaster, but if they don't even 
consider Compi. Sci. because it is male dominated then that is 
not good either.


Anyway, I think the mixed settings makes for better norm 
formation and interesting interaction, but we cannot declare that 
there should be more women interested in system level 
programming. In my experience that path starts in the early geeky 
teens by kids picking hardware to pieces... So we are basically 
stuck with the discourse of a male dominated community, which is 
not ideal, even for the male participants IMHO.




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 these names? Is there a 
listing for "D7", "10", "FZC7", "7" and so on?


Solved in the core.demangle module...
The demangle module converts mangled D symbols to a 
representation similar to what would have existed in code.


Regards, Ozan


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 exgold2.scl**
vector per node: 1 Displacement   exgold2.dis**

TIME
time set:  1
number of steps:   3
filename start number: 0
filename increment:1
time values:   1.0   2.0   3.0


The separators would be ["FORMAT", "TIME", "VARIABLE", 
"GEOMETRY"].
The blank lines between the blocks and the order of the 
separators in the file is not known.
I would expect a range of four ranges of lines: one for each 
text-block above.





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 a whole string, and split 
the string with:

splitter(fileString, [token1, token2, ... tokenN]);

And would like to get a range of strings each starting with 
tokenX and ending before the next token.


Does something like this exist?

I know how to parse the string line by line and create new 
strings and append the appropriate lines, but I don't know how 
to do this with a lazy result range and new allocations.


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 == ';' || e == ',');
assert(equal(b, ["a", "b", "c"]));

However, not only are the separators lost in the process, it only 
allows single-element separators. This might be good enough given 
the information you've divulged, but I'll hazard a guess it isn't.


My next stop is std.algorithm.chunkBy:

auto a = ["a","b","c", "d", "e"];
auto b = a.chunkBy!(e => e == "a" || e == "d");
auto result = [
tuple(true, ["a"]), tuple(false, ["b", "c"]),
tuple(true, ["d"]), tuple(false, ["e"])
];

No assert here, since the ranges in the tuples are not arrays. My 
immediate concern is that two consecutive tokens with no 
intervening values will mess it up. Also, the result looks a bit 
messy. A little more involved, and according to documentation not 
guaranteed to work:


bool isToken(string s) {
return s == "a" || s == "d";
}

bool tokenCounter(string s) {
static string oldToken;
static bool counter = true;
if (s.isToken && s != oldToken) {
oldToken = s;
counter = !counter;
}
return counter;
}

unittest {
import std.algorithm;
import std.stdio;
import std.typecons;
import std.array;

auto a = ["a","b","c", "d", "e", "a", "d"];
auto b = a.chunkBy!tokenCounter.map!(e=>e[1]);
auto result = [
["a", "b", "c"],
["d", "e"],
["a"],
["d"]
];
writeln(b);
writeln(result);
}

Again no assert, but b and result have basically the same 
contents. Also handles consecutive tokens neatly (but consecutive 
identical tokens will be grouped together).


Hope this helps.

--
  Simen


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", "FZC7", "7" and so on?



Regards, Ozan




[Issue 15816] ICE void ddmd.dclass.__assert(int) with error: anonymous classes not allowed

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15816

Kenji Hara  changed:

   What|Removed |Added

   Keywords||ice, pull
   Hardware|x86 |All
 OS|Mac OS X|All

--- Comment #2 from Kenji Hara  ---
https://github.com/D-Programming-Language/dmd/pull/5565

--


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 for a more derived type.


Ok but how to handle sittuation like this ?

class TypeHolder{
import std.variant;
Variant[TypeInfo] data;

void add(T)(T value){
data[typeid(value)]=value;
}

T getByType(T)(){
Variant retVar=data.get(typeid(T),Variant(null));
T val=retVar.get!T; //fails
return val;
}

}
unittest{
import std.variant;
A a= new A;
B b= new B;
C c = new C;

A ab= new B;
A ac = new C;
TypeHolder holder = new TypeHolder;
holder.add(a);
holder.add(ab);
holder.add(ac);
assert(holder.data.length==3);
A result=holder.getByType!A;
assert(result==a);
result=holder.getByType!B; //fails
assert(result==ab);
result=holder.getByType!C; //fails
assert(result==ac);
}

I can hold objects in other AA but Object[TypeInfo] rather  than 
Variant. Or is there a way to get super type of provided T ?





[Issue 15824] 'scope' attribute ignored when making an alias to a scope delegate

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15824

Mathias Lang  changed:

   What|Removed |Added

 CC||mathias.l...@sociomantic.co
   ||m, pub...@dicebot.lv

--


[Issue 15824] New: 'scope' attribute ignored when making an alias to a scope delegate

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15824

  Issue ID: 15824
   Summary: 'scope' attribute ignored when making an alias to a
scope delegate
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: mathias.l...@sociomantic.com

The following code fails to compile:

```
alias scope void delegate() AltDg;

void foo (AltDg dg) @nogc {}
void main () @nogc {
uint i;
foo(() { i = 1; });
}
```

Error message:
`foo.d(4): Error: function D main @nogc function allocates a closure with the
GC`

Using `void foo (scope AltDg dg) @nogc {}` works fine.

--


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 => output example?


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
mt.


See also: http://code.dlang.org/packages/htmld


Re: Females in the community.

2016-03-23 Thread Marco Leise via Digitalmars-d
Am Wed, 23 Mar 2016 11:33:55 +
schrieb QAston :

> https://marketplace.visualstudio.com/items?itemName=shinnn.alex

"The novelist from my motherland excites a lot of sci-fi
addicts by his crazy storytelling."

… (from the screen-shot) turns into …

"The novelist from my native land excites a lot of sci-fi
people with a drug addiction by their disgusting storytelling."

I feel safer now, having avoided these lingual traps.

-- 
Marco



[Issue 15823] opIndex doesn't work for const std.variant.Variant

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15823

--- Comment #1 from Maksim Zholudev  ---
https://github.com/D-Programming-Language/phobos/pull/4112

--


Re: [Request] A way to extract all instance of X from a range

2016-03-23 Thread Marc Schütz via Digitalmars-d

On Wednesday, 23 March 2016 at 11:36:39 UTC, Nick Treleaven wrote:
On Tuesday, 22 March 2016 at 20:09:51 UTC, Matthias Bentrup 
wrote:
It is logically just a combination of map and concat (which 
turns a range of ranges into a combined range, but I think 
that one is missing in the std lib too).


http://dlang.org/phobos/std_range.html#.chain


Or joiner(), if you have a range of ranges:
http://dlang.org/phobos/std_algorithm_iteration.html#.joiner


[Issue 15823] New: opIndex doesn't work for const std.variant.Variant

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15823

  Issue ID: 15823
   Summary: opIndex doesn't work for const std.variant.Variant
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: maxim...@gmail.com

Test:
--
import std.variant;

void main()
{
const v = Variant([1, 2, 3]);
auto f = v[1]; // <--- ERROR
}
--

Output:
--
test.d(6): Error: template std.variant.VariantN!32LU.VariantN.opIndex cannot
deduce function from argument types !()(int) const, candidates are:
/usr/include/dmd/phobos/std/variant.d(1082):   
std.variant.VariantN!32LU.VariantN.opIndex(K)(K i)
--

--


Re: 2016Q1: std.blas

2016-03-23 Thread paper rewriter via Digitalmars-d-announce
Whatever your reason may be for wanting to rewrite your paper it 
can still be a difficult task.To improve the language and 
structure of the original. Also, To target a different audience 
with your writing.


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: 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 
start it. Tell the web server to start using the new one for all 
new connections without breaking any existing connections.


Then when all existing connections are finished, you can stop the 
old one and remove it.


Re: Females in the community.

2016-03-23 Thread QAston via Digitalmars-d
On Wednesday, 23 March 2016 at 12:04:19 UTC, Ola Fosheim Grøstad 
wrote:
Actually, the D forums can be quite hostile at times, but it 
doesn't last for a very long.


I've actually spent years of my life studying social 
interaction on the internet and virtual worlds, academically. 
So you will most likely fail to engage me at a level where I 
can learn anything from your "citations".


What exactly are you trying to tell me? That programmers are 
somehow outcasts, by what definition? Even if it was true, then 
maybe it would be the other way around, given that system level 
programming is an extremely time consuming activity.


Oh, what I was posting weren't citations either obviously. That 
was the point: we could argue both ways. Either way - it don't 
matter.


And yes, I'm saying that the world of programming has a history 
of accepting "weird" people. That's partially because we have a 
clear measurment: either your stuff works or it doesn't. No need 
for identity wars. Computing was dominated by women after the 
ww2, it was shifted towards men later on. Maybe it will shift 
back. Who cares - we all have so much in common as programmers 
that it doesn't really matter which parts of your body hang down.


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 experience with handling upgrading/updating D-Apps on 
the fly?


Working with dynamic libraries or distributed components is not 
secure enough,
but maybe there are solutions, maybe around base calls and 
functions or completely different.



Regards, Ozan


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: Females in the community.

2016-03-23 Thread Ola Fosheim Grøstad via Digitalmars-d

On Wednesday, 23 March 2016 at 10:46:22 UTC, QAston wrote:
[citations needed] for so much you post. You need to update 
your knowledge of evo-psych.


You should learn not to open a reply with going ad hominem. The 
fact that you don't, suggests to me that I've struck a nerve and 
that you basically don't have much to add to this debate...


I am also not basing my statements on pseudo-scientific 
evo-psych...



I could tell you exact opposite:  men are the  more 
coopoerative sex.


I haven't said anything about one sex being more cooperative than 
the other.



You know when males are competitive? When they compete for 
female attention.


Men position themselves also with other men they like, women are 
more likely to compete with people they don't like and more 
likely to downplay their own position with people they like to 
put themselves at the same level and create a connection. You 
very rarely see men claim that they are less capable in order to 
connect with people they like. The average woman communicate more 
at the personal level, are more likely to resolve issues they 
have, and are less likely to commit suicide as a result. Those 
are facts.


Statistical gender differences are real, measurable and 
observable to anyone willing to look at it. Does it apply at the 
individual level? No. There are greater differences between 
individuals than between genders.


However, an all-female community and an all-male community have 
typically different characteristics. Both online and offline.


You know why programming attracts various social outcasts? 
Because we've always been welcoming. Don't fuck that up.


Actually, the D forums can be quite hostile at times, but it 
doesn't last for a very long.


I've actually spent years of my life studying social interaction 
on the internet and virtual worlds, academically. So you will 
most likely fail to engage me at a level where I can learn 
anything from your "citations".


What exactly are you trying to tell me? That programmers are 
somehow outcasts, by what definition? Even if it was true, then 
maybe it would be the other way around, given that system level 
programming is an extremely time consuming activity.




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, [token1, token2, ... tokenN]);

And would like to get a range of strings each starting with 
tokenX and ending before the next token.


Does something like this exist?

I know how to parse the string line by line and create new 
strings and append the appropriate lines, but I don't know how to 
do this with a lazy result range and new allocations.


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 allocate the data - in the GC 
heap or outside it. Depending on your answers there are different 
approaches. It's all solvable if you pause and think what exactly 
you're trying to do.




Re: Question about version ( ) keyword

2016-03-23 Thread Nick Treleaven via Digitalmars-d

On Monday, 21 March 2016 at 14:51:48 UTC, Vincent R wrote:
version( CRuntime_Glibc ) || version( FreeBSD ) || version 
(Solaris)

{


As a workaround, you can do it with static if and version strings:
http://forum.dlang.org/post/op.vkshabecot0hzo@las-miodowy


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 15822] InvalidMemoryOperationError when calling GC.removeRange/Root from a finalizer

2016-03-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15822

--- Comment #5 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/d23d7efb3649cd543e8d0b10b9a32ab3325f5cd0
fix Issue 15822 - InvalidMemoryOperationError when calling GC.removeRange/Root
from a finalizer

- use separate locks for GC.add/removeRange/Root
- avoids GC.lock contention for manual memory management

https://github.com/D-Programming-Language/druntime/commit/c6ac077a8d544fab65b1973b385c6f479697fb0e
Merge pull request #1519 from MartinNowak/fix15822

fix Issue 15822 - InvalidMemoryOperationError when calling GC.removeRange/Root
from a finalizer

--


Re: Females in the community.

2016-03-23 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 23 March 2016 at 10:25:46 UTC, Vladimir Panteleev 
wrote:

Also because the GP used the word "vitriol".


Yes, but Chris has already stated that he is a Social Justice 
Warrior, so he might object to things others don't :-).






Re: [Request] A way to extract all instance of X from a range

2016-03-23 Thread Nick Treleaven via Digitalmars-d

On Tuesday, 22 March 2016 at 20:09:51 UTC, Matthias Bentrup wrote:
It is logically just a combination of map and concat (which 
turns a range of ranges into a combined range, but I think that 
one is missing in the std lib too).


http://dlang.org/phobos/std_range.html#.chain


Re: Females in the community.

2016-03-23 Thread QAston via Digitalmars-d

On Tuesday, 22 March 2016 at 20:43:07 UTC, Chris Wright wrote:
Helping others to be polite is in fact progressive and 
enlightened. Your response is neither.


The problem with this idea is that you need an authority which 
decides what is the correct polite speech and what's not. There's 
no registry of universally polite speech. There can't be. I 
remind you - this post is made in a forum of a programming 
language over 10 years old and there're still major syntax change 
requests posted (DAE hove/hate semicolons?).


You can't please everyone. People have different ideas about 
what's offensive/progressive. As long as you're agreeing with the 
authority you're fine, the problem starts when you're not. You 
are going to get old and stop keeping up with the progressive 
idea of the day. Did you know that motherland is now a regressive 
word? Here's a VS addon to remind you of that:


https://marketplace.visualstudio.com/items?itemName=shinnn.alex

Why don't we look past the superficial stuff in the language and 
assume good intent? Do we really need to stand on moral high 
ground and look down on people less skilled in communicating 
politely? Is drama and infantilization of the community worth 
that feeling you get when 1-upping a regressive person? This time 
could be spent better by making awesome libraries for example. 
With that bluntly communicating person.


  1   2   >