Re: Precise GC state

2017-11-23 Thread Ola Fosheim Grøstad via Digitalmars-d

On Friday, 24 November 2017 at 05:34:14 UTC, Adam Wilson wrote:
RAII+stack allocations make sense when I care about WHEN an 
object is released and wish to provide some semblance of 
control over deallocation (although as Andrei has pointed out 
numerous time, you have no idea how many objects are hiding 
under that RAII pointer). But there are plenty of use cases 
where I really don't care when memory is released, or even how 
long it takes to release.


A GC makes most sense when the compiler fail at disproving that 
an object can be part of  cycle of references that can be 
detached.


So it makes most sense for typically long lived objects. Imagine 
if you spend all the effort you would need to put into getting a 
generational GC to work well into implementing pointer analysis 
to improve automatic deallocation instead…


In order to speed up generated code that allows a generational GC 
to run you still would need a massive amount of work put into 
pointer analysis + all the work of making a state of the art GC 
runtime.


Most people consider designing and implementing pointer analysis 
to be difficult. The regular data flow analysis that the D 
compiler has now is trivial in comparison. Might need a new IR 
for it, not sure.



Obviously my pattern isn't "wrong" or else DMD itself is 
"wrong". It's just not your definition of "correct".


Well, you could redefine the semantics of D so that you disallow 
unsafe code and possibly some other things. Then maybe have 
generational GC would be easy to implement if you don't expect 
better performance than any other high level language.



Another use case where RAII makes no sense is GUI apps. The 
object graph required to maintain the state of all those 
widgets can be an absolute performance nightmare on 
destruction. Closing a window can result in the destruction of 
tens-of-thousands of objects (I've worked on codebases like 
that), all from the GUI thread, causing a hang, and a bad user 
experience. Or you could use a concurrent GC and pass off the 
collection to a different thread. (See .NET)


Sounds like someone didn't do design before the started coding 
and just kept adding stuff.


Keep in mind that OS-X and iOS use reference counting for all 
objects and it seems to work for them. But they also have put a 
significant effort into pointer-analysis to reduce ref-count 
overhead, so still quite a lot more work for the compiler 
designer than plain RAII.


Your arguments are based on a presupposition that D should only 
be used a certain way;


No, it is based on what the D language semantics are and the 
stated philosophy and the required changes that it would involve.


I have no problem with D switching to generational GC. Like you I 
think most programs can be made to work fine with the overhead, 
but then you would need to change the philosophy that Walter is 
following. You would also need to either invest a lot into 
pointer analysis to keep a clean separation between GC-references 
and non-GC references, or create a more unforgiving type system 
that ensure such separation.


I think that having a generational GC (or other high level 
low-latency solutions) probably would be a good idea, but I don't 
see how anyone could convince Walter to change his mind on such 
issues. Especially as there are quite a few semantic flaws in D 
that would be easy to fix, that Walter will not fix because he 
like D as it is or thinks it would be too much of a breaking 
change.


You would need to change the D philosophy from "performant with 
some convenience" to "convenience with some means to write 
performant code".


I agree with you that the latter philosophy probably would 
attract more users. It is hard to compete with C++ and Rust on 
the former.


But I am not sure if Walter's goal is to attract as many users as 
possible.




Re: Intellij D Language v1.15.2

2017-11-23 Thread ikod via Digitalmars-d-announce

On Thursday, 23 November 2017 at 20:11:01 UTC, singingbush wrote:
Hi all. A new release intellij-dlanguage plugin has been made 
available for download from the Jetbrains repository this week.



There is also support for debugging with GDB (since v1.14 1st 
Nov). We need to completely overhaul our documentation as some 
of it is outdated now and there is no mention of the gdb 
support. If anyone with Java/Kotlin experience wants to get 
involved with helping squash bugs then we welcome pull requests 
so please feel free to browse the issues on our github 
repository and get involved.


https://github.com/intellij-dlanguage/intellij-dlanguage

If you find the plugin helpful please also rate the plugin:

https://plugins.jetbrains.com/plugin/8115-d-language


Thanks a lot for the Structure view!
Plugin became better with each release.



Re: Looking for a job in USA

2017-11-23 Thread codephantom via Digitalmars-d

On Friday, 24 November 2017 at 06:13:59 UTC, Mike Parker wrote:

On Friday, 24 November 2017 at 05:36:52 UTC, codephantom wrote:

btw. I read somewhere that this forum software can't delete 
threads. That sounds pretty silly. Even sillier if it's true.


The forum software is a frontend for a newsgroup server, which 
also backs a mailing list. Although it would be possible to add 
a feature to delete posts from the local cache the forum uses, 
it wouldn't be something that could be synced across the other 
interfaces. Editing is tricky to implement, too.


And because we don't have moderators or require accounts, it's 
been longstanding policy here that we're on the honor system 
with our posts posts. In order to maintain a healthy 
environment and avoid toxic flamewars, politics and religion 
are discouraged as topics of discussion.


interesting. thanks for the explanation though.

Politics and religion seem a touchy topic in the U.S.

I guess this where Australians differ a lot with our U.S friends.

Anyway, happy to comply ;-)

God bless you, and may God bless the United States of America..

whoopps.



Re: Looking for a job in USA

2017-11-23 Thread Mike Parker via Digitalmars-d

On Friday, 24 November 2017 at 05:36:52 UTC, codephantom wrote:

btw. I read somewhere that this forum software can't delete 
threads. That sounds pretty silly. Even sillier if it's true.


The forum software is a frontend for a newsgroup server, which 
also backs a mailing list. Although it would be possible to add a 
feature to delete posts from the local cache the forum uses, it 
wouldn't be something that could be synced across the other 
interfaces. Editing is tricky to implement, too.


And because we don't have moderators or require accounts, it's 
been longstanding policy here that we're on the honor system with 
our posts posts. In order to maintain a healthy environment and 
avoid toxic flamewars, politics and religion are discouraged as 
topics of discussion.


Re: Precise GC state

2017-11-23 Thread Dmitry Olshansky via Digitalmars-d

On Friday, 24 November 2017 at 05:34:14 UTC, Adam Wilson wrote:

On 11/23/17 13:40, Ola Fosheim Grøstad wrote:
On Thursday, 23 November 2017 at 20:13:31 UTC, Adam Wilson 
wrote:

I would focus on a generational GC first for two reasons. The


But generational GC only makes sense if many of your GC 
objects have a
short life span. I don't think this fits well with sensible 
use of a
language like D where you typically would try to put such 
allocations on

the stack and/or use RAII or even an arena.



Sensible to whom? The great thing about D is that it works just 
we well for low-level people who need to wring the most out of 
the metal, AND the high-level productivity minded apps people, 
who don't.




The problem with generational GC is “write barriers” - pieces of 
code compiler needs to insert around every write of a pointer.


Now given that we can cast pointer to integer and back (also 
unions), I don’t see how it would work unless we put write 
barriers everywhere on the off-chance it did wrote a pointer from 
OLD to NEW space.


A better GC is a great direction. Generational one is not 
feasible unless we disallow quite a few of our features.


Re: Looking for a job in USA

2017-11-23 Thread codephantom via Digitalmars-d

On Friday, 24 November 2017 at 04:33:52 UTC, Walter Bright wrote:
These posts have nothing to do with D, so please stop posting 
them. This isn't a political forum.


Also, perhaps you could delegate the policing of off topic 
threads to someone else..??


We could all use your attention elsewhere:

https://issues.dlang.org/buglist.cgi?bug_status=NEW=dmd=D_format=advanced=---_desc=d_desc_type=allwordssubstr

btw. I read somewhere that this forum software can't delete 
threads. That sounds pretty silly. Even sillier if it's true.


You could ask someone to volunteer, to waste their time policing 
the threads, looking for off topic discussions, and then delete 
them, or maybe have some facility to mark them for automatic 
deletion with a period of time...or something.





Re: Precise GC state

2017-11-23 Thread Adam Wilson via Digitalmars-d

On 11/23/17 13:40, Ola Fosheim Grøstad wrote:

On Thursday, 23 November 2017 at 20:13:31 UTC, Adam Wilson wrote:

I would focus on a generational GC first for two reasons. The


But generational GC only makes sense if many of your GC objects have a
short life span. I don't think this fits well with sensible use of a
language like D where you typically would try to put such allocations on
the stack and/or use RAII or even an arena.



Sensible to whom? The great thing about D is that it works just we well 
for low-level people who need to wring the most out of the metal, AND 
the high-level productivity minded apps people, who don't.


RAII+stack allocations make sense when I care about WHEN an object is 
released and wish to provide some semblance of control over deallocation 
(although as Andrei has pointed out numerous time, you have no idea how 
many objects are hiding under that RAII pointer). But there are plenty 
of use cases where I really don't care when memory is released, or even 
how long it takes to release.


For example, all of the D apps that I've written and use in production, 
GC-allocate everything. I don't have a single struct in the code. But I 
don't care, because the program is so short lived and the working set so 
small that there will never be GC collection. And it's not like this is 
an uncommon or unwise pattern in D, DMD itself follows this exact 
pattern. Obviously my pattern isn't "wrong" or else DMD itself is 
"wrong". It's just not your definition of "correct".


Another use case where RAII makes no sense is GUI apps. The object graph 
required to maintain the state of all those widgets can be an absolute 
performance nightmare on destruction. Closing a window can result in the 
destruction of tens-of-thousands of objects (I've worked on codebases 
like that), all from the GUI thread, causing a hang, and a bad user 
experience. Or you could use a concurrent GC and pass off the collection 
to a different thread. (See .NET)



The second is that you still typically have to stop the execution of
the thread on the Gen0 collection (the objects most likely to be hot).
So with a non-generational concurrent collector you have to stop the
thread for the entirety of the scan, because you have no way to know
which objects are hot and which are cold.


How are you going to prove that references are all kept within the
generation in D? There is some very costly book keeping involved that
simply don't work well with D semantics.




Again, which semantics? If you compile with -betterc, the bookkeeping 
and it's overhead simply don't exist.


