Re: Creating D bindings for a C library

2015-11-24 Thread cym13 via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 23:22:24 UTC, Joseph Rushton 
Wakeling wrote:
On Tuesday, 24 November 2015 at 23:14:14 UTC, Joseph Rushton 
Wakeling wrote:

I'm considering creating some D bindings for a C library.


I should probably clarify that I know what to do assuming I 
have to write all the bindings manually.  However, as the 
library has quite a lot of header files, I'd really much rather 
auto-convert as much as possible, hence the questions above :-)


There are some binding generator the most two famous being htod 
and dstep: 
http://wiki.dlang.org/List_of_Bindings#Binding_generators


Re: C++ to add import, module and export

2015-11-24 Thread deadalnix via Digitalmars-d

On Tuesday, 24 November 2015 at 23:14:28 UTC, deadalnix wrote:

According to this:
https://www.youtube.com/watch?v=RwdQA0pGWa4

There are plan to add these keyword in C++'s module system.


Also, this module representation may be an opportunity for us to 
compile D to something a C++ compiler can digest (maybe ?).




Re: C++ to add import, module and export

2015-11-24 Thread bitwise via Digitalmars-d

On Tuesday, 24 November 2015 at 23:14:28 UTC, deadalnix wrote:

According to this:
https://www.youtube.com/watch?v=RwdQA0pGWa4

There are plan to add these keyword in C++'s module system.


I think I would prefer if C++ compilers started spitting out D 
bindings instead ;)


 Bit



Re: New __traits

2015-11-24 Thread BLM768 via Digitalmars-d

On Wednesday, 25 November 2015 at 01:06:55 UTC, BLM768 wrote:
In other words, "std" isn't a package _or_ module, and 
std.stdio is both (even though it's just a single D source 
file). This doesn't seem quite right.


I just confirmed that this also applies to other root packages, 
i.e. "core" or any root packages from third-party libraries.






New __traits

2015-11-24 Thread BLM768 via Digitalmars-d
For a project I've been working on, I found that it would be 
helpful to have a way to determine whether a symbol represents a 
module or package. Since I couldn't find an easy way to do it, I 
forked DMD and made some tweaks. ;)


Anyway, I uncovered an interesting issue. According to my test 
program (https://gist.github.com/blm768/42f40aa5a0c49bb8bd16), 
these are the "types" of various packages/modules in Phobos:

std:
std.stdio: package, module
std.algorithm: package
std.digest: package

In other words, "std" isn't a package _or_ module, and std.stdio 
is both (even though it's just a single D source file). This 
doesn't seem quite right.


There could be an error in my patch to DMD, but I don't see where 
it could be because it's so simple. The code is at 
https://github.com/blm768/dmd/tree/new_traits if anyone wants to 
look over it.


If anyone can help me figure out what's going on, I'd greatly 
appreciate it.


C++ to add import, module and export

2015-11-24 Thread deadalnix via Digitalmars-d

According to this:
https://www.youtube.com/watch?v=RwdQA0pGWa4

There are plan to add these keyword in C++'s module system.


Creating D bindings for a C library

2015-11-24 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

Hello all,

I'm considering creating some D bindings for a C library.  Before 
I start, I was wondering if anyone could advise me on the current 
state-of-the-art in automatically converting C headers to .d or 
.di files; it's a long time since I've looked at anything to do 
with this and the interfacing-with-C page in the D reference 
doesn't mention any tools.


Thanks in advance for any advice,

Best wishes,

-- Joe


Re: Creating D bindings for a C library

2015-11-24 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 23:14:14 UTC, Joseph Rushton 
Wakeling wrote:

I'm considering creating some D bindings for a C library.


I should probably clarify that I know what to do assuming I have 
to write all the bindings manually.  However, as the library has 
quite a lot of header files, I'd really much rather auto-convert 
as much as possible, hence the questions above :-)


Re: RAII is misleading

2015-11-24 Thread bitwise via Digitalmars-d

On Tuesday, 24 November 2015 at 19:37:33 UTC, duff wrote:

On Tuesday, 24 November 2015 at 19:22:46 UTC, bitwise wrote:

On Tuesday, 24 November 2015 at 18:22:12 UTC, duff wrote:

On Tuesday, 24 November 2015 at 17:03:47 UTC, bitwise wrote:
Then, during recursive serialization, if you found an object 
which was already in the table, you wouldn't serialize it 
again.


But this doesn't give the guarentee that the real citizen who 
responsible to tell the client "hey i've got the ref" can do 
it. With RC, the real owner may not know that his resource is 
stolen by a children.


The way that I was dealing with this at the time was 
requesting resources(files) from a shared repository by name. 
The repository would either load the file and instantiate the 
appropriate object, or return the object if it already 
existed. So, no node in the graph ever really owned a 
resource. All resources were owned by one central repository. 
Now, this was only enforced by convention, so I suppose 
someone could call delete on the shared_ptr's internal 
pointer, but making this strictly enforced through language 
features is difficult, if at all possible without major 
comprimises.


There is some discussion about this idea in the dlang Study 
forum. They're trying to figure out how to implement ref 
counting in D in a totally @safe way(impossible to currupt 
memory). I think that some major comprimises will have to be 
made, and I personally wohld rather deal with this issue 
through good coding conventions.


   Bit


I know that there is a study group.
And it's not the first time I post this:

http://www.reactiongifs.com/r/dnd.gif

because manual memory managment is the stuff.


I had my way, the first thing I would do is get rid of @safe and 
shared ;)


Its not that I don't think the general idea of making the 
language safe is good, but there is just so much that can go 
wrong in a systems programming language, its like throwing 
glasses of water at a burning house instead of just calling the 
fire department..


Never underestimate the resourcefulness of a bad programmer!



Re: Calypso progress report (+ updated MingW64 build)

2015-11-24 Thread deadalnix via Digitalmars-d-announce

On Tuesday, 24 November 2015 at 22:51:40 UTC, Elie Morisse wrote:

On Tuesday, 24 November 2015 at 06:44:31 UTC, deadalnix wrote:
Yeah that's what I wanted to look int he IR. Where is 
_D_ZTISt9exception7__tiwrap defined ? Looks like you trimed 
the output :(


Sorry I got a little heavy handed, here's the full IR: 
https://paste.kde.org/piivojs0s


<3 <3 <3 <3



Re: [OT] bitcoin donation

2015-11-24 Thread deadalnix via Digitalmars-d-announce
On Monday, 23 November 2015 at 12:11:36 UTC, Steven Schveighoffer 
wrote:
One could ask the same thing about any currency that isn't the 
one accepted at a store.


I looked with a tinge of fascination at what bitcoin was a 
while ago. I think there is a natural averse reaction to 
something that is valuable but that you cannot understand.




Don't be confused. Krugman do not understand bitcoin, but Krugman 
think that terrorism and riots are good, that the internet will 
never work and that there was no bubble in 2008, so I think is it 
fairly secure to ignore him.


Many other economist have model that explain bitcoin's value.

I know bitcoin has real math and genius behind it, and this is 
a silly example, but for those who do not understand how it 
actually works (including myself), it seems very similar in 
nature. Dollars (or whatever local currency you use) are 
understandable, and generally accepted at places where I shop. 
It's easy to see how one cannot duplicate them without evidence 
of doing so (the fundamental characteristic of currency). 
Online bits don't seem so uncopyable.


-Steve


Most people to not understand fractional reserve, bond emission, 
or how credit card works. I think that's ok.


Back to the point, one of the value of bitcoin is to be able to 
transfer money internationally easily and for cheap. People that 
do have USD to spend on digital mars do not care. People abroad 
do care.


Now I don't expect that accepting bitcoin will create a giant 
wave of donation, but, if anything, it is always good PR and not 
complicated. There is also no reason to refuse a donation or to 
make it more complex to do a donation.


Andrei, Walter, if you need help to navigate the bitcoin 
ecosystem, you can reach me, I can help.




Re: New D book available for pre-order: D Web Development

2015-11-24 Thread Nick_B via Digitalmars-d-announce

On Wednesday, 29 July 2015 at 21:17:59 UTC, John wrote:

On Wednesday, 22 July 2015 at 15:29:20 UTC, Kai Nacke wrote:
my book D Web Development, available now for pre-order: 
https://www.packtpub.com/web-development/d-web-development




Will this book be available in hardcopy ?

Do you have a planned date for publication ?




Re: New D book available for pre-order: D Web Development

2015-11-24 Thread Rory McGuire via Digitalmars-d-announce
Any chance I could be added to the reviewers for this book?
English is my primary language and I use vibe.d about 25 work hours a week.

On Wed, Jul 22, 2015 at 5:29 PM, Kai Nacke via Digitalmars-d-announce <
digitalmars-d-announce@puremagic.com> wrote:

> Hi all!
>
> Did you notice that development of LDC has been a bit slowly in the past?
> The reason is my book D Web Development, available now for pre-order:
> https://www.packtpub.com/web-development/d-web-development
>
> The story behind the book:
> Some time after the review of the "D Cookbook" I was asked by Packt
> Publishing if I would be interested in writing a book about web development
> with D. By that time I used vibe.d only as a test case for LDC :-) But then
> I took a closer look at the features of vibe.d and got enthusiastic about
> it. I agreed to write the book. Hopefully the book shows much fun it is to
> use D for web applications.
>
> For me writing a book is an incredible experience. It's challenging
> because I am not a native English speaker. But I am having lot of fun in
> exploring all the details, creating examples and writing about it. I
> learned a lot in this process, including some more D programming. :-)
>
> A big thank to all (known and unknown) reviewers, to Andrei for
> contributing the foreword and all others who helped in one way or the other.
>
> Having finished about 60% of the chapters, the other 40% and the rework
> due to comments still absorb most of my time. Please be patient if fixing
> LDC bugs  takes some more time as usual.
>
> Regards,
> Kai
>
>