Your arguments are based on a presupposition that D should only be used 
a certain way; a way that, I am sure, mirrors your own usage patterns. D 
supports a multitude of different usage patterns, some of which look 
nothing like what you are holding up as "correct". And this is what 
makes D special. To remove or dismiss as invalid those usage patterns 
would be detrimental to those of us who use them and be catastrophic to 
D in general.


As a community, can we please stop it with the subjective judgements of 
what is and is not "sensible" in D, and start supporting the people 
using it, however they are using it, even if we are sure that they are 
"wrong"?


--
Adam Wilson
IRC: LightBender
import quiet.dlang.dev;


Re: Intellij D Language v1.15.2

2017-11-23 Thread Dmitry Olshansky via Digitalmars-d-announce

On Thursday, 23 November 2017 at 20:11:01 UTC, singingbush wrote:
Hi all. A new release intellij-dlanguage plugin has been made 
available for download from the Jetbrains repository this week.


The speed at which features and bug fixes are being done has 
picked up recently. We've had 4 releases this month alone.


Then I think you guys should post on Annonce more often :)

It would be really helpful if there are any Intellij users out 
there who don't already use our plugin to install it via the 
plugin repo and try it out (there are 2 D plugins, make sure to 
install the correct one). We now have error reporting built in 
to the plugin so that if anything breaks it's easy to inform 
the team about the problem.


Awesome! Will give it a spin.




Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn

On Friday, 24 November 2017 at 05:01:17 UTC, Basile B. wrote:

On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote:

On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:

If I add -noboundscheck flag all works fine.

dmd version is 2.076.1

Why -betterC flag not 'include' -noboundscheck flag?
It's bug or in some cases it's useful?



Interestingly, ldc2 will compile this ok, without the 
-noboundscheck flag


btw. you should start using: boundscheck=off/on/safeonly flag 
instead i believe.


https://dlang.org/dmd-windows.html#switch-boundscheck


It's b/c LDC2 doesn't have the most recent betterC features. It 
works just like it worked in older DMD release (e.g w 2.075), 
when betterC was "inexact" / "mostly unimplemented"



Thanks. I didn't take that into account (was using LDC 1.5.0 
..based on 2.075.1)


Getting used to monthly compiler updates is a real challenge.. 
not something I'm used to ;-)


Re: remake of remake of Konami's Knightmare

2017-11-23 Thread ketmar via Digitalmars-d-announce

bauss wrote:


On Thursday, 23 November 2017 at 12:18:38 UTC, ketmar wrote:
recently i worked on remake of DOS remake of Konami's Knightmare 
game[0]. the game is playable now, it has music from original MSX 
Knightmare, and sfx/gfx/levels from DOS remake. it is written in D, of 
course, and it is FOSS. you can find the sources here[1].


[...]


This is pretty neat, good job!


thank you!


Re: betterC and noboundscheck

2017-11-23 Thread Basile B. via Digitalmars-d-learn

On Friday, 24 November 2017 at 00:17:31 UTC, codephantom wrote:

On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:

If I add -noboundscheck flag all works fine.

dmd version is 2.076.1

Why -betterC flag not 'include' -noboundscheck flag?
It's bug or in some cases it's useful?



Interestingly, ldc2 will compile this ok, without the 
-noboundscheck flag


btw. you should start using: boundscheck=off/on/safeonly flag 
instead i believe.


https://dlang.org/dmd-windows.html#switch-boundscheck


It's b/c LDC2 doesn't have the most recent betterC features. It 
works just like it worked in older DMD release (e.g w 2.075), 
when betterC was "inexact" / "mostly unimplemented"


Re: remake of remake of Konami's Knightmare

2017-11-23 Thread bauss via Digitalmars-d-announce

On Thursday, 23 November 2017 at 12:18:38 UTC, ketmar wrote:
recently i worked on remake of DOS remake of Konami's 
Knightmare game[0]. the game is playable now, it has music from 
original MSX Knightmare, and sfx/gfx/levels from DOS remake. it 
is written in D, of course, and it is FOSS. you can find the 
sources here[1].


[...]


This is pretty neat, good job!


Re: Looking for a job in USA

2017-11-23 Thread codephantom via Digitalmars-d

On Friday, 24 November 2017 at 04:33:52 UTC, Walter Bright wrote:
These posts have nothing to do with D, so please stop posting 
them. This isn't a political forum.


Are you going to go through every other thread, and post the same 
comment?


This thread was off topic to begin with.


Re: Looking for a job in USA

2017-11-23 Thread codephantom via Digitalmars-d

On Friday, 24 November 2017 at 03:07:57 UTC, Indigo wrote:


If you believe any of our "leaders" are actually leading this 
country in the right direction(regardless of party) then you 
are an imbecile. I hope you don't believe that. Those that 
think Trump is president material are morons. Those that think 
Hilary is president material are also morons.


Neither were presidential material. Hilary lacked a coherent and 
energising vision, and she deserved to lose IMHO. People liked 
the arrogant assertiveness of Trump (some of the time). 
Unfortunately, he's has set out to make friends with his enemies, 
and enemies with his friends. He really is a moron. Instead of 
dealing with the 'real' threats in the world, he's set out to 
make enemies of the U.S secret agency heads, buddy up to that 
other moron that runs Russia, and play juvenile tit for tat with 
another moron that runs North Korea. And China simply cannot be 
trusted, full stop. They're all morons!


Trump has the U.S best interests at heart. Ha!

But he got there through the democratic process... and he can be 
removed through the same process, unlike those other countries I 
just mentioned.


What is your solution anyway? I haven't heard one yet. That's 
what politicians are good at ;-)


I think a universal income, and universal health, has to be part 
of any fair society going forward. Many agree.. it makes complete 
sense... but just not those in government - although i believe 
its being trialled somewhere. I don't know how you pay for it. 
But then again, money is a resource that humans have created to 
restrict themselves. It's not something nature imposed on us.


Zuckerberg put forward a great vision in his speech. Only the 
corrupt would say otherwise. And business and power does have a 
tendency to corrupt. So I reserve my opinion of him. I hope he 
runs for the next presidency, and then we'll see I guess.





Re: Looking for a job in USA

2017-11-23 Thread Walter Bright via Digitalmars-d
These posts have nothing to do with D, so please stop posting them. This isn't a 
political forum.


Re: Looking for a job in USA

2017-11-23 Thread Indigo via Digitalmars-d

On Friday, 24 November 2017 at 02:18:09 UTC, codephantom wrote:

On Friday, 24 November 2017 at 01:26:49 UTC, Indigo wrote:


Yes, there are good people, what you fail to realize is that 
there are very few running the show.


So that's the purpose of having a democracy. You get to say who 
runs the show ;-)


If (majority) people wanted Trump running the show, then that's 
what they got.


Although, as i understand it, Trump did not get the majority 
'popular vote'..so that's encouraging ;-)


In any case, it was close. So that's a good sign.

But I think the real problem was that the U.S became to passive 
about protecting it's own interests under Obama...perhaps in 
the name of international order and peace.


But I think that policy failed, and that's why Trump managed to 
appeal to people. Trump is very assertive, and although he goes 
over the top, i think the people in the U.S really want a 
president who is assertive.


That's just my guess anyway. What would I know ;-)

But one thing if for sure, the next president that gets elected 
needs to assert U.S power. Anything less, and the world will be 
in trouble soon enough.


The U.N has become a joke.
The W.T.A has become a joke.
That's a bad sign for global security.
And so, countries are naturally looking more inwards now, to 
protect their interests.


I cannot say whether I trust or don't trust Mark Zuckerberg, 
but his Harvard commencement speech this year was really, 
really inspiring. Assuming you can take him at his word, he 
could make a great U.S president .. perhaps. I don't see anyone 
in politics, in the U.S or any other country for that matter, 
with a vision like the one Zuckerberg provides in his speech. 
The current generation of politicians is the problem I believe. 
In a democracy, the people already have the power to change 
that, peacefully... just need the right person to step up, with 
a vision the country can get behind *in a united way*.


https://www.youtube.com/watch?v=QM8l623AouM



If you believe any of our "leaders" are actually leading this 
country in the right direction(regardless of party) then you are 
an imbecile. I hope you don't believe that. Those that think 
Trump is president material are morons. Those that think Hilary 
is president material are also morons.


We have some of the brightest and smartest minds in the world and 
yet we scrape from the bottom of the barrel. Yes, we live in a 
supposed democracy. Two problems with that: 1. 80% of the 
population are idiots who little common sense and no 
understanding of the big picture(some may be geniuses at baking 
cakes, but that is pointless in helping decide the fate of 
humanity). 2. We actually don't have a democracy and even if the 
corruption is only superficial, money and power are decides 
elections.


Zuckerberg is a moron. It is a capitalist who's sole purpose is 
to make money for himself and the people around him. Do you 
seriously want America to be run like facebook? Our children are 
not being educated to be the best but to be the worst. If you are 
entitled then you will get to choose from the cream... if not, 
then you are assumed to be worthless and pushed in to the 
meaningless cracks of the machine where you are ground up and 
everything around you becomes meaningless. How many children have 
been wasted simply because someone diverted money in to their own 
pockets? Children that could be used to solve many of the worlds 
problems.


The system is fundamentally flawed, not the people. The rules of 
the game determine the outcome, ALWAYS. People are in to blaming 
people("the other side") constantly for the problems when it is 
fundamentally due to the system itself.


For example, take any game. A game has "rules". The rules 
determine how the game works. If the rules have a flaw in it then 
people will exploit the flaw to win, because the purpose of 
having a game is to to create winners and losers(due to the 
competitive nature of humans). Imagine a game of chess with some 
10^50 moves. Now, the rules of the game are only a handful but 
the complexity it creates is staggering. The rules of chess can 
be written on a page of paper. Take the law, it is a game with 
rules. Winners win and losers lose. The law is hundreds of 
volumes of pages. The complexity of that game is beyond anything 
like chess. 10^(10^(10...)...) 50 times maybe.  It so so complex 
that actually no one comprehends it and most of it is meaningless 
and illogical created by the "law makers".


Just like chess, most people don't understand it nor can play 
well and hence come out losing. The thing about losing is there 
can only be one winner, or, rather, there are far more losers 
than winners. Again, that is basically the point... some type of 
flaw in the human psyche I suppose.



The problem is, humanity isn't a game. Every human lost is a loss 
for humans. Every child wasted by not giving a proper education. 
Every homeless person who is wasted because they are 

Re: Looking for a job in USA

2017-11-23 Thread codephantom via Digitalmars-d

On Friday, 24 November 2017 at 01:26:49 UTC, Indigo wrote:


Yes, there are good people, what you fail to realize is that 
there are very few running the show.


So that's the purpose of having a democracy. You get to say who 
runs the show ;-)


If (majority) people wanted Trump running the show, then that's 
what they got.


Although, as i understand it, Trump did not get the majority 
'popular vote'..so that's encouraging ;-)


In any case, it was close. So that's a good sign.

But I think the real problem was that the U.S became to passive 
about protecting it's own interests under Obama...perhaps in the 
name of international order and peace.


But I think that policy failed, and that's why Trump managed to 
appeal to people. Trump is very assertive, and although he goes 
over the top, i think the people in the U.S really want a 
president who is assertive.


That's just my guess anyway. What would I know ;-)

But one thing if for sure, the next president that gets elected 
needs to assert U.S power. Anything less, and the world will be 
in trouble soon enough.


The U.N has become a joke.
The W.T.A has become a joke.
That's a bad sign for global security.
And so, countries are naturally looking more inwards now, to 
protect their interests.


I cannot say whether I trust or don't trust Mark Zuckerberg, but 
his Harvard commencement speech this year was really, really 
inspiring. Assuming you can take him at his word, he could make a 
great U.S president .. perhaps. I don't see anyone in politics, 
in the U.S or any other country for that matter, with a vision 
like the one Zuckerberg provides in his speech. The current 
generation of politicians is the problem I believe. In a 
democracy, the people already have the power to change that, 
peacefully... just need the right person to step up, with a 
vision the country can get behind *in a united way*.


https://www.youtube.com/watch?v=QM8l623AouM



Re: Looking for a job in USA

2017-11-23 Thread realdonaldtrump via Digitalmars-d

On Friday, 24 November 2017 at 01:26:49 UTC, Indigo wrote:
On Thursday, 23 November 2017 at 05:08:39 UTC, codephantom 
wrote:

[...]


That's good, Australians are known for being hot headed! ;) j/k

[...]


I am working on draining the swamp.  You seem like you are 
already tired of winning. America is coming back so bigly that’s 
it’s gonna be something real special believe me.


Re: Looking for a job in USA

2017-11-23 Thread Indigo via Digitalmars-d

On Thursday, 23 November 2017 at 05:08:39 UTC, codephantom wrote:

On Thursday, 23 November 2017 at 04:13:33 UTC, Indigo wrote:


Wow, no need to get offended


Actually, I was not at all offended.

And we always find it kind of humorous, how people around the 
world view Australia. We don't get offended by it.




That's good, Australians are known for being hot headed! ;) j/k


In any case, I think you underestimate the U.S.

Yes, many objectionable people are doing many objectional 
things.


But there are many good people doing many good things too.

I'm confident that in the U.S, as in other freedom loving 
countries, the good people will get the upper hand again soon. 
It's an unfortunate ongoing cycle - part of the evolution of 
humanity I guess.


Go seek out, and connect with good people. They are out there 
you know.


The U.S is the worlds last defense against tyranny and 
chaos..which is right on our doorstep. Don't give up on the 
U.S. Instead go out and make it better.



Yes, there are good people, what you fail to realize is that 
there are very few running the show. You might not be aware but 
the US government is extremely corrupt. Weekly we have some 
politician being busted for something illegal or nearly so. 
Countless politicians have been caught in some scandal. Even if 
it's only 10, it should be 0. If that many are being caught, how 
many are not but still doing the same or worse? After all, our 
presidential candidates also are caught in doing illegal 
things... and these things are not just "accidental" or 
"mistakes" but intentional criminal actions.


You know how japan will apologize for a train being 2 seconds 
late? Well, in America, when a politician steals hundreds of 
thousands of dollars, he doesn't apologize and gets off the hook. 
Yet when some homeless person steals a candy bar, he gets 10 to 
20 years. It sounds like an exaggeration, but it isn't. Our law 
enforcement exits now to make a profit... not to make the world 
more peaceful. Don't believe me? Just look on youtube for police 
quotas and see directly from law enforcement saying they have 
quotas.


Yes, there are a lot of good people in the US, and the momentum 
the US has created through it's wealth in the past is the only 
thing that keeps it afloat... but it can't last forever(for 
sure)... but I give it less than a century(and each year it gets 
worse, not better). So, sure it looks good on the outside but 
it's cancer on the inside and it will kill everything in it's 
path at some point.


These are very slow processes and most people don't have the 
brain cells to see the low frequency patterns and trends. Like 
all trends, it is not 100%, but the fact that it is as bad as it 
is is enough to know that it is even worse than perceived, 
because for all the bad news, there is always more bad news that 
didn't get through. (sure the media focuses on the news, another 
problem that contributes to the decline)


Anyways, if you don't believe me about the US, then do your 
research. When the government becomes corrupt, there is no way 
out. The government will not self correct itself(has never 
happened in any civilization, except from overthrows, etc).


It may be a natural progression of things, but the cracks are 
showing in the US and it's obvious to some... any just society 
does not function/behave the way the US(any others) behave. Hence 
we do not have a just society. Any that believe we do are simply 
ignorant of the facts.




[Issue 17997] autotester's d_do_test has strange failures with Win32

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17997

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

https://github.com/dlang/dmd/commit/bcae082b71508c1f661e71b8ccc7a0868ec24825
fix Issue 17997 - autotester's d_do_test has strange failures with Win32

https://github.com/dlang/dmd/commit/58f64bddf60972791da7297fb6aa37f3a27d6884
Merge pull request #7350 from WalterBright/win32eh

fix Issue 17997 - autotester's d_do_test has strange failures with Win32

--


[Issue 17997] autotester's d_do_test has strange failures with Win32

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17997

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

   What|Removed |Added

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

--


Re: betterC and noboundscheck

2017-11-23 Thread codephantom via Digitalmars-d-learn

On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:

If I add -noboundscheck flag all works fine.

dmd version is 2.076.1

Why -betterC flag not 'include' -noboundscheck flag?
It's bug or in some cases it's useful?



Interestingly, ldc2 will compile this ok, without the 
-noboundscheck flag


btw. you should start using: boundscheck=off/on/safeonly flag 
instead i believe.


https://dlang.org/dmd-windows.html#switch-boundscheck



Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 10:20:49 UTC, Jonathan M Davis 
wrote:
LOL. I assumed that you were legitimately asking what the name 
of his compiler was, because I knew that he was writing a D 
compiler, whereas you were questioning his 
knowledge/credentials. Timon is a very smart guy. He knows a 
lot and has lots of great things to say. I certainly don't 
always agree with him, but he generally knows what he's talking 
about.


- Jonathan M Davis



I thought he was becoming a little confrontational with the 
Master Wizard (W), so I sought to check his credentials ;-)




Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d

On Wednesday, 22 November 2017 at 18:16:16 UTC, Wyatt wrote:


Perhaps that's why I've never considered nulls to be an issue. 
I take proactive steps to protect my code, before the compiler 
ever sees it. And actually, I cannot recall any null related 
error in any code I've deployed. It's just never been an issue.


Oh, that explains it.  He's a _robot_! ;)


Actually, you touch on an important point, which is implicit in 
my argument - (i.e changing the way you think, will change the 
way you write code).


We are programmable too ;-)

But who's doing the programming...



Re: Precise GC state

2017-11-23 Thread Ola Fosheim Grøstad via Digitalmars-d

On Thursday, 23 November 2017 at 20:13:31 UTC, Adam Wilson wrote:

I would focus on a generational GC first for two reasons. The


But generational GC only makes sense if many of your GC objects 
have a short life span. I don't think this fits well with 
sensible use of a language like D where you typically would try 
to put such allocations on the stack and/or use RAII or even an 
arena.


The second is that you still typically have to stop the 
execution of the thread on the Gen0 collection (the objects 
most likely to be hot). So with a non-generational concurrent 
collector you have to stop the thread for the entirety of the 
scan, because you have no way to know which objects are hot and 
which are cold.


How are you going to prove that references are all kept within 
the generation in D? There is some very costly book keeping 
involved that simply don't work well with D semantics.





[Issue 15542] pure function with no argument returning different values (with void-initialized static array)

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15542