Re: Calypso progress report (+ updated MingW64 build)

2015-11-24 Thread deadalnix via Digitalmars-d-announce

On Wednesday, 25 November 2015 at 01:04:19 UTC, deadalnix wrote:
On Tuesday, 24 November 2015 at 22:51:40 UTC, Elie Morisse 
wrote:

On Tuesday, 24 November 2015 at 06:44:31 UTC, deadalnix wrote:
Yeah that's what I wanted to look int he IR. Where is 
_D_ZTISt9exception7__tiwrap defined ? Looks like you trimed 
the output :(


Sorry I got a little heavy handed, here's the full IR: 
https://paste.kde.org/piivojs0s


<3 <3 <3 <3


I can't find the runtime that goes with this. My best guess was 
here: 
https://github.com/Syniurge/druntime/blob/release-0.16.1/src/ldc/eh/common.d But it doesn't check the source language.


Can I get some pointers ?


[Issue 15379] "final" attribute on function parameter

2015-11-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15379

Johan Engelen  changed:

   What|Removed |Added

 CC||goejenda...@zonnet.nl

--


[Issue 15379] New: "final" attribute on function parameter

2015-11-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15379

  Issue ID: 15379
   Summary: "final" attribute on function parameter
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: goejenda...@zonnet.nl

The grammar on Dlang.org tells me that "final" is a valid attribute on function
parameters (see "InOutX"), however I cannot find documentation of what that
means. dmd does not accept it on normal function parameters, only on template
parameters:

void foo(final int a); // error!
void bar(T)(final T a); // OK

We should either add documentation on what "final" means for a function
parameter, or fix the grammar if it is (no longer?) supported.

Thanks for any explanation,
 Johan

--


Re: Calypso progress report (+ updated MingW64 build)

2015-11-24 Thread Elie Morisse via Digitalmars-d-announce

On Tuesday, 24 November 2015 at 06:44:31 UTC, deadalnix wrote:
Yeah that's what I wanted to look int he IR. Where is 
_D_ZTISt9exception7__tiwrap defined ? Looks like you trimed the 
output :(


Sorry I got a little heavy handed, here's the full IR: 
https://paste.kde.org/piivojs0s


Re: AA behaves differently in CTFE?

2015-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 11/24/15 2:43 PM, Bastiaan Veelo wrote:

On Tuesday, 24 November 2015 at 14:23:38 UTC, Steven Schveighoffer wrote:

If CTFE associative arrays perform differently, then that is a bug. I
am not sure if this is the case, but you should file a bug anyway,
someone can take a look at it.

If you can narrow it down to a minimal case where it breaks down, that
would be helpful.

-Steve


Thanks. After narrowing it down further I discovered a mistake in my
code, which caused undesired behaviour dependent on the order in which
elements on an AA are traversed by foreach.

As it turns out, the order in which foreach traverses elements of an AA
at compile time differs from the order at run time. So yes, associative
arrays behave differently, but it is hardly a bug since "in a foreach
loop the order in which the elements are iterated is unspecified." [1]

[1] http://dlang.org/hash-map.html


Ah yes, that is very true.

Thanks for looking at it further!

If you need traversal to be consistent, there is std.container.rbtree, 
but it's not very friendly to use as a map.


-Steve


Re: [OT] bitcoin donation

2015-11-24 Thread Laeeth Isharc via Digitalmars-d-announce

On Monday, 23 November 2015 at 14:02:30 UTC, Joakim wrote:
On Monday, 23 November 2015 at 12:11:36 UTC, Steven 
Schveighoffer wrote:
One could ask the same thing about any currency that isn't the 
one accepted at a store.


Sure, online is much less of a hassle, but it's still a little 
time to sign up and administer.  Is that much of Ali's time 
worth spending for at least three donations, likely more?  I 
bet it would be.


I looked with a tinge of fascination at what bitcoin was a 
while ago. I think there is a natural averse reaction to 
something that is valuable but that you cannot understand.

--snip--
I know bitcoin has real math and genius behind it, and this is 
a silly example, but for those who do not understand how it 
actually works (including myself), it seems very similar in 
nature. Dollars (or whatever local currency you use) are 
understandable, and generally accepted at places where I shop. 
It's easy to see how one cannot duplicate them without 
evidence of doing so (the fundamental characteristic of 
currency). Online bits don't seem so uncopyable.


I'm by no means steeped in the tech, but it's pretty 
straightforward to understand the broad strokes.  It's just a 
giant distributed ledger with some crypto to keep it secure and 
hashing to avoid double-counting, ie the duplication you're 
worried about.  But ultimately that doesn't really matter, as 
almost nobody knows how Dollars or other local currencies are 
created or what makes them tough to copy either. ;)


All that matters for a currency is that many buyers and sellers 
will accept it, or at least exchange it quickly and easily for 
your currency of choice, and bitcoin certainly passes that bar.


Regimes vary in how they accommodate some kinds of financial 
innovation.  If you're dealing with dollars anyway, that's one 
thing, but quite another if you have to figure out the peculiar 
local tax treatment (which may well not yet be determinate or 
written down anywhere).  Plus in some places it might invite 
unwelcome scrutiny.


So I agree that bitcoin is a very interesting technology, and 
this may be the real world application of an idea that goes back 
to the 90s of the new monetary economics (a book by cowen and 
kroszner), where the unit of account, medium of exchange, and 
store of value functions of money become unbundled.  But its use 
unreasonable to expect people to behave in an optimising manner 
in every part of their lives, particularly when tax and 
regulation (and uncertainty surrounding them) get in the way.





Re: Swift is coming, Swift is coming

2015-11-24 Thread Jack Stouffer via Digitalmars-d

On Tuesday, 24 November 2015 at 17:59:35 UTC, Joakim wrote:

Will be interesting to see how Swift does


Considering it won't be available for Windows, I'd guess not very 
well and it will remain a niche language until it does. There's a 
reason D shot up in popularity after it started to support 
windows more thoroughly.


Sure you can say that since it will be open source, people can 
create Windows versions. But without Apple merging changes 
upstream (which they have never said they would do) I really 
don't see those efforts lasting long before people realize the 
effort involved probably isn't worth it.


Re: AA behaves differently in CTFE?

2015-11-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 14:23:38 UTC, Steven 
Schveighoffer wrote:
If CTFE associative arrays perform differently, then that is a 
bug. I am not sure if this is the case, but you should file a 
bug anyway, someone can take a look at it.


If you can narrow it down to a minimal case where it breaks 
down, that would be helpful.


-Steve


Thanks. After narrowing it down further I discovered a mistake in 
my code, which caused undesired behaviour dependent on the order 
in which elements on an AA are traversed by foreach.


As it turns out, the order in which foreach traverses elements of 
an AA at compile time differs from the order at run time. So yes, 
associative arrays behave differently, but it is hardly a bug 
since "in a foreach loop the order in which the elements are 
iterated is unspecified." [1]


[1] http://dlang.org/hash-map.html


Re: Something about Chinese Disorder Code

2015-11-24 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 24 Nov 2015 17:08:33 +
schrieb BLM768 :

> On Tuesday, 24 November 2015 at 09:48:45 UTC, magicdmer wrote:
> > I display chinese string like:
> >
> > auto str = "你好,世界"
> > writeln(str)
> >
> > and The display is garbled。
> >
> > some windows api like MessageBoxA ,if string is chinese, it 
> > displays disorder code too
> >
> > i think i must use WideCharToMultiByte to convert it , is there 
> > any other answer to solve this question simplely
> 
> You can also try using a wide string literal, i.e. "你好,世界"w. The 
> suffix forces the string to use 16-bit characters.
> 
> The garbled display from writeln might be related to your console 
> settings. If you aren't using the UTF-8 codepage in cmd.exe, that 
> would explain why the text appears garbled. Unfortunately, 
> Windows has some significant bugs with UTF-8 in the console.

This is really our problem. We pretend the output terminal is
UTF-8 without providing any means to configure the terminal or
converting the output to the terminal's encoding. All OSs
provide conversion API that works for the most part (assuming
normalization form D for example), but we just don't use them.
Most contributers were on Linux or English Windows system
where the issue is not obvious. But even in Europe łáö will
come out garbled.

Now this is mostly not an issue with modern Linux and OS X as
the default is UTF-8, but some people refuse to change to
variable length encodings and Windows has always been
preferring fixed length encodings.

The proper way to solve this for the OP in a cross-platform
way is to replace writeln with something that detects whether
the output is a terminal and then converts the string to
something that will display correctly, which can be a simple
wchar[] on Windows or the use of iconv on Linux. Ketmar is
currently using iconv to print D string on his Linux set up
for Cyrillic KIO-8U and I think I used it in some code as
well. It is not perfect, but will make most printable strings
readable. ICU I think is the only library that gets it 100%
correct with regards to normalization and offering you
different error concealment methods.

-- 
Marco



Re: Communicating with external processes in D

2015-11-24 Thread Jesse Phillips via Digitalmars-d-learn

On Monday, 23 November 2015 at 20:02:16 UTC, Cameron Reid wrote:

I'm rather new to D, so apologies if this is a silly question:

I'd like to be able to fork a number of instances of a process, 
write to their stdins and read from their stdouts in parallel. 
That is, I want to write some data to the stdin of all these 
processes and collect lines written to their stdouts as soon as 
they're emitted by the process.


I tried for quite a while last night using permutations of 
pipeProcess and i/o redirection but nothing did exactly what I 
was looking for.


Is such a thing possible? If so, where might I go to educate 
myself?


pipeProcess will give you the input/output pair (and believe the 
output is accessible at the available time the program writes a 
line). To publish the same input to multiple pipes will be 
something have to create along with a receiver of multiple 
outputs.


That is to say, you can do it, but managing read/write is on you.


Re: https everywhere!

2015-11-24 Thread Walter Bright via Digitalmars-d-announce

On 11/24/2015 10:59 AM, David Nadlinger wrote:

There are a number of issues with how SSL is set up on the server, from
misconfiguration and/or outdated software:
https://www.ssllabs.com/ssltest/analyze.html?d=dlang.org=on

Compare this e.g. to issues.dlang.org, which achieves a solid A grade (although
it uses a SHA-1 intermediary certificate, which will lead to issues soon):
https://www.ssllabs.com/ssltest/analyze.html?d=issues.dlang.org=on



Thanks, I forwarded this to Jan.


Re: How to use D parallel functions/library

2015-11-24 Thread anonymous via Digitalmars-d-learn

On 24.11.2015 19:49, Bishop120 wrote:

I figured this would be a simple parallel foreach function with an iota
range of sizeX and just making int X declared inside the function so
that I didnt have to worry about shared variable but I cant get around
the alive++ reduction and I dont understand enough about D's
reduction/parallel library.

Any ideas?  Thanks in advance for yalls patience and assistance!


I'm not sure what you're asking. Are you maybe looking for 
core.atomic.atomicOp?


Example:

import core.atomic: atomicOp;
import std.parallelism: parallel;
import std.range: iota;
import std.stdio: writeln;

void main()
{
int x = 0;
shared int y = 0;
foreach(i; parallel(iota(100_000)))
{
++x;
y.atomicOp!"+="(1);
}
writeln(x); /* usually less than 100_000 */
writeln(y); /* 100_000 */
}



Re: Something about Chinese Disorder Code

2015-11-24 Thread Rikki Cattermole via Digitalmars-d-learn

On 25/11/15 1:47 AM, Meta wrote:

On Tuesday, 24 November 2015 at 09:52:21 UTC, Rikki Cattermole wrote:

On 24/11/15 10:48 PM, magicdmer wrote:

I display chinese string like:

auto str = "你好,世界"
writeln(str)

and The display is garbled。

some windows api like MessageBoxA ,if string is chinese, it displays
disorder code too

i think i must use WideCharToMultiByte to convert it , is there any
other answer to solve this question simplely


*A windows API functions are for ASCII only.
You need the *W varients which are unicode.
For this you could use std.conv : to.

wstring text = "my str".to!wstring;

Or at least I'm pretty sure that will work for you.


I'm pretty sure you can just do:

wstring text = "my string";

Or

auto text = "my string"w;


The second one is correct yes.
I'm just assuming that it isn't compiled into the executable.


switch with enum

2015-11-24 Thread tcak via Digitalmars-d-learn
I have seen a code a while ago, but even by looking at 
documentation, I couldn't have found anything about it.


Let's say I have defined an enum;

enum Status: ubyte{
 Busy = 1,
 Active = 2
}

and received a ubyte value from user.

ubyte userValue;

I want to switch over userValue, but that should depend on Status.

switch( userValue ){
...
}

What I mean is that compiler should enforce values of enum 
"Status" to be declared in switch as it would be done with "final 
switch", but as you can guess, user might enter a value that is 
not defined by Status. Thus, I should be able to enter the case 
"default" as well.


I remember it something like switch( userValue ) with( Status 
){...}, but not sure about it. Maybe it was D1 code. Is there 
anything like this currently?


Re: switch with enum

2015-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 11/24/15 10:51 PM, tcak wrote:

I have seen a code a while ago, but even by looking at documentation, I
couldn't have found anything about it.

Let's say I have defined an enum;

enum Status: ubyte{
  Busy = 1,
  Active = 2
}

and received a ubyte value from user.

ubyte userValue;

I want to switch over userValue, but that should depend on Status.

switch( userValue ){

}

What I mean is that compiler should enforce values of enum "Status" to
be declared in switch as it would be done with "final switch", but as
you can guess, user might enter a value that is not defined by Status.
Thus, I should be able to enter the case "default" as well.


All final switch does is ensure you are covering all possible enums. It 
assumes that the value is already a valid enum value. If you did final 
switch on userValue, it would require you handle all 256 possible values 
for ubyte. So you would have to cast first.




I remember it something like switch( userValue ) with( Status ){...},
but not sure about it. Maybe it was D1 code. Is there anything like this
currently?


What this does (and yes, it should work) is make it so you don't have to 
type "Status.Busy" within your case statements. You can just type 
"Busy". That's all.


-Steve


Re: Something about Chinese Disorder Code

2015-11-24 Thread magicdmer via Digitalmars-d-learn

On Tuesday, 24 November 2015 at 19:41:12 UTC, Marco Leise wrote:

Am Tue, 24 Nov 2015 17:08:33 +
schrieb BLM768 :

[...]


thank you for your answers.

I solved it.
windows console like:
fwide(core.stdc.stdio.stdout, 1);
setlocale(0, cast(char*)"china");
auto str = "你好,世界";
writeln(str);

MessageBox like:
const wchar *wstring = toUTF16z("你好,世界");
MessageBoxW(null,wstring,wstring,0);


Re: switch with enum

2015-11-24 Thread tcak via Digitalmars-d-learn
On Wednesday, 25 November 2015 at 03:59:01 UTC, Steven 
Schveighoffer wrote:

On 11/24/15 10:51 PM, tcak wrote:
I have seen a code a while ago, but even by looking at 
documentation, I

couldn't have found anything about it.

Let's say I have defined an enum;

enum Status: ubyte{
  Busy = 1,
  Active = 2
}

and received a ubyte value from user.

ubyte userValue;

I want to switch over userValue, but that should depend on 
Status.


switch( userValue ){

}

What I mean is that compiler should enforce values of enum 
"Status" to
be declared in switch as it would be done with "final switch", 
but as
you can guess, user might enter a value that is not defined by 
Status.

Thus, I should be able to enter the case "default" as well.


All final switch does is ensure you are covering all possible 
enums. It assumes that the value is already a valid enum value. 
If you did final switch on userValue, it would require you 
handle all 256 possible values for ubyte. So you would have to 
cast first.




I remember it something like switch( userValue ) with( Status 
){...},
but not sure about it. Maybe it was D1 code. Is there anything 
like this

currently?


What this does (and yes, it should work) is make it so you 
don't have to type "Status.Busy" within your case statements. 
You can just type "Busy". That's all.


-Steve


As far as I see, "default" case is not allowed when final switch
is used. From compiler developer's perspective, it is meaningful
and I can understand, but thinking about use cases as I have
given an example, this limitation prevents writing "tight" code.
(That is the term I could have found to express I am trying to 
say).


Re: How to use D parallel functions/library

2015-11-24 Thread thedeemon via Digitalmars-d-learn

On Tuesday, 24 November 2015 at 18:49:25 UTC, Bishop120 wrote:
I figured this would be a simple parallel foreach function with 
an iota range of sizeX and just making int X declared inside 
the function so that I didnt have to worry about shared 
variable but I cant get around the alive++ reduction and I dont 
understand enough about D's reduction/parallel library.


Any ideas?  Thanks in advance for yalls patience and assistance!


Incrementing often the same variable from different parallel 
threads is a very bad idea in terms of performance. I would 
suggest counting number of alive cells for each row independently 
(in a local non-shared variable) and storing it to an array (one 
value per row), then after the loop sum them up.


auto aliveCellsPerRow = new int[N];

foreach(i; iota(N).parallel) {
  int aliveHere;
  //...process a row...
  aliveCellsPerRow[i] = aliveHere;
}

alive = aliveCellsPerRow.sum;

Then everything will be truly parallel, correct and fast.


Re: [OT] bitcoin donation

2015-11-24 Thread Rory McGuire via Digitalmars-d-announce
On Wed, Nov 25, 2015 at 4:33 AM, deadalnix via Digitalmars-d-announce <
digitalmars-d-announce@puremagic.com> wrote:

> On Monday, 23 November 2015 at 12:11:36 UTC, Steven Schveighoffer wrote:
>
>> One could ask the same thing about any currency that isn't the one
>> accepted at a store.
>>
>> I looked with a tinge of fascination at what bitcoin was a while ago. I
>> think there is a natural averse reaction to something that is valuable but
>> that you cannot understand.
>>
>>
> Don't be confused. Krugman do not understand bitcoin, but Krugman think
> that terrorism and riots are good, that the internet will never work and
> that there was no bubble in 2008, so I think is it fairly secure to ignore
> him.
>
> Many other economist have model that explain bitcoin's value.
>
> I know bitcoin has real math and genius behind it, and this is a silly
>> example, but for those who do not understand how it actually works
>> (including myself), it seems very similar in nature. Dollars (or whatever
>> local currency you use) are understandable, and generally accepted at
>> places where I shop. It's easy to see how one cannot duplicate them without
>> evidence of doing so (the fundamental characteristic of currency). Online
>> bits don't seem so uncopyable.
>>
>> -Steve
>>
>
> Most people to not understand fractional reserve, bond emission, or how
> credit card works. I think that's ok.
>
> Back to the point, one of the value of bitcoin is to be able to transfer
> money internationally easily and for cheap. People that do have USD to
> spend on digital mars do not care. People abroad do care.
>
> Now I don't expect that accepting bitcoin will create a giant wave of
> donation, but, if anything, it is always good PR and not complicated. There
> is also no reason to refuse a donation or to make it more complex to do a
> donation.
>
> Andrei, Walter, if you need help to navigate the bitcoin ecosystem, you
> can reach me, I can help.
>
>
:D anyone could accept donations to Ali on his behalf and then send him
dollars whenever it reaches a certain value.

Does the D Foundation have a bitcoin address?


convertion of type tuple to enum

2015-11-24 Thread drug via Digitalmars-d-learn

What is the best way to do subj? I did
```
import std.array: array;
import std.typetuple: TypeTuple;
import std.typecons: tuple;
import std.traits: EnumMembers;

struct Foo {}
struct Bar {}
struct FooBar {}
struct Baz {}

string convertTypeTupleToEnum(Types...)()
{
string s = "enum Kind { ";

foreach(T; Types)
{
s ~= T.stringof ~ ", ";
}
s ~= "}";

return s;
}

alias Types = TypeTuple!(Foo, Bar, FooBar, Baz);

void main()
{
mixin(convertTypeTupleToEnum!(Types));

	assert(EnumMembers!Kind.tuple.array == [ Kind.Foo, Kind.Bar, 
Kind.FooBar, Kind.Baz]);

}
```
(also here http://dpaste.dzfl.pl/bc6f19770f85). Is there a way to do it 
without string mixin? Thanks!


Re: 50% inative

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 17:10:09 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:51:58 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 
50 % haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


If I look at the list of people in the dlang organisation, 50 
%

haven't done anything in the >>last<< 2 monthes...

no review, no merge, no commit, nothing..


Staline would say: it's time to clean up.


https://github.com/shoo?tab=activity
https://github.com/complexmath?tab=activity
https://github.com/jordisayol?tab=activity
https://github.com/donc?tab=activity
https://github.com/repeatedly?tab=activity
https://github.com/dsimcha?tab=activity

etc...

Among those, nobody takes the time to review and merge the 
simple fixes related to ddoc or things like that. Among those, 
nobody takes the time to read bugzilla and to fix the simple 
bugs whose fixes are constantly proposed by external people who 
gotta wait because among those people there is no activity.


If at least they would be able to find some regressions when a 
new release comes...but no.


Idle people. Useless people.


Re: 50% inative

2015-11-24 Thread tcak via Digitalmars-d

On Tuesday, 24 November 2015 at 17:10:09 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:51:58 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

[...]


Staline would say: it's time to clean up.


https://github.com/shoo?tab=activity
https://github.com/complexmath?tab=activity
https://github.com/jordisayol?tab=activity
https://github.com/donc?tab=activity
https://github.com/repeatedly?tab=activity
https://github.com/dsimcha?tab=activity

etc...

Among those, nobody takes the time to review and merge the 
simple fixes related to ddoc or things like that. Among those, 
nobody takes the time to read bugzilla and to fix the simple 
bugs whose fixes are constantly proposed by external people who 
gotta wait because among those people there is no activity.


Hey, those who don't have activity. Either work, or we will stop 
paying you.


[Issue 15378] New: dlang.org does not completely work with https:

2015-11-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15378

  Issue ID: 15378
   Summary: dlang.org does not completely work with https:
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: bugzi...@digitalmars.com

As reported on the n.g.:

> The forum widget isn't going to work until the forum is also HTTPS with a 
> valid certificate.

> This week's "This Week in D" excerpt on the front page

> Runnable examples on the front page (more so than usual, now they are 
> completely broken)

> Chrome warns saying that dlang connection is encrypted with obsolete 
> cryptography

--


Re: 50% inative

2015-11-24 Thread Brad Anderson via Digitalmars-d

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 50 % 
haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


Interest and contributions, even from core members, often comes 
in bursts. There is no harm in keeping idle contributors around.


Re: 50% inative

2015-11-24 Thread David DeWitt via Digitalmars-d

On Tuesday, 24 November 2015 at 17:35:54 UTC, duff wrote:

On Tuesday, 24 November 2015 at 17:10:09 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:51:58 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

Staline would say: it's time to clean up.


https://github.com/shoo?tab=activity
https://github.com/complexmath?tab=activity
https://github.com/jordisayol?tab=activity
https://github.com/donc?tab=activity
https://github.com/repeatedly?tab=activity
https://github.com/dsimcha?tab=activity

etc...

Among those, nobody takes the time to review and merge the 
simple fixes related to ddoc or things like that. Among those, 
nobody takes the time to read bugzilla and to fix the simple 
bugs whose fixes are constantly proposed by external people 
who gotta wait because among those people there is no activity.


If at least they would be able to find some regressions when a 
new release comes...but no.


Idle people. Useless people.



Some of those ppl have contributed greatly to D and probably 
still do behind the scenes so I doubt they deserve to be 
"removed" from the D organization and would even be considered 
for removal if anything more people need to get involved.


Re: Is facebook moving away from D?

2015-11-24 Thread deadalnix via Digitalmars-d

On Tuesday, 24 November 2015 at 10:05:36 UTC, Bruce Adams wrote:

What do you guys think?


As mentioned I work at Facebook, so I can give you some update on 
this, without going into to much details.


These projects are still used at Facebook. Facebook tend to be a 
all or nothing shop, and that's why you see no activity on these 
projects.


Facebook is not a D shop. Facebook is using D, but as other 
mentioned, D has no privileged position in the company. It has 
the same position as other "alternative" languages (meaning not 
C++ or Hack) like Haskell.




Re: RAII is misleading

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 17:03:47 UTC, bitwise wrote:
Then, during recursive serialization, if you found an object 
which was already in the table, you wouldn't serialize it again.


But this doesn't give the guarentee that the real citizen who 
responsible to tell the client "hey i've got the ref" can do it. 
With RC, the real owner may not know that his resource is stolen 
by a children.





How to use D parallel functions/library

2015-11-24 Thread Bishop120 via Digitalmars-d-learn
Hey everyone.  A new D learner here.  So far I love D and how 
much better its working than C++.  One thing I like doing is 
parallel functions so with C++ using OMP.  Right now Im trying to 
figure out how to do Conways Game of Life in D in parallel.  
Serially D is much faster than C++ so I feel fairly confident 
that it should be faster using D's parallelism library.


In C++ with OMP its pretty easy to do a parallel for with a 
private and a reduction variable but I am having problems 
understanding how to do this in D.  Heres the meat of my parallel 
code for the Game of Life.  Can yall help me understand how to 
convert this to D?


//Iterate through 2d matrix ignoring the border cells (starting 
at 1 and going to matrix size)

#pragma omp for private (x) reduction (+:alive) schedule (dynamic)
for (int i = 1; i <= sizeX; i++)
{
for (int j = 1; j <= sizeY; j++)
{
//Set X to 0... sumerize all 8 of X's neighbors including 
border cells

x = 0;
x += matrixA[i - 1][j] + matrixA[i + 1][j] + matrixA[i][j - 
1] + matrixA[i][j + 1] + matrixA[i - 1][j - 1] + matrixA[i - 1][j 
+ 1] + matrixA[i + 1][j - 1] + matrixA[i + 1][j + 1];


//If cell is alive
if (matrixA[i][j] == true)
{
//Cell dies if it doesnot have 2 or 3 
neighbors
if (x < 2 || x > 3)
{
matrixB[i][j] = false;
}
//Mark cell as alive in matrix B
else
{
matrixB[i][j] = true;
alive++;
}
}

//If cell is not alive
else
{
//Cell becomes alive if it has exactly 
3 neighbors
if (x == 3)
{
//Mark cell alive in matrix B
matrixB[i][j] = true;
alive++;
}
}
}
}

The Matrices are bools since its only alive or dead.  I keep 
track of the number of alive cells so that I can see at a glance 
if things are working correctly since the same seed run the same 
number of iterations will always have the same outcome.  For 
simplicity sake imagine that the matrices are 2002 x 2002.  The 
reason they are extra rows and columns is so that I can do wrap 
around but thats not relevant here.


I figured this would be a simple parallel foreach function with 
an iota range of sizeX and just making int X declared inside the 
function so that I didnt have to worry about shared variable but 
I cant get around the alive++ reduction and I dont understand 
enough about D's reduction/parallel library.


Any ideas?  Thanks in advance for yalls patience and assistance!

Thomas



DUB, Platform specifications and dependencies

2015-11-24 Thread Zardoz via Digitalmars-d-learn
Actually I'm trying to setup dub to not grab a dependency on 
Windows ( 
https://github.com/Zardoz89/DEDCPU-16/blob/master/dub.sdl ) :


name "dedcpu"
authors "Luis Panadero Guardeño"
targetType "none"
license "BSD 3-clause"
description "DCPU-16 tools"

subPackage {
  name "lem1802"
  description "Visual LEM1802 font editor"
  targetType "executable"
  targetName "lem1802"
  excludedSourceFiles "src/bconv.d"
  excludedSourceFiles "src/ddis.d"
  dependency "gtk-d:gtkd" version="~>3.2.0" platform="posix"
  libs "gtkd" platform="windows"
}

...

How ever, running dub on Windows (tested on two different 
machines), ignores platform specification for gtk-d dependency . 
What I'm doing wrong ?


Re: Something about Chinese Disorder Code

2015-11-24 Thread BLM768 via Digitalmars-d-learn

On Tuesday, 24 November 2015 at 09:48:45 UTC, magicdmer wrote:

I display chinese string like:

auto str = "你好,世界"
writeln(str)

and The display is garbled。

some windows api like MessageBoxA ,if string is chinese, it 
displays disorder code too


i think i must use WideCharToMultiByte to convert it , is there 
any other answer to solve this question simplely


You can also try using a wide string literal, i.e. "你好,世界"w. The 
suffix forces the string to use 16-bit characters.


The garbled display from writeln might be related to your console 
settings. If you aren't using the UTF-8 codepage in cmd.exe, that 
would explain why the text appears garbled. Unfortunately, 
Windows has some significant bugs with UTF-8 in the console.


Re: 50% inative

2015-11-24 Thread Ilya Yaroshenko via Digitalmars-d

On Tuesday, 24 November 2015 at 16:51:58 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 50 
% haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


If I look at the list of people in the dlang organisation, 50 %
haven't done anything in the >>last<< 2 monthes...

no review, no merge, no commit, nothing..


Staline would say: it's time to clean up.


Stalin*.

I suppose that you can try to offer this again after and if you 
become a member of D core team ;-)


Re: 50% inative

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 50 % 
haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


If I look at the list of people in the dlang organisation, 50 %
haven't done anything in the >>last<< 2 monthes...

no review, no merge, no commit, nothing..


Re: RAII is misleading

2015-11-24 Thread bitwise via Digitalmars-d

On Tuesday, 24 November 2015 at 16:12:23 UTC, duff wrote:

On Tuesday, 24 November 2015 at 15:14:16 UTC, duff wrote:
I've discovered this when working on a kind of "fat pointer" 
system.


The "RAII" term is misleading, it tends to let people think 
that the one who initializes a resource is its owner.


The reality is different. The real owner of a resource is the 
one who see it "as valid" for the first time.


You would like to serialize a tree of object ?

Using ReferenceCounting: which one has to write the properties 
of an object that's only a reference ?


Using ReferenceCounting: let's say that the last object who has 
a referenced object serialiazes it, there's no guarantee that 
when the soft run again his reference is already set...


The only way to do this correctly is to use system of ownership 
rather than RC system.


One approach is to start serialization at the root node, annd 
whoever sees a node first could serialize it, and all references 
it contains, recursively. When an object is serialized, its 
memory address or unique ID of some kind could be added to a 
hashtable. Then, during recursive serialization, if you found an 
object which was already in the table, you wouldn't serialize it 
again. If we were talking about C++, I would say to use the 
object address as the unique ID - shared_ptr::get(). Im not 
sure if D's RefCounted has an equivalent function.


For deserializing, you could do two passes. First, read all nodes 
into a table, which you can index by the node's old memory 
address, and second, build the tree and resolve referenes to the 
new nodes' addresses.


I'm not claiming this is the best approach, but it has worked for 
me in the past.


   Bit


Re: 50% inative

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 16:51:58 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 50 
% haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


If I look at the list of people in the dlang organisation, 50 %
haven't done anything in the >>last<< 2 monthes...

no review, no merge, no commit, nothing..


Staline would say: it's time to clean up.


https://github.com/shoo?tab=activity
https://github.com/complexmath?tab=activity
https://github.com/jordisayol?tab=activity
https://github.com/donc?tab=activity
https://github.com/repeatedly?tab=activity
https://github.com/dsimcha?tab=activity

etc...

Among those, nobody takes the time to review and merge the simple 
fixes related to ddoc or things like that. Among those, nobody 
takes the time to read bugzilla and to fix the simple bugs whose 
fixes are constantly proposed by external people who gotta wait 
because among those people there is no activity.


Re: 50% inative

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 50 
% haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


If I look at the list of people in the dlang organisation, 50 %
haven't done anything in the >>last<< 2 monthes...

no review, no merge, no commit, nothing..


Staline would say: it's time to clean up.


Re: https everywhere!

2015-11-24 Thread Walter Bright via Digitalmars-d-announce

On 11/24/2015 12:55 AM, Vladimir Panteleev wrote:

This change could've been done with some community communication, no? Then we
could've gone into this prepared.



Jan just turned off the automatic http: => https: redirect. That will keep the 
site working as before giving time to get everything working with https:


I ask that everything that doesn't work with https: get filed as a bugzilla 
issue. I've filed these:


https://issues.dlang.org/show_bug.cgi?id=15378


Re: range.save

2015-11-24 Thread Freddy via Digitalmars-d
On Tuesday, 24 November 2015 at 01:53:39 UTC, Steven 
Schveighoffer wrote:

...
I can't quite think of an example right now but there was a 
thread about this a few years ago. 
http://forum.dlang.org/thread/twnymbxfdmqupsfjf...@forum.dlang.org


Re: 50% inative

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 17:45:26 UTC, Brad Anderson wrote:

On Tuesday, 24 November 2015 at 16:47:55 UTC, duff wrote:
If I look at the list of people in the dlang organisation, 50 
% haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


Interest and contributions, even from core members, often comes 
in bursts. There is no harm in keeping idle contributors around.


burst of interest for people who are constantly interested ?

Who is in the right place ?


Swift is coming, Swift is coming

2015-11-24 Thread Joakim via Digitalmars-d
A Wired article about Swift coming to the server, particularly 
after the imminent open-sourcing, that also mentions D as an 
alternative, especially since it's written by the same guy who 
wrote about D for Wired last year:


http://www.wired.com/2015/11/apples-swift-ios-programming-language-is-being-remade-for-data-centers/

Will be interesting to see how Swift does, a good natural 
experiment for those pushing D to focus on one niche before 
expanding, as Swift is doing really well on one of the most 
important development platforms today, iOS, before expanding onto 
the server.  Of course, Apple is unlikely to really push it on 
the server, other than open-sourcing and accepting patches, so 
they have a built-in excuse if it doesn't do well. ;)


Re: 50% inative

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 17:47:01 UTC, David DeWitt wrote:

On Tuesday, 24 November 2015 at 17:35:54 UTC, duff wrote:

On Tuesday, 24 November 2015 at 17:10:09 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:51:58 UTC, duff wrote:

On Tuesday, 24 November 2015 at 16:49:07 UTC, duff wrote:

Staline would say: it's time to clean up.


https://github.com/shoo?tab=activity
https://github.com/complexmath?tab=activity
https://github.com/jordisayol?tab=activity
https://github.com/donc?tab=activity
https://github.com/repeatedly?tab=activity
https://github.com/dsimcha?tab=activity

etc...

Among those, nobody takes the time to review and merge the 
simple fixes related to ddoc or things like that. Among 
those, nobody takes the time to read bugzilla and to fix the 
simple bugs whose fixes are constantly proposed by external 
people who gotta wait because among those people there is no 
activity.


If at least they would be able to find some regressions when a 
new release comes...but no.


Idle people. Useless people.



Some of those ppl have contributed greatly to D and probably 
still do behind the scenes so I doubt they deserve to be 
"removed" from the D organization and would even be considered 
for removal if anything more people need to get involved.


I understand that J.Sayol has done a great job in the past, but 
except this work for the installer...I don't get why do you keep 
such people in your organisation.
I mean that it appened to me to make some small things for "Him" 
or "Her"...but i'm not member of their companies...


Re: Is facebook moving away from D?

2015-11-24 Thread Andrei Alexandrescu via Digitalmars-d

On 11/24/2015 05:05 AM, Bruce Adams wrote:

I was just looking at the git hub pages for warp and flint and I notice
they've recently been labelled as "no longer maintained"


Maintaining OSS projects is difficult; they barely keep up with folly. 
The code is still used internally. -- Andrei


Re: RAII is misleading

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 15:14:16 UTC, duff wrote:
I've discovered this when working on a kind of "fat pointer" 
system.


The "RAII" term is misleading, it tends to let people think 
that the one who initializes a resource is its owner.


The reality is different. The real owner of a resource is the 
one who see it "as valid" for the first time.


You would like to serialize a tree of object ?

Using ReferenceCounting: which one has to write the properties of 
an object that's only a reference ?


Using ReferenceCounting: let's say that the last object who has a 
referenced object serialiazes it, there's no guarantee that when 
the soft run again his reference is already set...


The only way to do this correctly is to use system of ownership 
rather than RC system.




50% inative

2015-11-24 Thread duff via Digitalmars-d
If I look at the list of people in the dlang organisation, 50 % 
haven't done anything in the that 2 monthes...


no review, no merge, no commit, nothing...


Re: https everywhere!

2015-11-24 Thread David Nadlinger via Digitalmars-d-announce

On Monday, 23 November 2015 at 20:55:32 UTC, Walter Bright wrote:
I'm pleased to announce that Jan Knepper has gotten us some 
proper certificates now, and dlang.org and digitalmars.com are 
now fully https!


There are a number of issues with how SSL is set up on the 
server, from misconfiguration and/or outdated software: 
https://www.ssllabs.com/ssltest/analyze.html?d=dlang.org=on


Compare this e.g. to issues.dlang.org, which achieves a solid A 
grade (although it uses a SHA-1 intermediary certificate, which 
will lead to issues soon): 
https://www.ssllabs.com/ssltest/analyze.html?d=issues.dlang.org=on


 — David


[Issue 15378] dlang.org does not completely work with https:

2015-11-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15378

David Nadlinger  changed:

   What|Removed |Added

 CC||c...@klickverbot.at

--- Comment #1 from David Nadlinger  ---
There is also a number of issues with the server-side configuration, including
vulnerability to known attacks:
https://www.ssllabs.com/ssltest/analyze.html?d=dlang.org=on

While perhaps not a matter of life and death in the case of dlang.org, it is
certainly not good advertisement for D (cf. also the fact that it doesn't even
show as "green" on Chrome).

--


Re: https everywhere!

2015-11-24 Thread duff via Digitalmars-d-announce
On Tuesday, 24 November 2015 at 18:59:39 UTC, David Nadlinger 
wrote:
On Monday, 23 November 2015 at 20:55:32 UTC, Walter Bright 
wrote:
I'm pleased to announce that Jan Knepper has gotten us some 
proper certificates now, and dlang.org and digitalmars.com are 
now fully https!


There are a number of issues with how SSL is set up on the 
server, from misconfiguration and/or outdated software: 
https://www.ssllabs.com/ssltest/analyze.html?d=dlang.org=on


Compare this e.g. to issues.dlang.org, which achieves a solid A 
grade (although it uses a SHA-1 intermediary certificate, which 
will lead to issues soon): 
https://www.ssllabs.com/ssltest/analyze.html?d=issues.dlang.org=on


 — David


You're part of the bikscheder team.


Re: RAII is misleading

2015-11-24 Thread bitwise via Digitalmars-d

On Tuesday, 24 November 2015 at 18:22:12 UTC, duff wrote:

On Tuesday, 24 November 2015 at 17:03:47 UTC, bitwise wrote:
Then, during recursive serialization, if you found an object 
which was already in the table, you wouldn't serialize it 
again.


But this doesn't give the guarentee that the real citizen who 
responsible to tell the client "hey i've got the ref" can do 
it. With RC, the real owner may not know that his resource is 
stolen by a children.


The way that I was dealing with this at the time was requesting 
resources(files) from a shared repository by name. The repository 
would either load the file and instantiate the appropriate 
object, or return the object if it already existed. So, no node 
in the graph ever really owned a resource. All resources were 
owned by one central repository. Now, this was only enforced by 
convention, so I suppose someone could call delete on the 
shared_ptr's internal pointer, but making this strictly enforced 
through language features is difficult, if at all possible 
without major comprimises.


There is some discussion about this idea in the dlang Study 
forum. They're trying to figure out how to implement ref counting 
in D in a totally @safe way(impossible to currupt memory). I 
think that some major comprimises will have to be made, and I 
personally wohld rather deal with this issue through good coding 
conventions.


   Bit


Re: https everywhere!

2015-11-24 Thread David Nadlinger via Digitalmars-d-announce

On Tuesday, 24 November 2015 at 19:13:22 UTC, duff wrote:

You're part of the bikscheder team.


What is this even supposed to mean?

 — David


Re: RAII is misleading

2015-11-24 Thread bitwise via Digitalmars-d

On Tuesday, 24 November 2015 at 19:22:46 UTC, bitwise wrote:

On Tuesday, 24 November 2015 at 18:22:12 UTC, duff wrote:

On Tuesday, 24 November 2015 at 17:03:47 UTC, bitwise wrote:
Then, during recursive serialization, if you found an object 
which was already in the table, you wouldn't serialize it 
again.


But this doesn't give the guarentee that the real citizen who 
responsible to tell the client "hey i've got the ref" can do 
it. With RC, the real owner may not know that his resource is 
stolen by a children.


The way that I was dealing with this at the time was requesting 
resources(files) from a shared repository by name. The 
repository would either load the file and instantiate the 
appropriate object, or return the object if it already existed. 
So, no node in the graph ever really owned a resource. All 
resources were owned by one central repository. Now, this was 
only enforced by convention, so I suppose someone could call 
delete on the shared_ptr's internal pointer, but making this 
strictly enforced through language features is difficult, if at 
all possible without major comprimises.


There is some discussion about this idea in the dlang Study 
forum. They're trying to figure out how to implement ref 
counting in D in a totally @safe way(impossible to currupt 
memory). I think that some major comprimises will have to be 
made, and I personally wohld rather deal with this issue 
through good coding conventions.


   Bit


I should add that the repository stored references to the 
resources as weak_ptrs so when the resources went out of scope, 
they would be deleted. Similar systems may also choose to keep 
these resources around, even with a ref count of zero, and only 
delete them when more new resources were requested and memory ran 
low. This would be a much more comicated approach though.





Re: RAII is misleading

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 19:22:46 UTC, bitwise wrote:

On Tuesday, 24 November 2015 at 18:22:12 UTC, duff wrote:

On Tuesday, 24 November 2015 at 17:03:47 UTC, bitwise wrote:
Then, during recursive serialization, if you found an object 
which was already in the table, you wouldn't serialize it 
again.


But this doesn't give the guarentee that the real citizen who 
responsible to tell the client "hey i've got the ref" can do 
it. With RC, the real owner may not know that his resource is 
stolen by a children.


The way that I was dealing with this at the time was requesting 
resources(files) from a shared repository by name. The 
repository would either load the file and instantiate the 
appropriate object, or return the object if it already existed. 
So, no node in the graph ever really owned a resource. All 
resources were owned by one central repository. Now, this was 
only enforced by convention, so I suppose someone could call 
delete on the shared_ptr's internal pointer, but making this 
strictly enforced through language features is difficult, if at 
all possible without major comprimises.


There is some discussion about this idea in the dlang Study 
forum. They're trying to figure out how to implement ref 
counting in D in a totally @safe way(impossible to currupt 
memory). I think that some major comprimises will have to be 
made, and I personally wohld rather deal with this issue 
through good coding conventions.


   Bit


I know that there is a study group.
And it's not the first time I post this:

http://www.reactiongifs.com/r/dnd.gif

because manual memory managment is the stuff.


Re: AA behaves differently in CTFE?

2015-11-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 07:54:24 UTC, Bastiaan Veelo 
wrote:

This results TRUE at compile time, but FALSE  at run time.


Sorry, that should be the reverse: TRUE at run time, FALSE at 
compile time. Compile time exhibits the unexpected behaviour.


Re: Dwarf Exception Handling question

2015-11-24 Thread deadalnix via Digitalmars-d
On Tuesday, 24 November 2015 at 07:52:13 UTC, Jacob Carlborg 
wrote:

On 2015-11-23 19:18, Walter Bright wrote:

My eevil plan is to get D exceptions working completely before 
trying to

support std::exception.


Is the idea to replace the existing exception handling 
mechanism for D code that don't interact with C++ as well?


Walter is moving DMD to use libunwind.



Re: let (x,y) = ...

2015-11-24 Thread visitor via Digitalmars-d-announce

On Tuesday, 24 November 2015 at 05:45:55 UTC, thedeemon wrote:
Well, I believe it's a matter of taste. By allowing different 
number of elements there you allow more errors to sink in 
without gaining anything at all. You lose the choice between 
strict and loose operators, erase the difference. It's not the 
"consistency" I would like to have.


ok, always curious about strategic choices, thanks :-)