--- Comment #5 from Jonathan M Davis  ---
(In reply to ag0aep6g from comment #4)
> Note that the test code still compiles even when you add `@safe`. Void
> initialization of value types is considered `@safe`.

Hmmm. I'm inclined to think that that's a bug, but I suppose that it depends on
what types it lets you void initialize. I guess that if it's just ints and
floats and whatnot in the struct, then that doesn't actually pose a memory
safety problem and wouldn't need to be marked @system, but it still seems
wrong.

Either way, I think that it's pretty clear that you're dealing with undefined
behavior if you use a void-initialized object before giving it a proper value,
and I don't see any reason to treat pure as special in that regard. As long as
the variable is given a proper value, then there is no purity issue, and
regardless of  whether @safety concerns really apply in all cases with
void-inialization, the concept is basically the same. When the programmer
void-initializes something, they're essentially promising that they'll do the
right thing and give the variablie a value before using it so that the normal
guarantees are in place.

--


Re: Precise GC state

2017-11-23 Thread Adam Wilson via Digitalmars-d

On 11/23/17 02:47, Nordlöw wrote:

On Wednesday, 22 November 2017 at 13:44:22 UTC, Nicholas Wilson wrote:

Thats a linker(?) limitation for OMF (or whatever is the win32 object
file format).


Was just fixed!

What improvements to D's concurrency model is made possible with this
precise GC?

I recall Martin Nowak saying at DConf 2016 that

a precise GC will enable data with isolated or immutable indirections to
be safely moved between threads


Rainer is awesome!

That is certainly one aspect that it will enable.

I would focus on a generational GC first for two reasons. The first is 
that you can delay the scans of the later gens if the Gen0 (nursery) has 
enough space, so for a lot of programs it would result in a significant 
cut-down in collection times.


The second is that you still typically have to stop the execution of the 
thread on the Gen0 collection (the objects most likely to be hot). So 
with a non-generational concurrent collector you have to stop the thread 
for the entirety of the scan, because you have no way to know which 
objects are hot and which are cold.


--
Adam Wilson
IRC: LightBender
import quiet.dlang.dev;


Intellij D Language v1.15.2

2017-11-23 Thread singingbush via Digitalmars-d-announce
Hi all. A new release intellij-dlanguage plugin has been made 
available for download from the Jetbrains repository this week.


The speed at which features and bug fixes are being done has 
picked up recently. We've had 4 releases this month alone. It 
would be really helpful if there are any Intellij users out there 
who don't already use our plugin to install it via the plugin 
repo and try it out (there are 2 D plugins, make sure to install 
the correct one). We now have error reporting built in to the 
plugin so that if anything breaks it's easy to inform the team 
about the problem.


There is also support for debugging with GDB (since v1.14 1st 
Nov). We need to completely overhaul our documentation as some of 
it is outdated now and there is no mention of the gdb support. If 
anyone with Java/Kotlin experience wants to get involved with 
helping squash bugs then we welcome pull requests so please feel 
free to browse the issues on our github repository and get 
involved.


https://github.com/intellij-dlanguage/intellij-dlanguage

If you find the plugin helpful please also rate the plugin:

https://plugins.jetbrains.com/plugin/8115-d-language


Re: reduce condition nesting

2017-11-23 Thread Michael via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana 
wrote:
On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe 
wrote:

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


The `switch` statement covers some of these cases too.


Anyway you can create something like this:
https://run.dlang.io/is/7pbVXT


That's pretty cool!


Re: reduce condition nesting

2017-11-23 Thread Temtaime via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana 
wrote:
On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe 
wrote:

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


The `switch` statement covers some of these cases too.


Anyway you can create something like this:
https://run.dlang.io/is/7pbVXT


Syntax #4

 // Syntax #4
when
(
c1, { writeln("first");   },
c2, { writeln("second"); },
{ writeln("default"); }   
);

:)


Re: GUI program on Mac OS in D?

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn

On 2017-11-23 17:06, Adam D. Ruppe wrote:
I know we have the extern(Objective-C) stuff from 
https://wiki.dlang.org/DIP43 now, but do we have existing bindings 
anywhere along the lines of the win32 ones we can just import and start 
calling the operating system functions?


Not as far as I know. Only a small part of what's in DIP43 is merged 
upstream in DMD, that is calling instance methods. DStep can generate 
bindings for Objective-C code but it will generate bindings for the full 
implementation of DIP43, so some things will not work with the official 
DMD. Back in the days when I announced 64bit version of DIP43 some guy 
started using it and seems to have a fairly complete set of bindings 
[1]. But again, those are for the full implementation of DIP43.


Moreover, I'm not a Mac dev; I've never actually done so much of a hello 
world, so have any of you done like a hello world in cocoa using D 
tutorial or example I can copy/paste to get started?


I have a simple example [2] of an application that shows a window with a 
WebKit view, i.e. and embedded browser. This works with the upstream DMD 
and LDC compilers. It basically only contains bindings for what I needed 
for that sample application. As you'll see there you need to use some 
parts of the Objective-C runtime to create class instances and 
subclasses. Also some gymnastics are required for class/static methods.


Note that this example is not a traditional Mac application, it was 
designed to not use .nib files (GUI files) and be embedded as a library 
inside another application.


If you want to give this a try, I recommend finding some 
Objective-C/Swift hello world examples online, combine that with my 
sample application [2] and the official documentation [3] for 
interfacing with Objective-C. You can use DStep to generate bindings and 
do some post-processing to remove/change what doesn't compile today 
using DMD.


If you have any questions, please let me know.

[1] https://github.com/DiveFramework/DiveFramework
[2] https://github.com/jacob-carlborg/d_webkit_test
[3] https://dlang.org/spec/objc_interface.html

--
/Jacob Carlborg


[Issue 15542] pure function with no argument returning different values (with void-initialized static array)

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15542

ag0ae...@gmail.com changed:

   What|Removed |Added

 CC||ag0ae...@gmail.com

--- Comment #4 from ag0ae...@gmail.com ---
(In reply to Marc Schütz from comment #1)
> Note how it says "undefined program behavior", not even "undefined value".
> So technically, the current behaviour is within the spec.

(In reply to Jonathan M Davis from comment #3)
> You'd basically have to force all pure functions to be @safe if you wanted
> to avoid this problem.

Note that the test code still compiles even when you add `@safe`. Void
initialization of value types is considered `@safe`.

--


Re: reduce condition nesting

2017-11-23 Thread drug via Digitalmars-d-learn

23.11.2017 17:16, Andrea Fontana пишет:

On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote:

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

for instance in kotlin it can be replace with this:

when {
    c1 -> foo(),
    c2 -> bar(),
    c3 -> ...
    else -> someDefault()
}


The `switch` statement covers some of these cases too.


Anyway you can create something like this:
https://run.dlang.io/is/7pbVXT


I really like Dlang very much


[Issue 15542] pure function with no argument returning different values (with void-initialized static array)

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15542

Jonathan M Davis  changed:

   What|Removed |Added

 CC||issues.dl...@jmdavisprog.co
   ||m

--- Comment #3 from Jonathan M Davis  ---
I would argue that this simply isn't a bug. void initializers are an @system
way to allow you to delay initialization so that you don't default-initialize a
variable and then assign to it again shortly thereafter. You're never supposed
to actually use the value of a void initialized variable any more than it's
advised to use a variable in C/C++ that you didn't initialize and thus is
filled with garbage. The fact that the pure function returns different values
for different calls is simply a result of failing to do your due diligence with
an @system function and make sure that it's actually @safe in spite of the
@system operations that it's doing. You'd have the same problem if you made it
do pointer arithmetic that made it point past the end of a buffer. There are
plenty of other ways to end up pointing to varying things whenever you violate
@safe. There's nothing particularly special about the void initializer in that
regard. You'd basically have to force all pure functions to be @safe if you
wanted to avoid this problem.

--


Re: GUI program on Mac OS in D?

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2017 at 16:14:50 UTC, Guillaume Piolat 
wrote:

Perhaps https://github.com/p0nce/DerelictCocoa


Well, that would be one option, though I was hoping to avoid the 
extern(C) runtime stuff and dynamic loading - ideally, I want 
something with the extern(Objective-C) stuff for static binding.


Re: Mirroring a drawable buf in DLangUI?

2017-11-23 Thread Dukc via Digitalmars-d-learn
On Thursday, 23 November 2017 at 13:31:23 UTC, Vadim Lopatin 
wrote:


There is no such feature currently, but it can be added easy.


In the meantime I should call OpenGL (I think it's the backend in 
my case) directly, correct?


Re: GUI program on Mac OS in D?

2017-11-23 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 23 November 2017 at 16:06:28 UTC, Adam D. Ruppe 
wrote:
I know we have the extern(Objective-C) stuff from 
https://wiki.dlang.org/DIP43 now, but do we have existing 
bindings anywhere along the lines of the win32 ones we can just 
import and start calling the operating system functions?


Moreover, I'm not a Mac dev; I've never actually done so much 
of a hello world, so have any of you done like a hello world in 
cocoa using D tutorial or example I can copy/paste to get 
started?


Perhaps https://github.com/p0nce/DerelictCocoa


GUI program on Mac OS in D?

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
I know we have the extern(Objective-C) stuff from 
https://wiki.dlang.org/DIP43 now, but do we have existing 
bindings anywhere along the lines of the win32 ones we can just 
import and start calling the operating system functions?


Moreover, I'm not a Mac dev; I've never actually done so much of 
a hello world, so have any of you done like a hello world in 
cocoa using D tutorial or example I can copy/paste to get started?


Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Timoses via Digitalmars-d-learn
On Thursday, 23 November 2017 at 15:45:17 UTC, Rene Zwanenburg 
wrote:

On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote:

A aaa = a;


That's initialization, not assignment, which is subtly 
different. It will call the postblit on aaa instead of 
opAssign. A postblit can be defined this way:


this(this)
{

}

There is no way to access the original a from the postblit. All 
fields have already been copied, you can use it to duplicate 
reference types, increment reference counts, and other things 
like that.


Wow, that's great! Thanks for the clarification you two!

For reference:
https://dlang.org/spec/struct.html#struct-postblit
http://ddili.org/ders/d.en/special_functions.html


Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Rene Zwanenburg via Digitalmars-d-learn

On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote:

A aaa = a;


That's initialization, not assignment, which is subtly different. 
It will call the postblit on aaa instead of opAssign. A postblit 
can be defined this way:


this(this)
{

}

There is no way to access the original a from the postblit. All 
fields have already been copied, you can use it to duplicate 
reference types, increment reference counts, and other things 
like that.


Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote:

A member;

this(A a)
{
this.member = a; // specifically aiming towards this 
assignment...



That's not assignment, that's construction.

opAssign is only called when you assign over a struct object that 
already exists. If there isn't an existing object in the variable 
already, it instead calls a constructor.


A a = A(); // construction, there is no existing a to call
A a; // construction done here...
a = x; // so this is now assignment over the existing object


Sometimes, they look the same, as in your case, but since you are 
assigning a member for the first time inside a constructor, it 
still counts as construction of the child object instead of 
assignment over an existing object.




Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Timoses via Digitalmars-d-learn

On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote:

I'm looking at

http://vibed.org/api/vibe.core.concurrency/makeIsolated

which is a great idea for safe inter-thread communication.

Are there any more usage examples for vibe's worker tasks that 
show how to send instances of `Isolated` to an existing such 
worker task via some low-latency (non-locking) channel-like 
communication structure?


You might wanna search or as the question on these forums as well:

vibe.d discussion - RejectedSoftware Forums
http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/


opAssign for most struct assignment calls not executed

2017-11-23 Thread Timoses via Digitalmars-d-learn

What am I missing?

import std.stdio;

struct A
{
int value;

A opAssign(A a)
{
writeln(" Assigning");
return this; // I know this makes little 
sense, just for illustration

}
}

class B
{
A member;

this(A a)
{
this.member = a; // specifically aiming towards this 
assignment...

}
}

void main()
{
A a = A(1);
A aa = A(2);

A aaa = a;

auto clas = new B(a);

writeln("Only this works:");
aaa = a;
writeln("or");
A ;
 = aa;
}


Output:
Only this works:
 Assigning
or
 Assigning


Note that before "Only this works:" nothing was written.

How can I overwrite the opAssign operator??
I'm sure I'm missing something...


Re: Decimal handling for currency (precision)

2017-11-23 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 23 November 2017 at 14:47:21 UTC, aberba wrote:
Some suggest working with the lowest currency denomination to 
avoid decimal precision handling and only convert to the 
highest denominations (decimal) when displaying. I've also seen 
some use decimal value handling libraries.


I'm thinking lowest denominations will result in extremely 
large values that D's type system cannot store (if such large 
values makes sense or can happen with money in real life).


What will be your advise on the type to use by default, the 
currency denominations (100p instead of 1.0 dollars), and cost 
of computation.


From d-money doc:

"Here the design decision is to use an integer for the internal 
representation. This limits the amounts you can use. For example, 
if you decide to use 4 digits behind the comma, the maximum 
number is 922,337,203,685,477.5807 or roughly 922 trillion. The 
US debt is currently in the trillions, so there are certainly 
cases where this representation is not applicable. However, we 
can check overflow, so if it happens, you get an exception thrown 
and notice it right away. The upside of using an integer is 
performance and a deterministic arithmetic all programmers are 
familiar with."


922 trillion (+4 digits after comma) should be enough for common 
computations.


Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread Ola Fosheim Grøstad via Digitalmars-d

On Thursday, 23 November 2017 at 08:47:43 UTC, codephantom wrote:
Many high level languages let you use 'unsafe' code, where you 
can write erroneous operations - and then you're back in the 
world of undefined behaviour.


Not many, but many allow interfacing with C, then it is up to 
those user to verify the correctness of their C code.


Are you saying, that a high level language can trap *all* 
errors?


Not sure what you mean by trap, they use static or runtime checks 
to uphold the language specification.


Whether something is an error or not beyond that is highly 
subjective. I.e. we cannot talk about errors unless we have a 
specification to judge the actual behaviour by.





Decimal handling for currency (precision)

2017-11-23 Thread aberba via Digitalmars-d-learn
Some suggest working with the lowest currency denomination to 
avoid decimal precision handling and only convert to the highest 
denominations (decimal) when displaying. I've also seen some use 
decimal value handling libraries.


I'm thinking lowest denominations will result in extremely large 
values that D's type system cannot store (if such large values 
makes sense or can happen with money in real life).


What will be your advise on the type to use by default, the 
currency denominations (100p instead of 1.0 dollars), and cost of 
computation.


Re: remake of remake of Konami's Knightmare

2017-11-23 Thread ketmar via Digitalmars-d-announce

Martin Drašar wrote:


Neat! Instead of working, I was spamming shift like crazy...

glad that you liked it! this little thingy is very addictive. ;-)



Now, when you say a partial port, did you make some automated
translation or it is just a manual labor with lotta love?
fully manual work. ah, except some simple regexps to replace "=" to "==", 
":=" to "=" and such. i ported all monster and movement logic, and wrote 
new video, audio and game state management subsystems from scratch.


Re: reduce condition nesting

2017-11-23 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe 
wrote:

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


The `switch` statement covers some of these cases too.


Anyway you can create something like this:
https://run.dlang.io/is/7pbVXT



[Issue 17966] chunkBy cannot accept an input range (from multiwayMerge)

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17966

greenify  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||greeen...@gmail.com
 Resolution|FIXED   |---

--- Comment #3 from greenify  ---
This has been accidentally closed.

--


Re: remake of remake of Konami's Knightmare

2017-11-23 Thread Martin Drašar via Digitalmars-d-announce
Dne 23.11.2017 v 13:18 ketmar via Digitalmars-d-announce napsal(a):
> recently i worked on remake of DOS remake of Konami's Knightmare
> game[0]. the game is playable now, it has music from original MSX
> Knightmare, and sfx/gfx/levels from DOS remake. it is written in D, of
> course, and it is FOSS. you can find the sources here[1].
> 
> as usual, you'll need my IV modules[2], and Adam's ARSD modules[3].
> the code won't work on 64-bit arches, tho (due to some bugs in sdpy/iv).
> but it can be compiled for 32-bit GNU/Linux, and 32-bit windows.
> 
> here is windows binary for those who cannot (or don't want to) build the
> binary[4].
> 
> WARNING! the code is a partial port of old DOS turbo pascal sources, so
> it is *very* far from something even remotely sane.
> 
> it is not polished yet, but that should not stop you! play this
> excellent classic shooter while it is hot! ;-)
> 
> some tech info: arsd.simpledisplay is used for video (with OpenGL
> backend), arsd.simplesound for audio (with my AY-8910 emulator), iv.vfs
> for VFS support. as the game designed for 20 FPS, i didn't bother
> avoiding GC (that is, the engine allocates like crazy).
> 
> enjoy, and happy hacking!
> 
> 
> [0] https://en.wikipedia.org/wiki/Knightmare_(1986_video_game)
> [1] http://repo.or.cz/knightmare.git
> [2] http://repo.or.cz/iv.d.git
> [3] https://github.com/adamdruppe/arsd
> [4] http://files.catbox.moe/z19j91.7z

Neat! Instead of working, I was spamming shift like crazy...

Now, when you say a partial port, did you make some automated
translation or it is just a manual labor with lotta love?

Martin


Re: Best way to call external function from another process memory?

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 23 November 2017 at 11:35:18 UTC, Skuzzi wrote:

typedef void (__stdcall* _function) (const char *text);

I want to do this in D. I understand that D uses "extern (C)" 
and does away with specifying calling conventions. However, how 
does D know the calling convention required? What if it is a 
__thiscall or something else, will it always be handled 
properly by D, just be specifying "extern (C)"?


extern(C) is for __cdecl functions. For __stdcall, it is 
`extern(Windows)`.


D doesn't actually do away with calling conventions, it just 
specifies them with slightly different syntax. You do still wanna 
make sure you get the right one.


Does anyone know of a proper and recommended way to achieve 
this in D?


Generally speaking, if you can do it in C or C++, it isn't *that* 
 much different to do in D: the concepts are the same, just the 
syntax is slightly different.


So the C function pointer (*foo)(arg) stuff turns into a D 
function pointer: `return_type function(args)` where `function` 
is the literal keyword `function`. The calling convention turns 
into one of the correct `extern` on the outside of it: 
`extern(C)`, `extern(C++)`, `extern(Windows)`, `extern(Pascal)`, 
or extern(System) and, for completeness, extern(D). The name is 
based on which language uses that calling convention by default.


Then casts go from (type)(statement) to `cast(type)(statement)`; 
the addition of the `cast` keyword.


And a few other little things like array from `int foo[]` to 
`int* foo` - use pointers for calling C functions instead of D 
arrays. and C's `long` is not the same as D's `long`, use `import 
core.stdc.config;` and the type `c_long` instead.


otherwise... pretty straightforward one-to-one translation of the 
concepts described in C++ on the 'net over to D syntax should get 
you there. You can call the same Windows API functions too.


Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread rjframe via Digitalmars-d
On Thu, 23 Nov 2017 01:08:45 +, codephantom wrote:

> So yeah, you can change the language.. or you can change the way people
> think about their code. When they think differently, their code will
> change accordingly.
> 
> My point about sophisticated IDE's and AI like compilers, is that they
> don't seem to have addressed the real issue - that is, changing the way
> people think about their code. If anything, they've introduced so many
> distractions and so much automation, that people are just not thinking
> about their code anymore. So now, language designers are being forced to
> step in and start regulating programmer behaviour. I don't like that
> approach.
> 
> You rarely hear anything about defensive programming these days, but
> it's more important now, than it ever was. I'd make it the number one
> priority for new developers. But you won't even find the concept being
> taught at our universities. They're too busy teaching students to
> program in Python ..hahha...the future is looking pretty bleak ;-(

It's easier to write better tools than it is to change people. That seems 
to me to be a big part of the D language design.

The sophisticated IDEs and compilers exist to help developers write better 
code; large projects are too complex, and open source projects especially 
receive contributions from people that don't know the code, so if the 
compiler can help, it should.

I left Python for D mostly because of variable annotations[1]. The 
following is valid in Python 3.6:

>>> myvar : int = "some string"
>>> print(myvar)
some string

If my compiler/interpreter won't tell me if I do something stupid like 
that, I don't want to waste my time with it. If your language gives me 
explicit types, it needs to give me some sort of type safety with them; 
otherwise your language is a hack. Static analysis will catch this, but I 
shouldn't need to run a static analysis tool or use an IDE to find an 
error like that.

> What if I did a security audit on DMD or PHOBOS. What would I discover?
> 
> What if I did a security audit on all the D code at github. What would I
> discover?

If you have the skills, this would (in my opinion) be an amazing use of 
your time. I'd recommend just auditing the core tools and popular 
libraries, rather than all code unless it's a hobby of yours though.


[1]: https://docs.python.org/3.6/whatsnew/3.6.html#whatsnew36-pep526


[Issue 5727] "ptr" in inline asm

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5727

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |FIXED

--- Comment #1 from RazvanN  ---
On ubuntu 16.04 git HEAD compilation fails with : "expression expected not ptr"
which is fine. Closing as fixed

--


Re: reduce condition nesting

2017-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


The `switch` statement covers some of these cases too.


deep copy thread local to shared or how to send() struct with indirections

2017-11-23 Thread crimaniak via Digitalmars-d-learn

Hi!

I need to send Publish struct from 
https://github.com/tchaloupka/vibe-mqtt to another vibe.d task. 
And there is the problem. First of all, I can't make it immutable 
because send() wants to mutate it. I can't send local copy 
because of "Aliases to mutable thread-local data not allowed.". 
And I can't convert it to shared because of "cannot implicitly 
convert expression `packet` of type `Publish` to 
`shared(FixedHeader)`".


I don't understand error message about FixedHeader. Why it tries 
to convert struct to its field? As I understand the real problem 
here is `ubyte[] payload` dynamic array field in Publish which is 
allocated separately, so to make a shared copy of Publish it need 
the deep copy of this struct. How to do it right? I don't want to 
copy all fields manually, is there a standard way to accomplish 
it?



```
struct MqttOnPublish
{
  Publish packet;
}

  override void onPublish(Publish packet)
  {
 super.onPublish(packet);

 // source/vcm/mqtt/bridge.d(69,41): Error: cannot implicitly 
convert expression `packet` of type `Publish` to 
`shared(FixedHeader)`

 shared Publish sp = shared Publish(packet);

/* /usr/include/dmd/phobos/std/concurrency.d(575,5): Error: 
static assert  "Aliases to mutable thread-local data not allowed."

../../.dub/packages/vibe-d-0.8.1/vibe-d/core/vibe/core/concurrency.d(1243,64):  
  instantiated from here: send!(MqttOnPublish)
source/vision/eventbus.d(72,27):instantiated from here: 
send!(MqttOnPublish)
source/vision/eventbus.d(42,13):instantiated from here: 
emit!(MqttOnPublish)
source/vcm/mqtt/bridge.d(70,14):instantiated from here: 
emit!(MqttOnPublish)

*/
 bus.emit(MqttOnPublish(packet));

  }
```



Re: Mirroring a drawable buf in DLangUI?

2017-11-23 Thread Vadim Lopatin via Digitalmars-d-learn

On Tuesday, 21 November 2017 at 13:45:31 UTC, Dukc wrote:
I am using the DrawRescaled method of DrawBuf[1] of DLangUI To 
draw a PNG image to a CanvasWidget[2] subclass. It has a minor 
issue of the box bounds showing in area that shoud be 
transparent but otherwise works well.


My question is, does anybody know a way to draw that image 
backwards without making another PNG file to do so? I tried to 
pass a dstrect with negative width but that results in nothing 
being drawn.


1: 
http://buggins.github.io/dlangui/ddox/dlangui/graphics/drawbuf/DrawBuf.html
2: 
http://buggins.github.io/dlangui/ddox/dlangui/widgets/controls/CanvasWidget.html


There is no such feature currently, but it can be added easy.


Re: Beta 2.077.1

2017-11-23 Thread Nicholas Wilson via Digitalmars-d-announce
On Thursday, 23 November 2017 at 13:09:09 UTC, Petar Kirov 
[ZombineDev] wrote:
On Thursday, 23 November 2017 at 13:06:14 UTC, Petar Kirov 
[ZombineDev] wrote:
On Thursday, 23 November 2017 at 12:04:05 UTC, Nicholas Wilson 
wrote:
On Thursday, 23 November 2017 at 11:43:08 UTC, Martin Nowak 
wrote:

[...]


Issue 17966 is a phobos bug. Why are the fixes for it 
druntime commits? This looks like a mixup.


The bug affected the makefiles of both druntime and phobos. 
The first merge commit apparently wins the closing bugzilla 
comment ;)


https://github.com/dlang/druntime/pull/1974
https://github.com/dlang/phobos/pull/5868


Actually, it looks like Martin made a typo in the commit 
message and wrote 17966 instead of 17996, which I missed :/


I meant that. Sorry for not being clear.


Re: Beta 2.077.1

2017-11-23 Thread codephantom via Digitalmars-d-announce

On Thursday, 23 November 2017 at 11:43:08 UTC, Martin Nowak wrote:

First beta for the 2.077.1 point release.

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


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

- -Martin


FreeBSD binaries too. I love it!


Re: Looking for a job in USA

2017-11-23 Thread codephantom via Digitalmars-d

On Thursday, 23 November 2017 at 12:05:53 UTC, aberba wrote:


When you analyse those points mentioned above you realise that 
things are happening exactly. For a writing of almost 2000 
years ago.


The writing you mention, can be said to be true for pretty much 
any epoch in the evolution of humanity that is similarly 
characterised by what you see today.


That is as far as I want to go, with regards to addressing the 
implications in your comment ;-)


People are free to believe what they want. And that's how it 
should be.


In any case, 'what we know to be true', is that if people want 
change, then they have to go connect with others who want change 
as well, and then together they can make it happen...


And 'what we know to be true', is that change in any epoch in the 
evolution of humanity that is similarly characterised by what you 
see today, came about as a result of people changing it.




Re: Beta 2.077.1

2017-11-23 Thread Petar via Digitalmars-d-announce
On Thursday, 23 November 2017 at 13:06:14 UTC, Petar Kirov 
[ZombineDev] wrote:
On Thursday, 23 November 2017 at 12:04:05 UTC, Nicholas Wilson 
wrote:
On Thursday, 23 November 2017 at 11:43:08 UTC, Martin Nowak 
wrote:

First beta for the 2.077.1 point release.

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


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

- -Martin


Issue 17966 is a phobos bug. Why are the fixes for it druntime 
commits? This looks like a mixup.


The bug affected the makefiles of both druntime and phobos. The 
first merge commit apparently wins the closing bugzilla comment 
;)


https://github.com/dlang/druntime/pull/1974
https://github.com/dlang/phobos/pull/5868


Actually, it looks like Martin made a typo in the commit message 
and wrote 17966 instead of 17996, which I missed :/


Re: Beta 2.077.1

2017-11-23 Thread Petar via Digitalmars-d-announce
On Thursday, 23 November 2017 at 12:04:05 UTC, Nicholas Wilson 
wrote:
On Thursday, 23 November 2017 at 11:43:08 UTC, Martin Nowak 
wrote:

First beta for the 2.077.1 point release.

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


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

- -Martin


Issue 17966 is a phobos bug. Why are the fixes for it druntime 
commits? This looks like a mixup.


The bug affected the makefiles of both druntime and phobos. The 
first merge commit apparently wins the closing bugzilla comment ;)


https://github.com/dlang/druntime/pull/1974
https://github.com/dlang/phobos/pull/5868


remake of remake of Konami's Knightmare

2017-11-23 Thread ketmar via Digitalmars-d-announce
recently i worked on remake of DOS remake of Konami's Knightmare game[0]. 
the game is playable now, it has music from original MSX Knightmare, and 
sfx/gfx/levels from DOS remake. it is written in D, of course, and it is 
FOSS. you can find the sources here[1].


as usual, you'll need my IV modules[2], and Adam's ARSD modules[3].
the code won't work on 64-bit arches, tho (due to some bugs in sdpy/iv). 
but it can be compiled for 32-bit GNU/Linux, and 32-bit windows.


here is windows binary for those who cannot (or don't want to) build the 
binary[4].


WARNING! the code is a partial port of old DOS turbo pascal sources, so it 
is *very* far from something even remotely sane.


it is not polished yet, but that should not stop you! play this excellent 
classic shooter while it is hot! ;-)


some tech info: arsd.simpledisplay is used for video (with OpenGL backend), 
arsd.simplesound for audio (with my AY-8910 emulator), iv.vfs for VFS 
support. as the game designed for 20 FPS, i didn't bother avoiding GC (that 
is, the engine allocates like crazy).


enjoy, and happy hacking!


[0] https://en.wikipedia.org/wiki/Knightmare_(1986_video_game)
[1] http://repo.or.cz/knightmare.git
[2] http://repo.or.cz/iv.d.git
[3] https://github.com/adamdruppe/arsd
[4] http://files.catbox.moe/z19j91.7z


Re: Looking for a job in USA

2017-11-23 Thread aberba via Digitalmars-d

On Wednesday, 22 November 2017 at 10:24:52 UTC, Indigo wrote:

On Saturday, 18 November 2017 at 08:59:53 UTC, Satoshi wrote:

On Saturday, 18 November 2017 at 01:31:09 UTC, Indigo wrote:

On Wednesday, 15 November 2017 at 17:32:50 UTC, Satoshi wrote:

Hi,
as the title says, I'm looking for a job opportunity in the 
USA (H1B visa sponsorship required).


I'm experienced Software Engineer with a demonstrated 
history of working in the security and investigations 
industry. Skilled in C, C++, D, C#, SQL, Object-Oriented 
Programming, Software Development and Electrical 
Engineering. Strong engineering professional with 
willingness to further education.


Actually I work as a full stack ASP.NET developer for 
SolarWinds in Brno (Czechia).


There are couple of my open source projects what I have done 
in past. https://github.com/Rikarin


If you are interested or you know someone who could hire me, 
please let me know!


Thanks!


What is your reasoning for coming to the US? You might want 
to rethink this as America is collapsing. America will be 
vastly different in 10 years and not a great a place to be. 
The amount of corruption in the government and the amount of 
vitriol that people have for each other are astonishing... 
and it is only getting worse.
Actually, Slovakia (SK) and Czechia (CZ) are two most 
corrupted countries in the EU. We are paying huge taxes and 
getting nothing in back.


If you are moving to settle down that it would be a bad 
decision IMO. If it is just temporary thing for a few years 
thing it might be ok depending on you end up.
I wanna try to live in the US for a few years and then decide 
if I should leave or settle down.


Do you mind me asking why you are leaving Czech? I hear there 
are a lot of pretty females there ;) Is it simply business or 
is it the country itself? To be honest, I couldn't imagine it 
being as bad as the US but I do not know much about it. To be 
honest, I'm curious as to what it is like over there because 
I plan on moving out of the US at some point and I'm looking 
for countries that are a bit more stable and not on the 
decline.
Actually, CZ is rising up and getting better, but in business 
area and salaries it's still worse than in the US.


Some places in EU are not safe yet. A lot of immigrants are 
going there from war zones. They are like groups of anarchists 
destroying everything, stealing, raping and not respecting the 
laws.


Salary... In US you get $100,000/year as a senior developer or 
something like that, right?
There it's only like $30,000/year. But the price of stuff like 
cars, grocery and everything what you can buy on amazon, 
e-bay, etc. is the same.


The concept of a money in US seems to be different than in SK. 
There it's more about survive than enjoying life.


People in US seems to be little more opened to strangers than 
here.


That's the reasons why I want to leave.

BTW: What's wrong with the US?