Re: https everywhere!

2015-11-24 Thread Vladimir Panteleev via Digitalmars-d-announce

On Monday, 23 November 2015 at 21:18:58 UTC, Walter Bright wrote:

On 11/23/2015 1:11 PM, Adam D. Ruppe wrote:
On Monday, 23 November 2015 at 20:55:32 UTC, Walter Bright 
wrote:
I'm pleased to announce that Jan Knepper has gotten us some 
proper
certificates now, and dlang.org and digitalmars.com are now 
fully https!


So it isn't actually https everywhere. On a https 
page, the browsers by
default block any external asset which itself isn't https 
loaded.


The forum and TWID widgets are not https and now no longer 
load on the homepage :(


The widgets don't, but the forums worked when I tried it.


The forum widget isn't going to work until the forum is also 
HTTPS with a valid certificate.


Sorry, I'm not going to pay for my own SSL certificate :) You'll 
either have to share, or wait until Let's Encrypt goes live and I 
get around to setting it up.


Re: Scott Meyers wants to bring default zero-initialization to C++, mentions TDPL for precedent

2015-11-24 Thread Paolo Invernizzi via Digitalmars-d

On Tuesday, 24 November 2015 at 06:31:17 UTC, Joakim wrote:


I thought this anonymous comment about his pacemaker example 
was funny:


"I surely hope you are talking about the programmer device for 
pacemakers and not the actual pacemaker inside someone's body. 
I worked for Intermedics until we got bought by Guidant on 
Monday and shut down on Tuesday. We had a project at that time 
that was being written in C++ and it was likely the compiler 
did not even have a standard year attached. I was never 
comfortable with that project given the really ugly tendencies 
of both compilers and software engineers to do awful things in 
code. The ugly things in compilers was behind the push for 
standards in both C and C++!


The actual pacemaker likely has so little memory and power that 
it would be very strange to be written even in C (but more 
likely after 16 years of improved technology). It is more 
likely that the pacemaker code is still being written in 
assembler and the whole program is likely less that a few 
thousand lines.


I am confused by your assertions. It would be *very* unlikely 
once a device is released to production that the compiler would 
be changed to a newer version. Medical device software that is 
done properly must undergo massive amounts of verification and 
validation before it is released. Changing the compiler would 
require that the compiler itself be exhaustively validated 
against the old compiler and then the verification and 
validation of the device would be required to be repeated. That 
whole process would likely cost hundreds of thousands of 
dollars (perhaps even a million) in engineer/clinician time to 
verify that the device is still safe and effective.


It is very likely that all properly managed medical device 
companies continue to use the initially validated compiler for 
a *very* long time. As an example, when I worked in 
arthroscopy, we used the same C compiler for our 
micro-controllers for 6 years before we even entertained 
updating to the very latest. And arthroscopy is not nearly as 
mission critical as pacemakers.


If the company you did contract work for was not that diligent, 
I would sure like to know who it is so I can tell my Dad to 
decline to use that manufacturer's pacemakers."


Well, I've actually wrote some code that's running inside this 
[1], a device that I think it is at least as critical as a 
pacemaker...


Well, I do take the view, but the situation is not so dark as he 
describe.


[1] 
http://www.transenterix.com/company/corporate-news-events/video/


--
/Paolo



Re: https everywhere!

2015-11-24 Thread Vladimir Panteleev via Digitalmars-d-announce

On Monday, 23 November 2015 at 20:55:32 UTC, Walter Bright wrote:
I'm pleased to announce that Jan Knepper has gotten us some 
proper certificates now, and dlang.org and digitalmars.com are 
now fully https!


Forcing HTTPS has broken:

- The forum widget on the front page
- This week's "This Week in D" excerpt on the front page
- Runnable examples on the front page (more so than usual, now 
they are completely broken)


Effectively our front page is now a broken mess.

This change could've been done with some community communication, 
no? Then we could've gone into this prepared.




Re: https everywhere!

2015-11-24 Thread Andrea Fontana via Digitalmars-d-announce

On Monday, 23 November 2015 at 20:55:32 UTC, Walter Bright wrote:
I'm pleased to announce that Jan Knepper has gotten us some 
proper certificates now, and dlang.org and digitalmars.com are 
now fully https!


Chrome warns me saying that dlang connectio is encrypted with 
obsolete cryptography





Re: Something about Chinese Disorder Code

2015-11-24 Thread Rikki Cattermole via Digitalmars-d-learn

On 24/11/15 10:48 PM, magicdmer wrote:

I display chinese string like:

auto str = "你好,世界"
writeln(str)

and The display is garbled。

some windows api like MessageBoxA ,if string is chinese, it displays
disorder code too

i think i must use WideCharToMultiByte to convert it , is there any
other answer to solve this question simplely


*A windows API functions are for ASCII only.
You need the *W varients which are unicode.
For this you could use std.conv : to.

wstring text = "my str".to!wstring;

Or at least I'm pretty sure that will work for you.


Re: Something about Chinese Disorder Code

2015-11-24 Thread Andrea Fontana via Digitalmars-d-learn

On Tuesday, 24 November 2015 at 09:48:45 UTC, magicdmer wrote:

I display chinese string like:

auto str = "你好,世界"
writeln(str)

and The display is garbled。

some windows api like MessageBoxA ,if string is chinese, it 
displays disorder code too


i think i must use WideCharToMultiByte to convert it , is there 
any other answer to solve this question simplely


MessageBoxA <- A is ANSI.

You should try with MessageBoxW, for unicode I guess.


Is facebook moving away from D?

2015-11-24 Thread Bruce Adams via Digitalmars-d
I was just looking at the git hub pages for warp and flint and I 
notice they've recently been labelled as "no longer maintained"


https://github.com/facebookarchive/warp
https://github.com/facebookarchive/flint

Now I could imagine that warp could be considered complete as the 
C/C++ preprocessor doesn't change very often.


Flint could perhaps be replaced by something equilavent to the 
C++ core guidelines


https://github.com/isocpp/CppCoreGuidelines

But adding a comment that the projects are no longer maintained 
(presumably by a facebook employee) suggests an internal move 
away from D.
It also invites speculation about either the cause or the effect 
of Andrei's move to the D foundation.


Though this is of course jumping to conclusions based on very 
little information.


What do you guys think?


Something about Chinese Disorder Code

2015-11-24 Thread magicdmer via Digitalmars-d-learn

I display chinese string like:

auto str = "你好,世界"
writeln(str)

and The display is garbled。

some windows api like MessageBoxA ,if string is chinese, it 
displays disorder code too


i think i must use WideCharToMultiByte to convert it , is there 
any other answer to solve this question simplely


[Issue 15377] New: std.stdio: Use MSVCRT's _fseeki64 / _ftelli64 on Windows COFF

2015-11-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15377

  Issue ID: 15377
   Summary: std.stdio: Use MSVCRT's _fseeki64 / _ftelli64 on
Windows COFF
   Product: D
   Version: D2
  Hardware: All
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P5
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: thecybersha...@gmail.com

Currently it's not possible to seek to 64-bit offsets on Windows, even when
targeting the MS C runtime which has 64-bit seek/tell functions.

--


Re: AA behaves differently in CTFE?

2015-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn

On 11/24/15 2:59 AM, Bastiaan Veelo wrote:

On Tuesday, 24 November 2015 at 07:54:24 UTC, Bastiaan Veelo wrote:

This results TRUE at compile time, but FALSE  at run time.


Sorry, that should be the reverse: TRUE at run time, FALSE at compile
time. Compile time exhibits the unexpected behaviour.


If CTFE associative arrays perform differently, then that is a bug. I am 
not sure if this is the case, but you should file a bug anyway, someone 
can take a look at it.


If you can narrow it down to a minimal case where it breaks down, that 
would be helpful.


-Steve


Re: Is facebook moving away from D?

2015-11-24 Thread rsw0x via Digitalmars-d

On Tuesday, 24 November 2015 at 10:05:36 UTC, Bruce Adams wrote:

What do you guys think?


I don't think Facebook ever really moved towards D.


RAII is misleading

2015-11-24 Thread duff via Digitalmars-d
I've discovered this when working on a kind of "fat pointer" 
system.


The "RAII" term is misleading, it tends to let people think that 
the one who initializes a resource is its owner.


The reality is different. The real owner of a resource is the one 
who see it "as valid" for the first time.


[Issue 10750] Strict aliasing semantics

2015-11-24 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10750

weaselcat  changed:

   What|Removed |Added

 CC||r9shacklef...@gmail.com

--- Comment #6 from weaselcat  ---
Ping, did anything ever happen with this? I cannot find anything in D's spec
about aliasing/type punning and this seems to be the only relevant bug report.

--


Re: Something about Chinese Disorder Code

2015-11-24 Thread Meta via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 09:52:21 UTC, Rikki Cattermole 
wrote:

On 24/11/15 10:48 PM, magicdmer wrote:

I display chinese string like:

auto str = "你好,世界"
writeln(str)

and The display is garbled。

some windows api like MessageBoxA ,if string is chinese, it 
displays

disorder code too

i think i must use WideCharToMultiByte to convert it , is 
there any

other answer to solve this question simplely


*A windows API functions are for ASCII only.
You need the *W varients which are unicode.
For this you could use std.conv : to.

wstring text = "my str".to!wstring;

Or at least I'm pretty sure that will work for you.


I'm pretty sure you can just do:

wstring text = "my string";

Or

auto text = "my string"w;


SuperStruct v0.2.0

2015-11-24 Thread rcorre via Digitalmars-d-announce
For those that missed the first announcement 
(http://forum.dlang.org/thread/jiucsrcvkfdzwinqp...@forum.dlang.org?page=1), SuperStruct is a struct that acts like a class; basically, a value type that exposes a common interface from its 'subtypes'.


Code on github: https://github.com/rcorre/superstruct

Anyways, I was having enough fun with this slightly ridiculous 
idea to make a v0.20, so with no further ado, here's whats new:


Operators get passed through just like any other common members.

You can try to cast a SuperStruct to a subtype (throws on 
failure).


If members have a common signature but uncommon return types, the 
member _is_ forwarded and the return type is a SuperStruct of the 
possible return types (this means it has any behavior common to 
the return types). Thanks to Timon Gehr for the suggestion! 
(http://forum.dlang.org/thread/jiucsrcvkfdzwinqp...@forum.dlang.org?page=2#post-n09600:241gel:241:40digitalmars.com)


A SuperStruct can now satisfy a range interface (this required 
using mixed-in members instead of opDispatch).


Create a SuperStruct on the fly with pick or pickAmong (similar 
to std.range's choose/chooseAmong, but works for any types, not 
just ranges).


Example:
unittest {
  import std.range, std.algorithm, std.container;

  alias Container(T) = SuperStruct!(SList!T, Array!T);

  Container!int slist = SList!int();

  // We can call any members that are common among containers
  slist.insert([1,2,3,4]);
  assert(slist.front == 1);

  // opSlice is supported on all the subtypes, but each returns a 
different type

  // Container.opSlice will return a SuperStruct of these types
  auto slice = slist[]; // [1,2,3,4]
  assert(slice.front == 1);
  slice.popFront(); // [2,3,4]
  assert(slice.front == 2);

  // as slice is a SuperStruct of range types, it still works as 
a range

  slist.insert(slice); // [2,3,4] ~ [1,2,3,4]
  assert(slist[].equal([2,3,4,1,2,3,4]));
}



Re: Is facebook moving away from D?

2015-11-24 Thread mattcoder via Digitalmars-d

On Tuesday, 24 November 2015 at 14:54:38 UTC, rsw0x wrote:

On Tuesday, 24 November 2015 at 10:05:36 UTC, Bruce Adams wrote:

What do you guys think?


I don't think Facebook ever really moved towards D.


Yes I agree, it was more a toy thing or small snippets of code, 
like they do with Haskell and other languages.


Matheus.


Re: Is facebook moving away from D?

2015-11-24 Thread duff via Digitalmars-d

On Tuesday, 24 November 2015 at 10:05:36 UTC, Bruce Adams wrote:
I was just looking at the git hub pages for warp and flint and 
I notice they've recently been labelled as "no longer 
maintained"


https://github.com/facebookarchive/warp
https://github.com/facebookarchive/flint

Now I could imagine that warp could be considered complete as 
the C/C++ preprocessor doesn't change very often.


Flint could perhaps be replaced by something equilavent to the 
C++ core guidelines


https://github.com/isocpp/CppCoreGuidelines

But adding a comment that the projects are no longer maintained 
(presumably by a facebook employee) suggests an internal move 
away from D.
It also invites speculation about either the cause or the 
effect of Andrei's move to the D foundation.


Though this is of course jumping to conclusions based on very 
little information.


What do you guys think?


There are other D people in FB, like deadalnix 
(https://github.com/deadalnix).