Um, it's the same! You won't escape it if you come to stay. 
Just because the shit hasn't hit the fan yet does not mean it's 
not coming down the pipe. There are many here that seem to 
believe that ignorance is bliss, that is true, for a while.


If you looking in the the US news you will see that there is a 
major killing happening just about once a week. The politicians 
are all crooks, provably, and the CEO's of many of the largest 
companies are in cahoots with them. No different than where you 
are from. The laws here are so screwed up that law abiding 
citizens are routinely killed by cops or cops killed by people 
and it all turns out to be a "mistake", or worse, someone's ego.


Again, it sounds like you are experiencing this in your own 
country now... so, if that is what you are trying to escape, 
you are just moving in to a bigger pond with the same type of 
scum. Again, it matters not that some people want to stick 
their head in the sand.


Our healthcare system is probably far more screwed up than your 
country. There are many Americans who are bankrupt over things 
like a broken arm, etc... 100k$ bill for 3 hours of work... and 
these insurance companies make billions in profits and it only 
goes up.



Wealthy and ignorant people(depending who's party is 
president), of course, love to believe that these are isolated 
problems and every country has them, etc.  Almost 30 years ago 
OJ Simpson was big news and cop murder(er)s were very rare. 
This is not to say there was no as much corruption, but the 
corruption is far different, much more dangerous because there 
are many people with big bucks who are extremely evil or 
ruthless(can, at the drop of a dime, create a whole can of 
worms that takes the country many years to try and fix).  So, 
what this proves is the world is becoming more dangerous and 
more insane. As time goes on the division lines are ingrained 
deeper(just as a persons face ages and it's a sign). Everyone 
knows this because the world is far more dangerous than it was. 
My point is, do 

Re: Beta 2.077.1

2017-11-23 Thread Nicholas Wilson via Digitalmars-d-announce

On Thursday, 23 November 2017 at 11:43:08 UTC, Martin Nowak wrote:

First beta for the 2.077.1 point release.

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


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

- -Martin


Issue 17966 is a phobos bug. Why are the fixes for it druntime 
commits? This looks like a mixup.


Re: Release Candidate [was: Re: Beta 2.077.0]

2017-11-23 Thread Martin Nowak via Digitalmars-d-announce
On 11/02/2017 09:43 AM, Basile B. wrote:
> On Monday, 30 October 2017 at 11:12:29 UTC, Basile B. wrote:
>> On Saturday, 28 October 2017 at 23:21:56 UTC, Martin Nowak wrote:
>>> First release candidate for 2.077.0.
>>>
>>> The OMF Windows API import libraries were updated, a bug in
>>> std.bigint was fixed, and the version identifier for `-betterC` is
>>> now `D_BetterC`.
>>>
>>> - -Martin
>>
>> Thanks, i have no problem here with the RC, tested it well, though
>> looking at the log there would be no reason why i would have.
> 
> Actually there's a REG  :/
> 
> a 192 bytes leak is created by the GC, just with an empty main.
> Also i don't know how this is possible but travisCI runs with DMD 2.077
> by default (even if not released).

For the install.sh script (and Travis-CI) it's released when we update
downloads.dlang.org/releases/LATEST, this happens slightly before the
release announcement.


Re: Best way to call external function from another process memory?

2017-11-23 Thread rikki cattermole via Digitalmars-d-learn

On 23/11/2017 11:35 AM, Skuzzi wrote:
Hi, I am new to D and I want to use it to create some tools that call 
certain functions from the process of a game, using an injected DLL 
written in D. I have reverse engineered the addresses and arguments of 
the function. Typically this kind of stuff is done with C++ and almost 
all the available resources online focus on C++. I was not able to find 
anything specific to this done in D.


This is what a function prototype might look like in C++:
typedef void (__stdcall* _function) (const char *text);
_function function;


alias _function = extern(C) void function(const(char)* text);
_function myFunction;


Which you would then call using the address of the function in memory:
function = (_function)(ADDRESS_OF_FUNCTION);
function("Some text");


void* ADDRESS_OF_FUNCTION = ...;
myFunction = cast(_function)ADDRESS_OF_FUNCTION;
myFunction(cast(const(char)*("Some text".ptr));

Literals have a \0 at the end so this is safe.

I want to do this in D. I understand that D uses "extern (C)" and does 
away with specifying calling conventions. However, how does D know the 
calling convention required? What if it is a __thiscall or something 
else, will it always be handled properly by D, just be specifying 
"extern (C)"?


extern takes care of calling conventions and mangling for declarations 
(which you are not using in the above).


See[0] point 3 regarding how this all works.

[0] https://dlang.org/spec/interfaceToC.html#calling_c_functions


Beta 2.077.1

2017-11-23 Thread Martin Nowak via Digitalmars-d-announce
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

First beta for the 2.077.1 point release.

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

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

- -Martin

-BEGIN PGP SIGNATURE-

iQIzBAEBCgAdFiEEpzRNrTw0HqEtE8TmsnOBFhK7GTkFAloWtEsACgkQsnOBFhK7
GTkXkg//W39GRilzKmyqD4okQCHCXRYtWG9hmgUiL3APS8vYfP1k0n8DGiQlu66n
UvL9R6G8W46FZn49wxZI+l4g3PAdIpH76YMPJiEHGCz+wU/ngJkWalDoEGoeLy1W
B4jd9drsuPnZjNMgdS1KMZ+5au9HQTFzLr88HhbCcA3mO8CV/OMrIa6mIsIboQi+
n1lh+NC5LJX4XD3go9S/acPTAqSbqp774N4637V7WoXZz3VTeaaYu/sJiXO8rtd7
rWIWghtA/oi4CrvgMjwdmvDxC45z8gf1kt8VgBgqiQfpX2B4Yw0sooqPH3/GQVUB
98IkL2lo/9P5XcTwei17dhBZLwxz/wkxrstQJsPWufDC2FM2JFduGBf2FASOCIwm
suWZP6aQIN9xpbGBxukXOh/Xou3RWmTlRHx+Q3sgdpuSiJiy+4A2BHKcN3M5w/Tn
cfnzosxM+PVVg4MRyFImDql9NhNpYRvx5mxTNbvfFzsX1KpI3EgbIkk2HWM2xGZM
ptuuE/ZTZjnPI2MQUwrrf+aj367AGDRhF74lqAxzhvURXTUzykX2Z2KGlVZM6tAZ
c0ahNrogSKzEHY1YWu21mZFbRanLCDQXgVMgp11MAuYCA9auf8/JU2sLS8C27gHF
5KGk+njC9XsDA9AxZnt6L7mu9jGloUFlfNUEnaXPA46cKRzfX2Q=
=FmzS
-END PGP SIGNATURE-


[Issue 16347] Strange deprecation message when using templates

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16347

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |WORKSFORME

--- Comment #3 from RazvanN  ---
Running the example on git HEAD on Ubuntu 16.04 results in successful
compilation (no warnings). Closing this as WORKSFORME.

--


Best way to call external function from another process memory?

2017-11-23 Thread Skuzzi via Digitalmars-d-learn
Hi, I am new to D and I want to use it to create some tools that 
call certain functions from the process of a game, using an 
injected DLL written in D. I have reverse engineered the 
addresses and arguments of the function. Typically this kind of 
stuff is done with C++ and almost all the available resources 
online focus on C++. I was not able to find anything specific to 
this done in D.


This is what a function prototype might look like in C++:
typedef void (__stdcall* _function) (const char *text);
_function function;

Which you would then call using the address of the function in 
memory:

function = (_function)(ADDRESS_OF_FUNCTION);
function("Some text");

I want to do this in D. I understand that D uses "extern (C)" and 
does away with specifying calling conventions. However, how does 
D know the calling convention required? What if it is a 
__thiscall or something else, will it always be handled properly 
by D, just be specifying "extern (C)"?


Does anyone know of a proper and recommended way to achieve this 
in D? Or is this a task better suited for C++? I hope to be able 
to use D for this, as I am enjoying learning the language. Any 
help is deeply appreciated, thank you very much.


Re: Problem building SWTSnippets with D 2.074.x

2017-11-23 Thread Mike James via Digitalmars-d-dwt

On Thursday, 16 November 2017 at 02:36:34 UTC, JamesD wrote:
On Wednesday, 15 November 2017 at 07:19:17 UTC, Mike Parker 
wrote:

On Tuesday, 14 November 2017 at 11:33:44 UTC, Mike James wrote:



Has there been any progress on this matter? The snippets 
still don't compile with the latest compiler...




https://github.com/dlang/dmd/pull/7315


Until the issue above is resolved, you can compile with dwtlib.
dwtlib is a work around that uses the *.d source files instead 
of the *.di files.


 dwtlib - DUB package for the D Widget Toolkit
 https://code.dlang.org/packages/dwtlib

Also try gdub, a gui to test individual snippets (see screen 
shot);


 GDUB is a DWT GUI front end for DUB, a D language build 
tool.

 https://code.dlang.org/packages/gdub


Hi James,

When I tried this I got...

Build_dwtlib working in  : 
C:\Users\mikej\AppData\Roaming\dub\packages\dwtlib-3.1.1\dwtlib\dwt

Build_dwtlib builiding   : Windows 64-bit
Build_dwtlib command line: rdmd build.d -m64 clean base swt
(in 
C:\Users\mikej\AppData\Roaming\dub\packages\dwtlib-3.1.1\dwtlib\dwt)

Cleaning
Building dwt-base
workdir=>C:\Users\mikej\AppData\Roaming\dub\packages\dwtlib-3.1.1\dwtlib\dwt\base\src
dmd.exe 
@C:\Users\mikej\AppData\Roaming\dub\packages\dwtlib-3.1.1\dwtlib\dwt\rsp
java\nonstandard\RuntimeTraits.d(61): Error: undefined identifier 
TypeInfo_Typedef


object.Exception@build.d(256): compile error

0x0040594A
0x00406E14
0x0041E56F
0x0041E533
0x0041E434
0x0041751F
0x75D78654 in BaseThreadInitThunk
0x77914A47 in RtlGetAppContainerNamedObjectPath
0x77914A17 in RtlGetAppContainerNamedObjectPath

object.Exception@tools\build_dwtlib.d(123): Build_dwtlib ERROR 
spawning cmd.


0x004029D0
0x00409ABF
0x00409A83
0x00409984
0x00406AE3
0x75D78654 in BaseThreadInitThunk
0x77914A47 in RtlGetAppContainerNamedObjectPath
0x77914A17 in RtlGetAppContainerNamedObjectPath
Press any key to continue . . .

Regards, Mike.


[Issue 18005] AA leak

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18005

radu.raca...@gmail.com changed:

   What|Removed |Added

 CC||radu.raca...@gmail.com

--- Comment #4 from radu.raca...@gmail.com ---
don't think is the AA that does it, as the following exposes the same behavior:

+++

void main(string[] args)
{
foreach (i; 0..300)
{
import core.memory;
import std.stdio : writefln;

writefln(`%g MB used, %g MB free`, GC.stats.usedSize / 1024f / 1024,
GC.stats.freeSize / 1024f / 1024);

new bool[13 * 1024 * 1024]; // <- this collects differently on Windows

GC.collect;
GC.minimize;
}
}

+++

Running it:

0.000137329 MB used, 0.999863 MB free
13.004 MB used, 7.49988 MB free
26.0079 MB used, 13. MB free
39.0118 MB used, 20.4999 MB free
52.0157 MB used, 26. MB free
65.0197 MB used, 33.4999 MB free
78.0236 MB used, 39. MB free
78.0236 MB used, 42.496 MB free
91.0275 MB used, 51.4921 MB free
104.031 MB used, 63.4882 MB free
104.031 MB used, 66.4882 MB free
117.035 MB used, 53.4843 MB free
130.039 MB used, 68.4803 MB free
143.043 MB used, 55.4764 MB free
143.043 MB used, 86.4764 MB free
143.043 MB used, 55.4764 MB free
143.043 MB used, 86.4764 MB free
143.043 MB used, 55.4764 MB free
143.043 MB used, 86.4764 MB free
143.043 MB used, 55.4764 MB free
143.043 MB used, 86.4764 MB free
143.043 MB used, 55.4764 MB free
143.043 MB used, 86.4764 MB free
143.043 MB used, 55.4764 MB free
143.043 MB used, 86.4764 MB free


It stabilizes at 143.043 MB

On Linux it collects eagerly and stabilizes around
13.0042 MB used, 7.49976 MB free

--


Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn

On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote:

I'm looking at

http://vibed.org/api/vibe.core.concurrency/makeIsolated

which is a great idea for safe inter-thread communication.

Are there any more usage examples for vibe's worker tasks that 
show how to send instances of `Isolated` to an existing such 
worker task via some low-latency (non-locking) channel-like 
communication structure?


I guess

http://vibed.org/api/vibe.core.concurrency/send

void send(ARGS...) (
  Task task,
  ARGS args
);

void send(ARGS...) (
  Tid tid,
  ARGS args
);

is what I'm looking for.

Why aren't `ARGS` restricted to be instances of `Isolated`?

Further, shouldn't a trait `isIsolated` be defined and reused 
here and eventually moved into std.traits alongside `hasAliasing` 
and `hasIndirections`?


Re: Precise GC state

2017-11-23 Thread Nordlöw via Digitalmars-d
On Wednesday, 22 November 2017 at 13:44:22 UTC, Nicholas Wilson 
wrote:
Thats a linker(?) limitation for OMF (or whatever is the win32 
object file format).


Was just fixed!

What improvements to D's concurrency model is made possible with 
this precise GC?


I recall Martin Nowak saying at DConf 2016 that

a precise GC will enable data with isolated or immutable 
indirections to be safely moved between threads


Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn

On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote:

I'm looking at

http://vibed.org/api/vibe.core.concurrency/makeIsolated


Further, what does "weakly isolated" mean here

http://vibed.org/api/vibe.core.core/runWorkerTask

?


[Issue 16275] final functions allowed

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16275

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |WONTFIX

--- Comment #1 from RazvanN  ---
That's not a problem, it doesn't affect the code in anyway. As in the case of
extern (C) class, the attribute is ignored.

Closing as wontfix.

--


Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn

I'm looking at

http://vibed.org/api/vibe.core.concurrency/makeIsolated

which is a great idea for safe inter-thread communication.

Are there any more usage examples for vibe's worker tasks that 
show how to send instances of `Isolated` to an existing such 
worker task via some low-latency (non-locking) channel-like 
communication structure?


[Issue 16520] static foreach should be more explicit

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16520

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |FIXED

--- Comment #1 from RazvanN  ---
Static foreach has been added to the language. I'll close this as fixed.

--


Re: Error: 'this' is only defined in non-static member functions

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn

On 2017-11-23 01:35, Jonathan M Davis wrote:


It would make sense with something like the nodes of a linked list if they
needed access to the container for some reason. Pretty much any case where a
an instance of a nested class is going to be associated with a specific
instance of its parent class and needs access to it would be a canditate.
It's not that uncommon to see cases in C++ or Java where you'd pass a
pointer to the "parent" to an instance of a nested class when it's created,
and having outer built-in is kind of like that.

Personally, I've never had a use for it. I don't even use classes much in D,
since I rarely need inheritance. And as I understand it, most D programs
don't use classes very heavily for that very reason. So, I have no idea how
common it is to use nested classes in this manner, but I expect that someone
has found it useful at some point.

I thought that this meaning of static for nested classes came from Java, but
it's been a while since I've done much with Java, so I don't know.


Yeah, it's very similar in D and Java.

Another example that comes from Java (before version 8) is to have a 
class with a nested anonymous class that implements an interface. It's 
very common in Java for event handling or similar actions. Other 
languages like D or Java 8 would use a delegate/lambda for the same 
thing. Something like:


class WindowController
{
Button button;
Window window;

this()
{
button = new Button;
window = new Window;
button.onClick = new class() Clickable {
window.close();
};
}
}

The anonymous class could have been a named class as well and to be able 
to access the "window" instance variable of the controller it needs to 
have access to the outer context and cannot be static.


--
/Jacob Carlborg


Re: TickDuration deprecation

2017-11-23 Thread Jacob Carlborg via Digitalmars-d

On 2017-11-22 22:41, Walter Bright wrote:

For another example, unreferenced virtual functions never get elided 
because a reference to them does exist - they're in the virtual function 
pointer table. And then, of course, everything that virtual function 
references is never elided.


Yeah, that's one of the reason why the original Objective-C/D bridge 
resulted in a 60 MB Hello World executable. At that point we realized we 
need to add direct support in the compiler for linking with Objective-C.


--
/Jacob Carlborg


Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 07:20:41 UTC, Ola Fosheim 
Grostad wrote:
On Thursday, 23 November 2017 at 01:16:59 UTC, codephantom 
wrote:

That's why we have the concept of 'undefined behaviour'.


Errr, no.  High level programming languages don't have 
undefined behaviour. That is a C concept related to the 
performance of the executable. C tries to get as close to 
machine language as possible.


Many high level languages let you use 'unsafe' code, where you 
can write erroneous operations - and then you're back in the 
world of undefined behaviour.


Are you saying, that a high level language can trap *all* errors?

As per the Goldbach conjecture... where is the proof?



Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 07:13:37 UTC, Ola Fosheim 
Grostad wrote:


Heh, has the Goldbach conjecture been proven undecidable?


Not to my knowledge ;-)

At best, it's a possiblity - which can go either way.

No human or computer will ever make it anything more than that. 
Ever.


Someone saying it's true, up to < n, is not addressing the 
problem.


Someone trying to address the problem, does not even understand 
the problem ;-)




Re: reduce condition nesting

2017-11-23 Thread Andrey via Digitalmars-d-learn
On Thursday, 23 November 2017 at 08:27:54 UTC, Andrea Fontana 
wrote:

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

Hello, is there way to reduce this condition:

if (c1) {
foo();
} else {
if (c2) {
bar();
} else {
if (c3) {
...
}
}
}


for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


if (c1) foo()
else if (c2) bar();
else if (c3) ...
else someDefault();

?


haha, yes you are right, sorry for stupid question, I recently 
began to study Kotlin and noticed than `when` is a great feature )


Re: glfwSetDropCallback undefined symbol

2017-11-23 Thread drug via Digitalmars-d-learn

23.11.2017 09:33, Tim Hsu пишет:

DCD and DMD says that the symbol is undefined!

However, I look into derelichtGLFW3. It has this symbol defined!

It looks like a bug for me!
DerelictGLFW3 has this symbol, but it does not define it, it should be 
defined in shared/dynamic library you use. I guess you use old version 
of the lib, just update it.


Re: reduce condition nesting

2017-11-23 Thread Andrea Fontana via Digitalmars-d-learn

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

Hello, is there way to reduce this condition:

if (c1) {
foo();
} else {
if (c2) {
bar();
} else {
if (c3) {
...
}
}
}


for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


if (c1) foo()
else if (c2) bar();
else if (c3) ...
else someDefault();

?



[Issue 18007] Enforcing immutability

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18007

Saanvi Sharma  changed:

   What|Removed |Added

   Keywords||C++

--


[Issue 18007] New: Enforcing immutability

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18007

  Issue ID: 18007
   Summary: Enforcing immutability
   Product: D
   Version: D2
  Hardware: x86
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: iamsaan...@gmail.com

I wonder if it would be possible to have a mechanism (either in scale or in
dotty) that will enforce/guarantee immutability of data structures and/or
functions?

I’m no compiler expert but it could be something like a new keyword or implicit
argument required for doing reassignments. From what I understand on the lowest
level reassignment is the only way to mutate something, so this should be
enough.

I can recall that C++ has some pretty sophisticated const semantics similar to
this, but I remember as well that it was pretty cumbersome to use it (I have
not used C++ for more than a few years now, so don’t know whats the current
status).

Thank you
Saanvi S
Scala Trainer: https://mindmajix.com/scala-training

--


[Issue 15542] pure function with no argument returning different values (with void-initialized static array)

2017-11-23 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15542

RazvanN  changed:

   What|Removed |Added

 CC||razvan.nitu1...@gmail.com

--- Comment #2 from RazvanN  ---
Maybe void initialization should be disallowed in pure functions.

--