Re: Programming in D book is about 88% translated

2013-06-29 Thread Ali Çehreli

On 06/28/2013 08:16 PM, Rob T wrote:


On Saturday, 29 June 2013 at 02:02:26 UTC, Ali Çehreli wrote:



  http://ddili.org/ders/d.en/index.html



Awesome! I continue to make use of your online book, so having these new
chapters in a language I can read is very much welcome news.

teşekkür


Güzel sözler için ben teşekkür ederim. :)

Ali



Re: Programming in D book is about 88% translated

2013-06-29 Thread Joshua Niehus

On Saturday, 29 June 2013 at 02:02:26 UTC, Ali Çehreli wrote:

I have continued with the translation of the book [snip]


excellent.  Keep up the good work Ali!



Re: Programming in D book is about 88% translated

2013-06-29 Thread Walter Bright

On 6/28/2013 7:35 PM, Ali Çehreli wrote:

Thinking that it is free enough, I had chosen this:

   http://creativecommons.org/licenses/by-nc-sa/3.0/us/

Just let me know if it is limiting in any way.


This is just awesome! Thank you, Ali!



Re: dlibgit updated to libgit2 v0.19.0

2013-06-29 Thread Walter Bright

On 6/28/2013 9:10 AM, Dicebot wrote:

On Friday, 28 June 2013 at 16:00:57 UTC, Andrej Mitrovic wrote:

Deimos is an overhead which provides no benefits. It was supposed to
be used to make discovery easy, but discovery can be done through a
wiki, or dlang.org, or an automated process (dub).


Deimos provides all the usual benefits of using github for projects.

I used to maintain a page with a list of links to D related projects. It 
regularly suffered from links going out of date, domain names being abandoned 
and then taken up by porn sites, projects simply disappearing, no consistent way 
for users to contribute to those projects, etc.



I suspect with time Deimos will be completely superseeded by dub or whatever
tool becomes standard package manager for D. However, it should not be simply
discarded because:

1) right now dub is not an official dlang.org project, but Deimos is

2) it is a certain brand name which gives promises about aggregated bindings -
all Deimos bindings are thin 1-to-1 reflections of their C origin.

In that sense, I would have expected Deimos become part of dub registry at some
point, preferrably as a separate package category. But they should not loose
identity of Deimos project.


https://github.com/D-Programming-Deimos


Re: Announcing bottom-up-build - a build system for C/C++/D

2013-06-29 Thread Graham St Jack
On Sat, 29 Jun 2013 00:59:15 +0200, John Colvin wrote:

 On Thursday, 27 June 2013 at 00:10:37 UTC, Graham St Jack wrote:
 Having side-by-side comparisons of D against bash scripts and C++
 modules had the effect of turning almost all the other team members
 into D advocates.
 
 Any chance we could know what team this is? (Sorry if this is common
 knowledge)

It is the development team at my previous workplace. I haven't asked them 
for permission, so I would rather not say who they are.

David Bryant (the previous poster) was a member of that team though, and 
he will be happy to provide details.


Re: Programming in D book is about 88% translated

2013-06-29 Thread Johannes Pfau
Am Fri, 28 Jun 2013 19:02:25 -0700
schrieb Ali Çehreli acehr...@yahoo.com:

 I have continued with the translation of the book. There are 82 of
 the 718 pages still to be translated. (However, I still need to write
 the UDA chapter.)
 
 Ali

Nice work!

BTW: The link to wiki4d on this page
http://ddili.org/ders/d.en/intro.html
could be updated to http://wiki.dlang.org/Editors and / or
http://wiki.dlang.org/IDEs



Re: DConf 2013 Closing Keynote: Quo Vadis by Andrei Alexandrescu

2013-06-29 Thread Walter Bright

I agree with your post, I just want to make a couple of minor corrections.

On 6/27/2013 4:58 AM, Leandro Lucarella wrote:

Do you really think C++ took off because there are commercial
implementations?


I got into the C++ fray in the 1987-88 time frame. At the time, there was a 
great debate between C++ and Objective-C, and they were running neck-and-neck. I 
was casting about looking for a way to get a competitive edge with my C 
compiler, and investigated.


Objective-C was put out by Stepstone. They wanted royalties from anyone who 
implemented a clone, and kept a tight fist over the licensing.


C++ only existed in its ATT cfront implementation. I wrote a letter to ATT's 
lawyers, asking if I could create a C++ clone, and they phoned me up and were 
very nice. They said sure, and I wouldn't have to pay any license or royalties.


So I went with C++. I don't really know if cfront was open source at the time or 
not, but I never looked at its source. I think cfront source came with a paid 
license for unix, but I'm not positive.


Anyhow, I wound up implementing the first native C++ compiler for the PC. 
Directly afterward, C++ took off like a rocket. Was it because of Zortech C++? I 
think there's strong evidence it was. A lot of programmers turned up their noses 
at the peasants programming on DOS, but that's where the action was in the 
1980's, and ZTC++ had no realistic competitors.


You could also see the results in Usenet. Postings about C++ and O-C were 
neck-and-neck until ZTC++ came out, and then things tilted heavily in C++'s 
favor, and O-C disappeared into oblivion (later to be resurrected by Steve Jobs, 
but that's another tale).


ZTC++ was so successful that Borland and Microsoft (according to rumor) 
abandoned their efforts at making a proprietary OOP C, and went with C++.


ZTC++ was closed source, as were Borland's Turbo C++ and Microsoft C++.


Do you think being a standardized language didn't help?


C++ wasn't standardized until 1998, 10 years later. The 90's were pretty much 
the heyday of C++.



Do you think the fact that there was a free implementation around that
it supported virtually any existing platform didn't help? Do you think
the fact was it was (almost) compatible with C (which was born freeish,
since back then software was freely shared between universities) didn't
help?


ZTC++ was cheap as dirt, and at the time people didn't mind paying for 
compilers. Those days are over, though. People have different expectations today.




No. A standard is something that was standardized by a standard
committee which, ideally, have some credits to do so. C++ is
standardized by ISO. I guess Walter and Andrei can give you more
details, since I think they both were involved in the standardization of
C++.


I've attended a few ISO C++ meetings, but I never became a voting member, and 
have had pretty much zero influence over the direction C++ took after the 1980's.


The bottom line was the open source movement was not a very significant force in 
the 1980's when C++ gained traction. Open source really exploded around 2000, 
along with the internet. I wonder if open source perhaps needed the internet in 
order to be viable.




Re: Programming in D book is about 88% translated

2013-06-29 Thread Paulo Pinto

Am 29.06.2013 04:35, schrieb Ali Çehreli:

On 06/28/2013 07:15 PM, MattCoder wrote:

  I'm really thinking about translate to portuguese

That sounds great! :) Somebody else had started a translation last year
to Brazilian Portuguese. I have just emailed the author to see how much
they have advanced.

  I was about to email you know about any legal terms etc.

Thinking that it is free enough, I had chosen this:

   http://creativecommons.org/licenses/by-nc-sa/3.0/us/

Just let me know if it is limiting in any way.

Ali



Maybe some help from proper Portuguese as well? :)

--
Paulo


Bugfix release 0.9.16

2013-06-29 Thread Sönke Ludwig
Am 22.06.2013 13:04, schrieb Sönke Ludwig:
 Two additional notes:
 
  - There is a known bug that causes multiple DUB invocations to be
required until all indirect dependencies are installed (watch out
for a There are still some actions to perform: message). The
current git master fixes that.
 

The fix is now contained in the latest release.


Re: Announcing bottom-up-build - a build system for C/C++/D

2013-06-29 Thread Clive Hobson

On Saturday, 29 June 2013 at 07:54:30 UTC, Graham St Jack wrote:

On Sat, 29 Jun 2013 00:59:15 +0200, John Colvin wrote:

On Thursday, 27 June 2013 at 00:10:37 UTC, Graham St Jack 
wrote:
Having side-by-side comparisons of D against bash scripts and 
C++
modules had the effect of turning almost all the other team 
members

into D advocates.


Any chance we could know what team this is? (Sorry if this is 
common

knowledge)


It is the development team at my previous workplace. I haven't 
asked them

for permission, so I would rather not say who they are.

David Bryant (the previous poster) was a member of that team 
though, and

he will be happy to provide details.


I am still part of that team.  We still use the early predecessor 
of bub to build several projects from a large C++ codebase, but I 
am looking forward to switching to bub at the end of the current 
project.


For example, one project uses ~2000 cc/h files containing 
~390,000 lines (before any code generation).  After a successfull 
build, running the build again takes about 2s to figure out that 
everything is up to date.  Knowing both build tools, I expect 
that time to remain about the same after the switch to bub.


Yes, I have become a D advocate.  Our production code is still 
mostly C++, but a large part of our system-level testing is now 
written in D (~15,000 lines).  Bash scripts are becoming rarer 
too. :)


Re: Programming in D book is about 88% translated

2013-06-29 Thread MattCodr

On Saturday, 29 June 2013 at 02:35:27 UTC, Ali Çehreli wrote:
That sounds great! :) Somebody else had started a translation 
last year to Brazilian Portuguese. I have just emailed the 
author to see how much they have advanced.


Please let me know later how the translation is going, if I can 
continue his work somehow or I'll start my own translation from 
scratch.




Thinking that it is free enough, I had chosen this:

  http://creativecommons.org/licenses/by-nc-sa/3.0/us/

Just let me know if it is limiting in any way.


2 times more awesome. :]

Bye,

Matheus.


Re: DConf 2013 Closing Keynote: Quo Vadis by Andrei Alexandrescu

2013-06-29 Thread Joseph Rushton Wakeling

On Saturday, 29 June 2013 at 08:37:48 UTC, Walter Bright wrote:
The bottom line was the open source movement was not a very 
significant force in the 1980's when C++ gained traction. Open 
source really exploded around 2000, along with the internet. I 
wonder if open source perhaps needed the internet in order to 
be viable.


That's a very good point.  It's before my time really, but if I 
understand the history right, the main way to get hold of copies 
of stuff like GCC in the early days was to pay for a set of disks 
with it on -- and there was no infrastructure for easily sharing 
changes.  So neither the free-as-in-beer or free-as-in-freedom 
advantages were as readily apparent or effective as they are 
today.


Re: DConf 2013 Closing Keynote: Quo Vadis by Andrei Alexandrescu

2013-06-29 Thread Leandro Lucarella
Walter Bright, el 29 de June a las 01:37 me escribiste:
 The bottom line was the open source movement was not a very
 significant force in the 1980's when C++ gained traction. Open
 source really exploded around 2000, along with the internet. I
 wonder if open source perhaps needed the internet in order to be
 viable.

Yes, I think that's the whole point, without Internet open source was
extremely niche, without resources to distribute it, it was almost
impossible to take off, and almost impossible to collaborate, which is
the big different open source have vs traditional commercial software.

Even when extremely interesting, I think the ZTC++ history before open
source existed or was really viable (the free software movement started
in 1983, the FSF was founded in 1985 and the open source definition was
made in 1998) is irrelevant in terms to analyze if right now it would be
valuable to make the reference compiler partly closed.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
EL PRIMER MONITO DEL MILENIO...
-- Crónica TV


Re: Programming in D book is about 88% translated

2013-06-29 Thread Geancarlo Rocha

On Saturday, 29 June 2013 at 08:47:14 UTC, Paulo Pinto wrote:


Maybe some help from proper Portuguese as well? :)

--
Paulo


Ei gajo, did you mean weird portuguese? :P


Re: DConf 2013 Closing Keynote: Quo Vadis by Andrei Alexandrescu

2013-06-29 Thread CJS

On Saturday, 29 June 2013 at 08:37:48 UTC, Walter Bright wrote:
I agree with your post, I just want to make a couple of minor 
corrections.


On 6/27/2013 4:58 AM, Leandro Lucarella wrote:

Do you really think C++ took off because there are commercial
implementations?


I got into the C++ fray in the 1987-88 time frame. At the time, 
there was a great debate between C++ and Objective-C, and they 
were running neck-and-neck. I was casting about looking for a 
way to get a competitive edge with my C compiler, and 
investigated.


Objective-C was put out by Stepstone. They wanted royalties 
from anyone who implemented a clone, and kept a tight fist over 
the licensing.


C++ only existed in its ATT cfront implementation. I wrote a 
letter to ATT's lawyers, asking if I could create a C++ clone, 
and they phoned me up and were very nice. They said sure, and I 
wouldn't have to pay any license or royalties.


So I went with C++. I don't really know if cfront was open 
source at the time or not, but I never looked at its source. I 
think cfront source came with a paid license for unix, but I'm 
not positive.


Anyhow, I wound up implementing the first native C++ compiler 
for the PC. Directly afterward, C++ took off like a rocket. Was 
it because of Zortech C++? I think there's strong evidence it 
was. A lot of programmers turned up their noses at the peasants 
programming on DOS, but that's where the action was in the 
1980's, and ZTC++ had no realistic competitors.


You could also see the results in Usenet. Postings about C++ 
and O-C were neck-and-neck until ZTC++ came out, and then 
things tilted heavily in C++'s favor, and O-C disappeared into 
oblivion (later to be resurrected by Steve Jobs, but that's 
another tale).


ZTC++ was so successful that Borland and Microsoft (according 
to rumor) abandoned their efforts at making a proprietary OOP 
C, and went with C++.


ZTC++ was closed source, as were Borland's Turbo C++ and 
Microsoft C++.



Do you think being a standardized language didn't help?


C++ wasn't standardized until 1998, 10 years later. The 90's 
were pretty much the heyday of C++.


Do you think the fact that there was a free implementation 
around that
it supported virtually any existing platform didn't help? Do 
you think
the fact was it was (almost) compatible with C (which was born 
freeish,
since back then software was freely shared between 
universities) didn't

help?


ZTC++ was cheap as dirt, and at the time people didn't mind 
paying for compilers. Those days are over, though. People have 
different expectations today.




No. A standard is something that was standardized by a standard
committee which, ideally, have some credits to do so. C++ is
standardized by ISO. I guess Walter and Andrei can give you 
more
details, since I think they both were involved in the 
standardization of

C++.


I've attended a few ISO C++ meetings, but I never became a 
voting member, and have had pretty much zero influence over the 
direction C++ took after the 1980's.


The bottom line was the open source movement was not a very 
significant force in the 1980's when C++ gained traction. Open 
source really exploded around 2000, along with the internet. I 
wonder if open source perhaps needed the internet in order to 
be viable.


Wow. That's interesting reading. Thanks for the history lesson!



Re: DConf 2013 Closing Keynote: Quo Vadis by Andrei Alexandrescu

2013-06-29 Thread Walter Bright

On 6/29/2013 5:08 AM, Joseph Rushton Wakeling wrote:

On Saturday, 29 June 2013 at 08:37:48 UTC, Walter Bright wrote:

The bottom line was the open source movement was not a very significant force
in the 1980's when C++ gained traction. Open source really exploded around
2000, along with the internet. I wonder if open source perhaps needed the
internet in order to be viable.


That's a very good point.  It's before my time really, but if I understand the
history right, the main way to get hold of copies of stuff like GCC in the early
days was to pay for a set of disks with it on -- and there was no infrastructure
for easily sharing changes.  So neither the free-as-in-beer or
free-as-in-freedom advantages were as readily apparent or effective as they are
today.


True, distribution was mainly by physical mail. There was some via BBS's and 
Usenet, but these were severely limited by bandwidth.


I'd receive bug reports by fax, paper listings, and mailed floppies.


Re: DConf 2013 Closing Keynote: Quo Vadis by Andrei Alexandrescu

2013-06-29 Thread Walter Bright

On 6/29/2013 7:56 PM, CJS wrote:

Wow. That's interesting reading. Thanks for the history lesson!


There are other versions of this history, none of which mention the role ZTC++ 
played in C++ attaining critical mass, so I like to repeat my version now and 
then :-)




Re: DMD under 64-bit Windows 7 HOWTO

2013-06-29 Thread Jonathan Dunlap
Thanks! Adding those libs to the path worked. However, now I get 
the below error about a missing entry point.


LINK : fatal error LNK1561: entry point must be defined

--- errorlevel 1561

Exit code 1561

Build complete -- 1 error, 0 warnings



Re: DMD under 64-bit Windows 7 HOWTO

2013-06-29 Thread Jonathan Dunlap
Never mind, I fixed that linker error (had a minor issue with the 
main D entry point). I'm now building x64!


Re: DLang Spec rewrite (?)

2013-06-29 Thread Borden

On Monday, 27 May 2013 at 02:11:00 UTC, Andrei Alexandrescu wrote:
I think it would be great. In particular, an ebook format would 
be good.


You may want to wait until 
https://github.com/D-Programming-Language/dlang.org/pull/271 is 
in. It systematizes macros a lot and it may offer answers to 
many of your questions.


Andrei


I would still like to work on compiling the DLangSpec into HTML5, 
but I've noticed that pull request 271 hasn't been touched in 
over 4 months. Further, I sent in a pull request to move the 
DLangSpec source files into their own folders and haven't gotten 
so much as a 'worst pull request ever' in response.


I fully appreciate that people are very busy - including me - so 
I want to know if there's anything I can do to help things along. 
At least with respect to pull request 271, is there anything that 
I can do to help get it merged into master so I can get working 
on the HTML5 DDoc?


What about to add costume projects to D autotester?

2013-06-29 Thread Denis Shelomovskij
As dmd is actively developed approximately every 2 weeks (since May) I 
have to find a cause for a regression which takes few hours and is a bit 
annoying as it looks like a needless job.


What about to introduce some benefit criteria (regressions discovered by 
the project e.g.) relying on which a project is considered to be useful 
and can is added to autotester? This will help dmd developers to see 
bugs in their pulls immediately and will save D users time.


--
Денис В. Шеломовский
Denis V. Shelomovskij


Re: stack trace on linux amd64 ?

2013-06-29 Thread Iain Buclaw
On 29 June 2013 06:42, deadalnix deadal...@gmail.com wrote:
 On Friday, 28 June 2013 at 20:00:52 UTC, Johannes Pfau wrote:

 Am Fri, 28 Jun 2013 11:12:25 -0700
 schrieb Sean Kelly s...@invisibleduck.org:

 If I remember correctly, the issue there was that the runtime would
 need to open the executable or map file and parse it, and it seemed a
 lot more straightforward to simply make an API call.  But if you're
 inclined to submit a pull request...


 In the meantime the GCC guys have developed libbacktrace [1] for GCC 4.8
 which does exactly that: map the executable, parse it and use the dwarf
 debug info and all that without malloc. We're currently integrating
 this into GDC [2].

 Unfortunately it's not as easy to integrate into dmd: It uses libgcc,
 the libbacktrace library is not installed in the target system (it's
 only available at gcc build time, we then just link it statically into
 druntime) and you need a more advanced build system to check for
 BACKTRACE_SUPPORTED in C headers.

 [1] https://github.com/mirrors/gcc/tree/master/libbacktrace
 [2] https://github.com/D-Programming-GDC/GDC/pull/65


 https://github.com/bombela/backward-cpp

 That may be relevant.

If DMD wants to go down the route of pulling in third party dependencies.  :o)


--
Iain Buclaw

*(p  e ? p++ : p) = (c  0x0f) + '0';


Re: Problem with Variant

2013-06-29 Thread develop32
On Saturday, 29 June 2013 at 00:14:19 UTC, Andrei Alexandrescu 
wrote:
Could you please paste your note into a bug report? In a 
perfect world you may want to also submit a pull request!


Filled a bug
http://d.puremagic.com/issues/show_bug.cgi?id=10500

And I'll try to make world a better place too...


Re: DLang Spec rewrite (?)

2013-06-29 Thread Daniel Murphy
Borden 2...@bordenrhodes.com wrote in message 
news:qglzffgfawrzjguvt...@forum.dlang.org...
 I would still like to work on compiling the DLangSpec into HTML5, but I've 
 noticed that pull request 271 hasn't been touched in over 4 months. 
 Further, I sent in a pull request to move the DLangSpec source files into 
 their own folders and haven't gotten so much as a 'worst pull request 
 ever' in response.

 I fully appreciate that people are very busy - including me - so I want to 
 know if there's anything I can do to help things along. At least with 
 respect to pull request 271, is there anything that I can do to help get 
 it merged into master so I can get working on the HTML5 DDoc?

To be honest, you just have to keep bugging people.  I mostly review 
compiler pulls, and I am much much more likely to review something that 
shows up in my inbox than something that sits patiently in the list.  If you 
make enough noise somebody will eventually reply. 




DIP43 - D/Objective-C

2013-06-29 Thread Jacob Carlborg
I have created a DIP for making D ABI compatible with Objective-C. This 
idea has already been announced, what I've done now is created a proper 
DIP. The DIP is basically Michel Fortin's original designed document 
properly formatted and put next to the other DIP's.


DIP link: http://wiki.dlang.org/DIP43
Original announcement: 
http://forum.dlang.org/thread/kq7li9$2j9v$1...@digitalmars.com


--
/Jacob Carlborg


Compiler could elide many more postblit constructor calls

2013-06-29 Thread TommiT
Disclaimer: The discovery I'm about to describe here seems so 
obvious that I'm inclined to think that I've made some mistake.


The sole purpose of postblit constructors is to provide value 
semantics to structs which have mutable indirection (variables 
which have only immutable indirection have value semantics 
implicitly). Variables that are const/immutable can't have 
mutable indirection. Therefore, when making a copy from a 
const/immutable variable to a const/immutable variable, there's 
no need to call the postblit constructor.


Example:


struct S
{
int[] values;

this(this)
{
values = values.dup;
}
}

void foo(const S) { }

void main()
{
const S s;
foo(s); // No need to call postblit
}


Re: SIMD on Windows

2013-06-29 Thread Jonathan Dunlap
Alright, I'm now officially building for Windows x64 (amd64). 
I've created this early benchmark http://dpaste.dzfl.pl/eae0233e 
to explore SIMD performance. As you can see below, on my machine 
there is almost zero difference. Am I missing something?


//===SIMD===
0 1.#INF 5 1.#INF -- vector result
hnsecs: 16 -- duration time
0 1.#INF 5 1.#INF
hnsecs: 90005
0 1.#INF 5 1.#INF
hnsecs: 90006
//===SCALAR===
0 1.#INF 5 1.#INF
hnsecs: 90005
0 1.#INF 5 1.#INF
hnsecs: 15
0 1.#INF 5 1.#INF
hnsecs: 16


Re: DIP42 - Add enum E(T) = expression; eponymous template support

2013-06-29 Thread Denis Shelomovskij

26.06.2013 20:35, Andrej Mitrovic пишет:

On 6/26/13, Denis Shelomovskij verylonglogin@gmail.com wrote:

which will look better this way:
---
static if (...)
  enum template = ...;
else static if (...)
  enum template = ...;
else ...
---


Yeah I agree, this is more important than DIP42's shortened syntax for
simple templates. It's the more complicated templates that are the
problem.



It's rather strange that enhancement 7364 isn't implemented yet (and 
even not discussed) as it's an easy-to-implement change with big pros 
and no cons.


--
Денис В. Шеломовский
Denis V. Shelomovskij


Add static code analyzing to dmd

2013-06-29 Thread Denis Shelomovskij
IMHO it's an important enhancement as I see no reasons for the compiler 
to not inform about may-be-an-error situations if the user asks as it 
will save a lot people time.


Original issue:
http://d.puremagic.com/issues/show_bug.cgi?id=9811

Description:
There are things which may or may not indicate and error. Current 
compiler behavior is: I'm a compiler, I can't even give a warning if 
there is a chance for false positive, there are only warnings and 
errors. But it looks inconsistent with the fact a compiler tries to 
help the developer by doing code coverage, documentation etc. Static 
code analyzing is an essential task a compiler could also do and do 
good. Also, IMHO, compilers should do static analyzing instead of 
external tools.


So I propose to add -diagnostic flag to the compiler for things Walter 
is a bit uncomfortable in declaring it as always wrong and also for 
things that are definitely not always wrong. There also could be 
different levels of such analyzing and ability to treat diagnostic 
warnings as errors.



See also:
[1] Interview of Walter Bright by Andrey Karpov
http://www.viva64.com/en/b/0182/
[2] NG thread about the interview
http://forum.dlang.org/thread/nnzzbsafuwwzuotvl...@forum.dlang.org

--
Денис В. Шеломовский
Denis V. Shelomovskij


Re: DIP43 - D/Objective-C

2013-06-29 Thread Michel Fortin

On 2013-06-29 12:58:45 +, Jacob Carlborg d...@me.com said:

I have created a DIP for making D ABI compatible with Objective-C. This 
idea has already been announced, what I've done now is created a proper 
DIP. The DIP is basically Michel Fortin's original designed document 
properly formatted and put next to the other DIP's.


DIP link: http://wiki.dlang.org/DIP43
Original announcement: 
http://forum.dlang.org/thread/kq7li9$2j9v$1...@digitalmars.com


There's no mention of the type of the class returned by NSObject.class. 
That type is NSObject.Class. Each Objective-C class has its own Class 
inner metaclass. Static methods are implemented behind the scene as 
members of this metaclass. This is already implemented.


As for interfaces, they should have a meta-interface too implemented 
by the metaclasses of those classes implementing the interface. I don't 
think this has been done yet.


--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca/



Re: DIP43 - D/Objective-C

2013-06-29 Thread David Gileadi

On 6/29/13 5:58 AM, Jacob Carlborg wrote:

I have created a DIP for making D ABI compatible with Objective-C. This
idea has already been announced, what I've done now is created a proper
DIP. The DIP is basically Michel Fortin's original designed document
properly formatted and put next to the other DIP's.

DIP link: http://wiki.dlang.org/DIP43
Original announcement:
http://forum.dlang.org/thread/kq7li9$2j9v$1...@digitalmars.com


It's probably an obvious observation, but why not use an annotation like:

@selector(insertItemWithObjectValue:atIndex:)
void insertItem(ObjcObject object, NSInteger value);

instead of the DIP's proposal of:

void insertItem(ObjcObject object, NSInteger value) 
[insertItemWithObjectValue:atIndex:];


Regarding warnings

2013-06-29 Thread bearophile
I suggest to remove the -w switch from the list of dmd/ldc2 
switches, and later to remove that functionality too. It's better 
to keep only the informational warnings.


I keep seeing people in D.learn that miss warnings because they 
don't active them, so I suggest to activate informational 
warnings on default.


And then I suggest to add a switch to disable the warnings, for 
the rare situations where you don't want them.


Bye,
bearophile


Re: SIMD on Windows

2013-06-29 Thread jerro

On Saturday, 29 June 2013 at 14:39:44 UTC, Jonathan Dunlap wrote:
Alright, I'm now officially building for Windows x64 (amd64). 
I've created this early benchmark 
http://dpaste.dzfl.pl/eae0233e to explore SIMD performance. As 
you can see below, on my machine there is almost zero 
difference. Am I missing something?


//===SIMD===
0 1.#INF 5 1.#INF -- vector result
hnsecs: 16 -- duration time
0 1.#INF 5 1.#INF
hnsecs: 90005
0 1.#INF 5 1.#INF
hnsecs: 90006
//===SCALAR===
0 1.#INF 5 1.#INF
hnsecs: 90005
0 1.#INF 5 1.#INF
hnsecs: 15
0 1.#INF 5 1.#INF
hnsecs: 16


First of all, calcSIMD and calcScalar are virtual functions so 
they can't be inlined, which prevents any further optimization. 
It also seems that the fact that g, s, i and d are class fields 
and that g is a static array makes DMD load them from memory and 
store them back on every iteration even when calcSIMD and 
calcScalar are inlined.


But even if I make the class final and build it with gdc -O3 
-finline-functions -frelease -march=native (in which case GDC 
generates assembly that looks optimal to me), the scalar version 
is still a bit faster than the vector version. The main reason 
for that is that even with scalar code, the compiler can do 
multiple operations in parallel. So on Sandy Bridge CPUs, for 
example, floating point multiplication takes 5 cycles to 
complete, but the processor can do one multiplication per cycle. 
So my guess is that the first four multiplications and the second 
four multiplications in calcScalar are done in parallel.


That would explain the scalar code being equaly fast, but not 
faster than vector code. The reason it's faster is that gdc 
replaces multiplication by 2 with addition and omits 
multiplication by 1.


Re: DIP43 - D/Objective-C

2013-06-29 Thread Michel Fortin

On 2013-06-29 15:51:11 +, David Gileadi gilea...@nspmgmail.com said:


It's probably an obvious observation, but why not use an annotation like:

@selector(insertItemWithObjectValue:atIndex:)
void insertItem(ObjcObject object, NSInteger value);

instead of the DIP's proposal of:

void insertItem(ObjcObject object, NSInteger value) 
[insertItemWithObjectValue:atIndex:];


This document and its experimental implementation predate UDAs. While I 
do like this syntax, I agree it'd make more sense to use an attribute 
now.


--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca/



Re: SIMD on Windows

2013-06-29 Thread Kiith-Sa
See Manu's talk and google how to use it. If you don't know what 
you're doing you are unlikely to see performance improvements.


I'm not even sure if you're benchmarking SIMD performance or 
function call overhead there.


SCons D tooling patch

2013-06-29 Thread H. S. Teoh
Hi Russel,

After the latest hg pull from your SCons D tooling, bootstrap.py was
broken, and aborts with an error upon startup. Since I've been using
bootstrap.py to do all my D builds, this was a rather major
inconvenience.

But today, I managed to figure out the problem, so I've attached the
diff that fixed it for me.

Hope this helps.


T

-- 
Give a man a fish, and he eats once.
Teach a man to fish, and he will sit forever.
diff -r f57afb0b72f5 bootstrap.py
--- a/bootstrap.py  Wed May 15 12:50:05 2013 +0100
+++ b/bootstrap.py  Sat Jun 29 10:13:45 2013 -0700
@@ -197,7 +197,7 @@
 
 
 scons_py = os.path.join('src', 'script', 'scons.py')
-src_engine = os.path.join('src', 'engine')
+src_engine = os.path.join(script_dir, 'src', 'engine')
 MANIFEST_in = find(os.path.join(src_engine, 'MANIFEST.in'))
 
 files = [ scons_py ] + [os.path.join(src_engine, x)


Octal enums don't work anymore in git HEAD

2013-06-29 Thread H. S. Teoh
http://d.puremagic.com/issues/show_bug.cgi?id=10503

:-(


T

-- 
If Java had true garbage collection, most programs would delete themselves upon 
execution. -- Robert Sewell


Re: Compiler could elide many more postblit constructor calls

2013-06-29 Thread TommiT

On Saturday, 29 June 2013 at 13:47:36 UTC, TommiT wrote:

[..]

Example:


struct S
{
int[] values;

this(this)
{
values = values.dup;
}
}

void foo(const S) { }

void main()
{
const S s;
foo(s); // No need to call postblit
}


One important related detail:
If the compiler decides to elide the postblit of S on the call to 
foo(s), then the destructor of S (if S happened to have one) 
should not be called when the call to foo exits and the argument 
passed to foo goes out of scope. The logic behind this is that 
when we omit the postblit on the argument that's passed by value, 
it is as-if we had passed the argument by const reference (except 
that the argument is considered local to foo, i.e. not returnable 
by reference and what not).


Re: SIMD on Windows

2013-06-29 Thread Jonathan Dunlap
I've updated the project with your suggestions at 
http://dpaste.dzfl.pl/fce2d93b but still get the same 
performance. Vectors defined in the benchmark function body, no 
function calling overhead, etc. See some of my comments below btw:


First of all, calcSIMD and calcScalar are virtual functions so 
they can't be inlined, which prevents any further optimization.


For the dlang docs: Member functions which are private or package 
are never virtual, and hence cannot be overridden.


So my guess is that the first four multiplications and the 
second four multiplications in calcScalar are done in parallel. 
... The reason it's faster is that gdc replaces multiplication 
by 2 with addition and omits multiplication by 1.


I've changed the multiplies of 2 and 1 to 2.1 and 1.01 
respectively. Still no performance difference between the two for 
me.


Re: SIMD on Windows

2013-06-29 Thread Iain Buclaw
On 29 June 2013 18:57, Jonathan Dunlap jad...@gmail.com wrote:
 I've updated the project with your suggestions at
 http://dpaste.dzfl.pl/fce2d93b but still get the same performance. Vectors
 defined in the benchmark function body, no function calling overhead, etc.
 See some of my comments below btw:


 First of all, calcSIMD and calcScalar are virtual functions so they can't
 be inlined, which prevents any further optimization.


 For the dlang docs: Member functions which are private or package are never
 virtual, and hence cannot be overridden.

 So my guess is that the first four multiplications and the second four
 multiplications in calcScalar are done in parallel. ... The reason it's
 faster is that gdc replaces multiplication by 2 with addition and omits
 multiplication by 1.


 I've changed the multiplies of 2 and 1 to 2.1 and 1.01 respectively. Still
 no performance difference between the two for me.


s/class/struct/


--
Iain Buclaw

*(p  e ? p++ : p) = (c  0x0f) + '0';


Re: SIMD on Windows

2013-06-29 Thread jerro

On Saturday, 29 June 2013 at 17:57:20 UTC, Jonathan Dunlap wrote:
I've updated the project with your suggestions at 
http://dpaste.dzfl.pl/fce2d93b but still get the same 
performance. Vectors defined in the benchmark function body, no 
function calling overhead, etc. See some of my comments below 
btw:


First of all, calcSIMD and calcScalar are virtual functions so 
they can't be inlined, which prevents any further optimization.


For the dlang docs: Member functions which are private or 
package are never virtual, and hence cannot be overridden.


So my guess is that the first four multiplications and the 
second four multiplications in calcScalar are done in 
parallel. ... The reason it's faster is that gdc replaces 
multiplication by 2 with addition and omits multiplication by 
1.


I've changed the multiplies of 2 and 1 to 2.1 and 1.01 
respectively. Still no performance difference between the two 
for me.


The multiples 2 and 1 were the reason why the scalar code 
performs a little bit better than SIMD code when compiled with 
GDC. The main reason why scalar code isn't much slower than SIMD 
code is instruction level parallelism. Because the first four 
operation in calcScalar are independent (none of them depends on 
the result of any of the other three) modern x86-64 processors 
can execute them in parallel. Because of that, the speed of your 
program is limited by instruction latency and not throughput. 
That's why it doesn't really make a difference that the scalar 
version does four times as many operations.


You can also make advantage of instruction level parallelism when 
using SIMD. For example, I get about the same number of 
iterations per second for the following two functions (when using 
GDC):


import gcc.attribute;

@attribute(forceinline) void calcSIMD1() {

s0 = s0 * i0;

s0 = s0 * d0;

s1 = s1 * i1;

s1 = s1 * d1;

s2 = s2 * i2;

s2 = s2 * d2;

s3 = s3 * i3;

s3 = s3 * d3;

}

@attribute(forceinline) void calcSIMD2() {

s0 = s0 * i0;

s0 = s0 * d0;
}

By the way, if performance is very important to you, you should 
try GDC (or LDC, but I don't think LDC is currently fully usable 
on Windows).


Re: SIMD on Windows

2013-06-29 Thread jerro
For the dlang docs: Member functions which are private or 
package are never virtual, and hence cannot be overridden.


The call to calcScalar compiles to this:

movrax,QWORD PTR [r12]
rex.W call QWORD PTR [rax+0x40]

so I think the implementation doesn't conform to the spec in this 
case.


Re: SIMD on Windows

2013-06-29 Thread Jonathan Dunlap
modern x86-64 processors can execute them in parallel. Because 
of that, the speed of your program is limited by instruction 
latency and not throughput.


It seems like auto-vectorization to SIMD code may be an ideal 
strategy (e.g. Java) since it seems that the conditions to get 
any performance improvement have to be very particular and 
situational... which is something the compiler may be best suited 
to handle. Thoughts?


Re: DIP42 - Add enum E(T) = expression; eponymous template support

2013-06-29 Thread TommiT
I've been wondering if we could have parameterized named enumS. 
The syntax for it would look somewhat similar:


enum Fruit(T) : T { apple, banana = -42 }

void main()
{
auto shortFruit = Fruit!(short).apple;
auto longFruit  = Fruit!(long).banana;

longFruit = shortFruit; // OK: implicit conversion allowed
shortFruit = longFruit; // OK: ... even a truncating one

Fruit!uint uintFruit; // Error: -42 is out of range of uint
Fruit!string stringFruit; // Error: enums need initializers
}


Re: Regarding warnings

2013-06-29 Thread w0rp

On Saturday, 29 June 2013 at 16:07:57 UTC, bearophile wrote:
I suggest to remove the -w switch from the list of dmd/ldc2 
switches, and later to remove that functionality too. It's 
better to keep only the informational warnings.


I keep seeing people in D.learn that miss warnings because they 
don't active them, so I suggest to activate informational 
warnings on default.


And then I suggest to add a switch to disable the warnings, for 
the rare situations where you don't want them.


Bye,
bearophile


This might increase knowledge like you say. Plus, you'd have 
warnings about stuff like implicit switch case fall-through as 
the default. I think this idea sounds okay.


Re: Automatic typing

2013-06-29 Thread Ary Borenszweig

On 6/27/13 9:34 PM, JS wrote:

Would it be possible for a language(specifically d) to have the ability
to automatically type a variable by looking at its use cases without
adding too much complexity? It seems to me that most compilers already
can infer type mismatchs which would allow them to handle stuff like:

main()
{
auto x;
auto y;
x = 3;   // x is an int, same as auto x = 3;
y = f(); // y is the same type as what f() returns
x = 3.9; // x is really a float, no mismatch with previous type(int)
}

in this case x and y's type is inferred from future use. The compiler
essentially just lazily infers the variable type. Obviously ambiguity
will generate an error.


What you are asking is essentially what Crystal does for all variables 
(and types):


https://github.com/manastech/crystal/wiki/Introduction#type-inference

Your example would be written like this:

x = 3
y = f()
x = 3.9

But since Crystal transforms your code to SSA 
(http://en.wikipedia.org/wiki/Static_single_assignment_form) you 
actually have *two* x variables in your code. The first one is of type 
Int32, the second of type Float64. The above solves the problem 
mentioned by Steven Schveighoffer, where you didn't know what overloaded 
version you was calling:


x = 3
f(x) # always calls f(Int32), because at run-time
 # x will always be an Int32 at this point
x = 3.9

But to have this in a language you need some things:

1. Don't have a different syntax for declaring and updating variables
2. Transform your code to SSA
(maybe more?)

So this is not possible in D right now, and I don't think it will ever 
be because it requires a huge change to the whole language.


Re: Regarding warnings

2013-06-29 Thread bearophile

w0rp:

This might increase knowledge like you say. Plus, you'd have 
warnings about stuff like implicit switch case fall-through as 
the default. I think this idea sounds okay.


I think a strong, silent type of D compiler is not the best.
Maybe Walter can offer an opinion, even negative :-)

Bye,
bearophile


Re: DLang Spec rewrite (?)

2013-06-29 Thread Borden

On Saturday, 29 June 2013 at 11:33:16 UTC, Daniel Murphy wrote:
To be honest, you just have to keep bugging people.  I mostly 
review
compiler pulls, and I am much much more likely to review 
something that
shows up in my inbox than something that sits patiently in the 
list.  If you

make enough noise somebody will eventually reply.


Sigh, I know. I just don't want to get on anybody's bad side. 
Maybe I can do that just by keeping this bumped...


Re: auto type for defaulted arguments? [Repost]

2013-06-29 Thread bearophile

In the meantime I have opened an enhancement request:
http://d.puremagic.com/issues/show_bug.cgi?id=10491

Henning Pohl has written a patch:
https://github.com/D-Programming-Language/dmd/pull/2270

And Kenji has written some comments in Bugzilla, explaining why 
he doesn't like this ER.


I usually trust Kenji judgement. So let's close down this idea?

Bye,
bearophile


Re: SIMD on Windows

2013-06-29 Thread jerro
It seems like auto-vectorization to SIMD code may be an ideal 
strategy (e.g. Java) since it seems that the conditions to get 
any performance improvement have to be very particular and 
situational... which is something the compiler may be best 
suited to handle. Thoughts?


The things is that using SIMD efficiently often requires you to 
organize your data and your algorithm differently, which is 
something that the compiler can't do for you. Another problem is 
that the compiler doesn't know how often different code paths 
will be executed so it can't know how to use SIMD in the best way 
(that could be solved with profile guided optimization, though). 
Alignment restrictions are another thing that can cause problems. 
For those reasons auto-vectorization only works in the simplest 
of cases. But if you want auto-vectorization, GDC and LDC already 
do it.


I recommend watching Manu's talk (as Kiith-Sa has already 
suggested):


http://youtube.com/watch?v=q_39RnxtkgM


Re: Regarding warnings

2013-06-29 Thread Jonathan M Davis
On Saturday, June 29, 2013 18:07:55 bearophile wrote:
 I suggest to remove the -w switch from the list of dmd/ldc2
 switches, and later to remove that functionality too. It's better
 to keep only the informational warnings.
 
 I keep seeing people in D.learn that miss warnings because they
 don't active them, so I suggest to activate informational
 warnings on default.
 
 And then I suggest to add a switch to disable the warnings, for
 the rare situations where you don't want them.

http://d.puremagic.com/issues/show_bug.cgi?id=10147

- Jonathan M Davis


Re: SIMD on Windows

2013-06-29 Thread Jonathan Dunlap
I did watch Manu's a few days ago which inspired me to start this 
project. With the updates in http://dpaste.dzfl.pl/fce2d93b, I'm 
still a bit clueless as to why there is almost zero performance 
difference... considering that is seems like an ideal setup to 
benefit from SIMD. I feel that if I can't see gains here: that I 
shouldn't bother using them in practice, where sometimes 
non-ideal operations must be done.


Re: Regarding warnings

2013-06-29 Thread John Colvin

On Saturday, 29 June 2013 at 16:07:57 UTC, bearophile wrote:
I suggest to remove the -w switch from the list of dmd/ldc2 
switches, and later to remove that functionality too. It's 
better to keep only the informational warnings.


I keep seeing people in D.learn that miss warnings because they 
don't active them, so I suggest to activate informational 
warnings on default.


And then I suggest to add a switch to disable the warnings, for 
the rare situations where you don't want them.


Bye,
bearophile


I've been using D heavily for well over a year now and I've never 
used -w (facepalm)
That's good anecdotal evidence that it should be opt-out not 
opt-in.


Brb... Recompiling all my code with -w to find out my stupid 
mistakes :p


Re: Automatic typing

2013-06-29 Thread Walter Bright

On 6/29/2013 12:18 PM, Ary Borenszweig wrote:

What you are asking is essentially what Crystal does for all variables (and 
types):

https://github.com/manastech/crystal/wiki/Introduction#type-inference

Your example would be written like this:

x = 3
y = f()
x = 3.9

But since Crystal transforms your code to SSA
(http://en.wikipedia.org/wiki/Static_single_assignment_form) you actually have
*two* x variables in your code. The first one is of type Int32, the second of
type Float64.


Sorry, but that seems like a solution in search of a problem.

And besides, yuk. Imagine the bugs caused by hey, it doesn't implicitly 
convert, so instead of letting the user know he goofed, let's just silently 
create a new variable!


Re: SIMD on Windows

2013-06-29 Thread Michael

versioning on Win32/Win64 no longer works.

Why? or What exactly? Details please)


Re: Automatic typing

2013-06-29 Thread Ary Borenszweig

On 6/29/13 6:01 PM, Walter Bright wrote:

On 6/29/2013 12:18 PM, Ary Borenszweig wrote:

What you are asking is essentially what Crystal does for all variables
(and types):

https://github.com/manastech/crystal/wiki/Introduction#type-inference

Your example would be written like this:

x = 3
y = f()
x = 3.9

But since Crystal transforms your code to SSA
(http://en.wikipedia.org/wiki/Static_single_assignment_form) you
actually have
*two* x variables in your code. The first one is of type Int32, the
second of
type Float64.


Sorry, but that seems like a solution in search of a problem.

And besides, yuk. Imagine the bugs caused by hey, it doesn't implicitly
convert, so instead of letting the user know he goofed, let's just
silently create a new variable!


Sorry, but I can't imagine those bugs. Can you show me an example?


Re: Regarding warnings

2013-06-29 Thread bearophile

John Colvin:

I've been using D heavily for well over a year now and I've 
never used -w (facepalm)
That's good anecdotal evidence that it should be opt-out not 
opt-in.


Brb... Recompiling all my code with -w to find out my stupid 
mistakes :p


If you seem my first point, I am suggesting to remove -w from 
the switches and to use -wi (actually I am suggesting -wi to 
become the default compilation mode).


Bye,
bearophile


Re: Automatic typing

2013-06-29 Thread Walter Bright

On 6/29/2013 2:53 PM, Ary Borenszweig wrote:

On 6/29/13 6:01 PM, Walter Bright wrote:

On 6/29/2013 12:18 PM, Ary Borenszweig wrote:

What you are asking is essentially what Crystal does for all variables
(and types):

https://github.com/manastech/crystal/wiki/Introduction#type-inference

Your example would be written like this:

x = 3
y = f()
x = 3.9

But since Crystal transforms your code to SSA
(http://en.wikipedia.org/wiki/Static_single_assignment_form) you
actually have
*two* x variables in your code. The first one is of type Int32, the
second of
type Float64.


Sorry, but that seems like a solution in search of a problem.

And besides, yuk. Imagine the bugs caused by hey, it doesn't implicitly
convert, so instead of letting the user know he goofed, let's just
silently create a new variable!


Sorry, but I can't imagine those bugs. Can you show me an example?


Sure:

x = 3
px = x
y = f()
x = 3.9
// uh-oh, *px points to a different x, and wasn't updated!
printf(%d\n, x);  // uh-oh, I thought x was an int!


Re: Automatic typing

2013-06-29 Thread Steven Schveighoffer
On Sat, 29 Jun 2013 17:01:54 -0400, Walter Bright  
newshou...@digitalmars.com wrote:



On 6/29/2013 12:18 PM, Ary Borenszweig wrote:
What you are asking is essentially what Crystal does for all variables  
(and types):


https://github.com/manastech/crystal/wiki/Introduction#type-inference

Your example would be written like this:

x = 3
y = f()
x = 3.9

But since Crystal transforms your code to SSA
(http://en.wikipedia.org/wiki/Static_single_assignment_form) you  
actually have
*two* x variables in your code. The first one is of type Int32, the  
second of

type Float64.


Sorry, but that seems like a solution in search of a problem.

And besides, yuk. Imagine the bugs caused by hey, it doesn't implicitly  
convert, so instead of letting the user know he goofed, let's just  
silently create a new variable!


x is a variant that is compile-time optimized to be an int or a float.   
Where would the bug be?  If x could possibly change types depending on  
runtime data, then x is given a type of a union between int or float.


It would be somewhat like the compiler optimizing this:

{
Variant v = 1;
v = 3.5;
}

to:

{
int v = 1;
}
{
float v = 3.5;
}

because it sees that during the optimized scopes, v is only used as that  
specific type.


It seems like the compiler is generating variants that can hold exactly  
the types that are used for that variable.  Interesting concept.


-Steve


Re: Regarding warnings

2013-06-29 Thread Andrej Mitrovic
On 6/30/13, bearophile bearophileh...@lycos.com wrote:
 If you seem my first point, I am suggesting to remove -w from
 the switches and to use -wi (actually I am suggesting -wi to
 become the default compilation mode).

Regardless of any FR's I still want to ability for compilation to halt
on a warning, even if it means a new switch. As for the whole -w/-wi
thing, why can't people just read the list of switches?


Re: Automatic typing

2013-06-29 Thread Ary Borenszweig

On 6/29/13 7:30 PM, Walter Bright wrote:

On 6/29/2013 2:53 PM, Ary Borenszweig wrote:

On 6/29/13 6:01 PM, Walter Bright wrote:

On 6/29/2013 12:18 PM, Ary Borenszweig wrote:

What you are asking is essentially what Crystal does for all variables
(and types):

https://github.com/manastech/crystal/wiki/Introduction#type-inference

Your example would be written like this:

x = 3
y = f()
x = 3.9

But since Crystal transforms your code to SSA
(http://en.wikipedia.org/wiki/Static_single_assignment_form) you
actually have
*two* x variables in your code. The first one is of type Int32, the
second of
type Float64.


Sorry, but that seems like a solution in search of a problem.

And besides, yuk. Imagine the bugs caused by hey, it doesn't implicitly
convert, so instead of letting the user know he goofed, let's just
silently create a new variable!


Sorry, but I can't imagine those bugs. Can you show me an example?


Sure:

x = 3
px = x
y = f()
x = 3.9
// uh-oh, *px points to a different x, and wasn't updated!
printf(%d\n, x);  // uh-oh, I thought x was an int!


If the last statements were:

x = 4
printf(%d\n, *px);

I can see where the problem is (you would expect that to print 4, 
right?). That can be easily fixed by not transforming the last x to SSA 
if its address is taken.


That's a really good example you gave :-)



Re: Regarding warnings

2013-06-29 Thread bearophile

Andrej Mitrovic:


I still want to ability for compilation to halt on a warning,


It's a fair desire, but for it probably the problems in Issue 
10321 need to be faced first.




As for the whole -w/-wi thing, why can't people just
read the list of switches?


I have seen tens of times that this doesn't happen, in D.learn, 
in #D on IRC and with friends, students, etc. Silent compilers 
that keep the muzzle shut on default are not good enough. John 
Colvin's answer is not so unusual.


Bye,
bearophile


Re: Regarding warnings

2013-06-29 Thread bearophile

Jonathan M Davis:


http://d.puremagic.com/issues/show_bug.cgi?id=10147


I have aggregated a request of mine to your issue 10147. Are you 
OK with this? (What I am asking in addition to your request is 
for informational warnings to be active on default and to be 
disabled on request.)


Bye,
bearophile


Re: Automatic typing

2013-06-29 Thread Walter Bright

On 6/29/2013 4:08 PM, Ary Borenszweig wrote:

That's a really good example you gave :-)


Thanks. I remember seeing it somewhere before, but can't recall just where.



Re: Regarding warnings

2013-06-29 Thread Andrej Mitrovic
On 6/30/13, bearophile bearophileh...@lycos.com wrote:
 Andrej Mitrovic:

 I still want to ability for compilation to halt on a warning,

 It's a fair desire, but for it probably the problems in Issue
 10321 need to be faced first.

I've added a reply to the bugzilla issue, I think I might not even
need this behavior anymore, so I withdraw the request.


DMD ICE (issue 10401)

2013-06-29 Thread H. S. Teoh
I've managed to locate the commit that introduced bug 10401, using git
bisect:

http://d.puremagic.com/issues/show_bug.cgi?id=10401

But I don't have the DMD know-how to figure out what exactly is going
on. Any takers? :)


T

-- 
Not all rumours are as misleading as this one.


Re: SIMD on Windows

2013-06-29 Thread Manu
You should probably watch my talk again ;)
Most of the points I make towards the end when I make the claim almost
everyone who tries to use SIMD will see the same or slower performance, and
the reason is they have simply revealed other bottlenecks.
And I also made the point only by strictly applying ALL of the points I
demonstrated, will you see significant performance improvement.

The problem with your code is that it doesn't do any real work. Your
operations are all dependent on the result of the previous operation. The
scalar operations have a shorter latency than the SIMD operations, and they
all execute in parallel.
This is exactly the pathological worst-case comparison that basically
everyone new to SIMD tries to write and wonders why it's slow.
I guess I should have demonstrated this point more clearly in my talk. It
was very rushed (actually, the script was basically on the spot), sorry
about that!

There's not enough code in those loops. You're basically profiling loop
iteration performance and the latency of a float opcode vs a simd opcode...
not any significant work.
You should see a big difference if you unroll the loop 4-8 times (or more
for such a short loop, depending on the CPU).
I also made the point that you should always avoid doing SIMD profiling on
an x86, and certainly not an x64, since it is both, the most forgiving
(results in the least wins of any arch), and also the hardest to predict;
the performance difference you see will almost certainly not be the same on
someone else's chip..

Look again to my points about latency, reducing the overall pipeline length
(demonstrated with the addition sequence), and unrolling the loops.


On 30 June 2013 06:34, Jonathan Dunlap jad...@gmail.com wrote:

 I did watch Manu's a few days ago which inspired me to start this project.
 With the updates in http://dpaste.dzfl.pl/fce2d93b**, I'm still a bit
 clueless as to why there is almost zero performance difference...
 considering that is seems like an ideal setup to benefit from SIMD. I feel
 that if I can't see gains here: that I shouldn't bother using them in
 practice, where sometimes non-ideal operations must be done.



Re: Compiler could elide many more postblit constructor calls

2013-06-29 Thread Diggory

On Saturday, 29 June 2013 at 17:57:33 UTC, TommiT wrote:

On Saturday, 29 June 2013 at 13:47:36 UTC, TommiT wrote:

[..]

Example:


struct S
{
   int[] values;

   this(this)
   {
   values = values.dup;
   }
}

void foo(const S) { }

void main()
{
   const S s;
   foo(s); // No need to call postblit
}


One important related detail:
If the compiler decides to elide the postblit of S on the call 
to foo(s), then the destructor of S (if S happened to have one) 
should not be called when the call to foo exits and the 
argument passed to foo goes out of scope. The logic behind this 
is that when we omit the postblit on the argument that's passed 
by value, it is as-if we had passed the argument by const 
reference (except that the argument is considered local to foo, 
i.e. not returnable by reference and what not).


Unless the function is pure, this is only possible for immutable 
parameters otherwise the original variable may be modified while 
inside the function even if it is passed by const.


Interacting between two different programs

2013-06-29 Thread Jeremy DeHaan
I've been toying around with the idea of working on an IDE, 
mostly because I think it would be an interesting/fun project to 
work on. In any case, the only thing I cannot seem to wrap my 
head around is how programs like Code Blocks and Visual Studio, 
and various other IDE's interact with debuggers as if it isn't 
some external thing.


How does someone have one program interact with another like 
this? Can you have one send its output to the other's input? Do 
they somehow share the same IO's? I've never had to write code 
that does anything like this so I'm you great minds out there can 
shed some light.


Thanks in advance!


Re: Get body of a function as string

2013-06-29 Thread Namespace

Oh, hey! I remember participating in writing some of that :)

Only Involved? You've written it. I've added only a few things. :)


Re: Interacting between two different programs

2013-06-29 Thread yaz

On Saturday, 29 June 2013 at 06:08:28 UTC, Jeremy DeHaan wrote:
I've been toying around with the idea of working on an IDE, 
mostly because I think it would be an interesting/fun project 
to work on. In any case, the only thing I cannot seem to wrap 
my head around is how programs like Code Blocks and Visual 
Studio, and various other IDE's interact with debuggers as if 
it isn't some external thing.


How does someone have one program interact with another like 
this? Can you have one send its output to the other's input? Do 
they somehow share the same IO's? I've never had to write code 
that does anything like this so I'm you great minds out there 
can shed some light.


Thanks in advance!


You can use std.phobos.pipeProcess to interact with an external 
process that you spawn. This works by connecting the standard 
streams between the child and parent processes, so that they can 
send and receive data.
GDB provides an interface that can be used with this kind of 
intercommunication. It is called GDB MI. You can read about it 
here 
http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_211.html#SEC216


Re: Interacting between two different programs

2013-06-29 Thread Anthony J Bonkoski

On Saturday, 29 June 2013 at 06:08:28 UTC, Jeremy DeHaan wrote:
I've been toying around with the idea of working on an IDE, 
mostly because I think it would be an interesting/fun project 
to work on. In any case, the only thing I cannot seem to wrap 
my head around is how programs like Code Blocks and Visual 
Studio, and various other IDE's interact with debuggers as if 
it isn't some external thing.


How does someone have one program interact with another like 
this? Can you have one send its output to the other's input? Do 
they somehow share the same IO's? I've never had to write code 
that does anything like this so I'm you great minds out there 
can shed some light.


Thanks in advance!


At a more fundamental level, you might want to read about fork(), 
pipe(), execlp()  UNIX-style system calls. Here's a nice 
document: http://www.makelinux.net/alp/038. Given, this is 
Unix-specific and Windows will be much different. However, you'll 
find this low-level understanding useful when using the 
higher-level APIs.


Re: Opaque structs

2013-06-29 Thread Johannes Pfau
Am Fri, 28 Jun 2013 22:16:33 +0200
schrieb Andrej Mitrovic andrej.mitrov...@gmail.com:

 On 6/28/13, Johannes Pfau nos...@example.com wrote:
  A naive question: Why isn't struct S {} enough? This should be a
  struct with size 0 so why do we need to disable the constructor and
  postblit explicitly?
 
 Because the user should never be able to use such a struct by value,
 in other words a user might mistakenly write code such as:
 
 S s2 = *s;  // copies 1 byte

But why is that legal / does that copy _one_ byte? It seems like that's
totally arbitrary. Shouldn't doing anything value-related on
an empty struct be invalid anyway?




Re: Opaque structs

2013-06-29 Thread Maxim Fomin

On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote:

Am Fri, 28 Jun 2013 22:16:33 +0200
schrieb Andrej Mitrovic andrej.mitrov...@gmail.com:


On 6/28/13, Johannes Pfau nos...@example.com wrote:
 A naive question: Why isn't struct S {} enough? This should 
 be a
 struct with size 0 so why do we need to disable the 
 constructor and

 postblit explicitly?

Because the user should never be able to use such a struct by 
value,

in other words a user might mistakenly write code such as:

S s2 = *s;  // copies 1 byte


But why is that legal / does that copy _one_ byte? It seems 
like that's

totally arbitrary. Shouldn't doing anything value-related on
an empty struct be invalid anyway?


It copies one byte because empty structs have one byte - 
according to D implementation. The value can be adjusted using 
align() atrribute.


Re: zip vs. lockstep -- problems accessing elements by ref

2013-06-29 Thread Joseph Rushton Wakeling
On 06/28/2013 03:19 PM, Joseph Rushton Wakeling wrote:
 Consider the following equivalent code using zip and lockstep respectively to
 iterate over the entries in an array and set their values:
 
 auto arr1 = new double[10];
 foreach(i, ref x; zip(iota(10), arr1))
 {
 x = i;
 }
 writeln(arr1);
 
 auto arr2 = new double[10];
 foreach(i, ref x; lockstep(iota(10), arr2))
 {
 x = i;
 }
 writeln(arr2);
 
 The first array will still be full of nan's when it is output, while the 
 second
 will have values set correctly.  Can anyone offer a reasonable explanation why
 this should be so?  It looks like a bug to me, or at best an unreasonable
 difference in functionality. :-(

... ping ...?

The particular motivation here is bearophile's proposal to deprecate lockstep in
favour of zip:
http://d.puremagic.com/issues/show_bug.cgi?id=8155

That's clearly not a viable course until one can 's/lockstep/zip/' and have the
altered code Just Work.

I should add that bearophile has been fantastic in suggesting alternative design
patterns that don't require either lockstep _or_ zip, but I still think this
lockstep/zip discrepancy needs resolving.


Re: Get body of a function as string

2013-06-29 Thread Jacob Carlborg

On 2013-06-28 14:46, John Colvin wrote:

Is there any way of getting the body of a function as a string?
(Obviously only when the source code is available to the compiler)


I remember someone someone modified DMD and added a .codeof property or 
similar. It was fairly easy.


--
/Jacob Carlborg


Re: Get body of a function as string

2013-06-29 Thread bearophile

Jacob Carlborg:

I remember someone someone modified DMD and added a .codeof 
property or similar. It was fairly easy.


If there are enough use cases for it, then perhaps it's worth 
putting both the enhancement request for .codeof and its 
relative patch in Bugzilla.


Bye,
bearophile


SO Answer - Review

2013-06-29 Thread David
Could someone read over http://stackoverflow.com/a/17379444/969534
and tell me if I missed something and point out any grammatical mistakes
and fix them (if you have enough reputation to edit posts) or point them
out to me?

Thanks


test[0u] of type bool[1u] does not have a boolean value

2013-06-29 Thread Namespace
Is this a bug or is it just me? It seems that the compiler 
dereference wrong.


import std.stdio;

void foo(bool[1]* test) {
if (test[0])
test[0] = false;
}

void main()
{
bool[1] test = false;
foo(test);
}

prints: Error: expression test[0u] of type bool[1u] does not have 
a boolean value


This work:

if ((*test)[0])
test[0] = false;



Re: sort error

2013-06-29 Thread snow

On Friday, 28 June 2013 at 17:07:22 UTC, Ali Çehreli wrote:

On 06/28/2013 07:00 AM, snow wrote: Hello there,
 Ive got the following code

 http://dpaste.dzfl.pl/e391a268

 This code throws me a Range Exception in Algorithm.d.

 If I use a lower number of random vectors, like 100, the code
 terminates. Also, if I delete the template instruction like
this :

 sort(individuals);

 I also don't get an exception.

Yes, what is thrown is an Error. (Error and Exception are 
different hierarchies under Throwable.)


 Does anybody know, why this is the case?

Your opCmp does not provide a complete ordering of objects:

int opCmp(ref const Vector3D vec) {
if (this.x  vec.x  this.y  vec.y  this.z  vec.z)
return 1;

if (this.x  vec.x  this.y  vec.y  this.z  vec.z)
return -1;

return 0;
}

According to that function, the following two values are 
neither less than nor greater than the other:


// passes:
assert(!(Vector3D(1, 2, 3)  Vector3D(2, 1, 3)) 
   !(Vector3D(1, 2, 3)  Vector3D(2, 1, 3)));

Ali


I tried this now:
int opCmp(ref const Vector3D vec) {
if (this.x  vec.x  this.y  vec.y  this.z  vec.z)
return 1;
return -1;
}
this should be a total ordering, because a Vector is always 
greater or smaller, than another, but I still get the same 
exception.


Re: test[0u] of type bool[1u] does not have a boolean value

2013-06-29 Thread monarch_dodra

On Saturday, 29 June 2013 at 12:41:12 UTC, Namespace wrote:
Is this a bug or is it just me? It seems that the compiler 
dereference wrong.


import std.stdio;

void foo(bool[1]* test) {
if (test[0])
test[0] = false;
}

void main()
{
bool[1] test = false;
foo(test);
}

prints: Error: expression test[0u] of type bool[1u] does not 
have a boolean value


This work:

if ((*test)[0])
test[0] = false;



bool[1]*: a pointer to a static array of bools of size 1.

Ergo test[0] is of type bool[1]. Which can't be evaluated to 
bool.
When you write test[0] = false, that is actually an *array 
assignement* (test[0] is the same as *test, which resolves to a 
bool[1]), and yo are assigning false to *all* (in this case, 1) 
elements of your array.


On the other hand, (*test)[0] first dereferences the pointer to 
obtain the array, and then obtains the first element... The 
assignment on the next line is still wrong though.


So I think it's just you ;)

But in your defense, (I think you have a C++ background?) the 
declaration syntax from D to C++ is completely different...


Related: I think this might actually give you a compiler warning 
about doing a range assign without slicing? Bearophile had 
suggested this shouldn't work unless you actually type:

test[0][] = false;
But I prefer:
test[0] []= false;

I can't test right now: Does your code emit no warnings with -w ?


Re: test[0u] of type bool[1u] does not have a boolean value

2013-06-29 Thread Namespace

I get this with -wi:
bug.d(5): Warning: explicit element-wise assignment (test[0u])[] 
= false is bett

er than test[0u] = false

That helps a bit. But I thought that D dereferences 
automatically? ;)


Re: Opaque structs

2013-06-29 Thread Johannes Pfau
Am Sat, 29 Jun 2013 10:54:32 +0200
schrieb Maxim Fomin ma...@maxim-fomin.ru:

 On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote:
  Am Fri, 28 Jun 2013 22:16:33 +0200
  schrieb Andrej Mitrovic andrej.mitrov...@gmail.com:
 
  On 6/28/13, Johannes Pfau nos...@example.com wrote:
   A naive question: Why isn't struct S {} enough? This should 
   be a
   struct with size 0 so why do we need to disable the 
   constructor and
   postblit explicitly?
  
  Because the user should never be able to use such a struct by 
  value,
  in other words a user might mistakenly write code such as:
  
  S s2 = *s;  // copies 1 byte
 
  But why is that legal / does that copy _one_ byte? It seems 
  like that's
  totally arbitrary. Shouldn't doing anything value-related on
  an empty struct be invalid anyway?
 
 It copies one byte because empty structs have one byte - 
 according to D implementation. The value can be adjusted using 
 align() atrribute.

I see. I didn't know that we have this in the spec, but I guess there's
some good reason for this behavior if it was explicitly specified /
implemented.


Re: test[0u] of type bool[1u] does not have a boolean value

2013-06-29 Thread bearophile

monarch_dodra:

Related: I think this might actually give you a compiler 
warning about doing a range assign without slicing? Bearophile 
had suggested this shouldn't work unless you actually type:

test[0][] = false;
But I prefer:
test[0] []= false;

I can't test right now: Does your code emit no warnings with -w 
?


I have also suggested to have the -wi switch activated on 
default (as I think C# does, because people forget to use it all 
the time!), give a switch to disable on request the informational 
warnings (because once in a while you don't want warnings), and 
remove the -w switch (because it breaks the semantics of D 
programs) :-)


http://d.puremagic.com/issues/show_bug.cgi?id=10321

Bye,
bearophile


Re: test[0u] of type bool[1u] does not have a boolean value

2013-06-29 Thread monarch_dodra

On Saturday, 29 June 2013 at 13:11:10 UTC, bearophile wrote:

monarch_dodra:

Related: I think this might actually give you a compiler 
warning about doing a range assign without slicing? Bearophile 
had suggested this shouldn't work unless you actually type:

test[0][] = false;
But I prefer:
test[0] []= false;

I can't test right now: Does your code emit no warnings with 
-w ?


I have also suggested to have the -wi switch activated on 
default (as I think C# does, because people forget to use it 
all the time!), give a switch to disable on request the 
informational warnings (because once in a while you don't want 
warnings), and remove the -w switch (because it breaks the 
semantics of D programs) :-)


http://d.puremagic.com/issues/show_bug.cgi?id=10321

Bye,
bearophile


Thanks for the link. I actually wanted to state that I think you 
were one of the people who thought the above should be mandatory 
syntax? I do.


Re: test[0u] of type bool[1u] does not have a boolean value

2013-06-29 Thread monarch_dodra

On Saturday, 29 June 2013 at 12:57:07 UTC, Namespace wrote:

I get this with -wi:
bug.d(5): Warning: explicit element-wise assignment 
(test[0u])[] = false is bett

er than test[0u] = false

That helps a bit. But I thought that D dereferences 
automatically? ;)


Only when making a function call (AFAIK), eg: p.foo();

This also takes precedence over UFCS:


struct S
{
void foo(){writeln(val);}
}
void foo(S*){writeln(pointer);} //troll function trying to 
hijack p.foo()

void main()
{
S* p = new S;
p.foo();
}

val



Re: sort error

2013-06-29 Thread Ali Çehreli

On 06/29/2013 05:46 AM, snow wrote:

 On Friday, 28 June 2013 at 17:07:22 UTC, Ali Çehreli wrote:

 Your opCmp does not provide a complete ordering of objects:

 int opCmp(ref const Vector3D vec) {
 if (this.x  vec.x  this.y  vec.y  this.z  vec.z)
 return 1;

 if (this.x  vec.x  this.y  vec.y  this.z  vec.z)
 return -1;

 return 0;
 }

 According to that function, the following two values are neither less
 than nor greater than the other:

 // passes:
 assert(!(Vector3D(1, 2, 3)  Vector3D(2, 1, 3)) 
!(Vector3D(1, 2, 3)  Vector3D(2, 1, 3)));

 Ali

 I tried this now:
  int opCmp(ref const Vector3D vec) {
  if (this.x  vec.x  this.y  vec.y  this.z  vec.z)
  return 1;
  return -1;
  }
 this should be a total ordering,

Unfortunately, no. opCmp must return 0 when the values are considered equal.

 because a Vector is always greater or smaller, than another,
 but I still get the same exception.

Not knowing whether it applies to your case, the following is one almost 
correct way of writing opCmp:


int opCmp(ref const Vector3D vec) {
return cast(int)(x != vec.x
 ? x - vec.x
 : (y != vec.y
? y - vec.y
: z - vec.z));
}

The reason I said almost is due to the usual floating point equality 
comparison warnings. Values that are supposed to be equal may not 
compare equal due to accumulated earlier floating point calculation errors.


Ali



Re: Opaque structs

2013-06-29 Thread Andrej Mitrovic
On 6/29/13, Johannes Pfau nos...@example.com wrote:
 Shouldn't doing anything value-related on
 an empty struct be invalid anyway?

Maybe, maybe not. I could imagine it would cause problems if we simply
disallowed it, e.g. if you want to copy attributes from one
declaration to another.


Re: sort error

2013-06-29 Thread snow

On Saturday, 29 June 2013 at 14:20:05 UTC, Ali Çehreli wrote:

On 06/29/2013 05:46 AM, snow wrote:

 On Friday, 28 June 2013 at 17:07:22 UTC, Ali Çehreli wrote:

 Your opCmp does not provide a complete ordering of objects:

 int opCmp(ref const Vector3D vec) {
 if (this.x  vec.x  this.y  vec.y  this.z 
vec.z)
 return 1;

 if (this.x  vec.x  this.y  vec.y  this.z 
vec.z)
 return -1;

 return 0;
 }

 According to that function, the following two values are
neither less
 than nor greater than the other:

 // passes:
 assert(!(Vector3D(1, 2, 3)  Vector3D(2, 1, 3)) 
!(Vector3D(1, 2, 3)  Vector3D(2, 1, 3)));

 Ali

 I tried this now:
  int opCmp(ref const Vector3D vec) {
  if (this.x  vec.x  this.y  vec.y  this.z 
vec.z)
  return 1;
  return -1;
  }
 this should be a total ordering,

Unfortunately, no. opCmp must return 0 when the values are 
considered equal.


 because a Vector is always greater or smaller, than another,
 but I still get the same exception.

Not knowing whether it applies to your case, the following is 
one almost correct way of writing opCmp:


int opCmp(ref const Vector3D vec) {
return cast(int)(x != vec.x
 ? x - vec.x
 : (y != vec.y
? y - vec.y
: z - vec.z));
}

The reason I said almost is due to the usual floating point 
equality comparison warnings. Values that are supposed to be 
equal may not compare equal due to accumulated earlier floating 
point calculation errors.


Ali


Thats a cool way, thanks. But the exception is still coming. Both 
solutions  throw -1,0 or 1. So my first solution should work, 
too. Sure that the exception is coming, because of the compare 
function?


Re: sort error

2013-06-29 Thread monarch_dodra

On Saturday, 29 June 2013 at 14:20:05 UTC, Ali Çehreli wrote:
Not knowing whether it applies to your case, the following is 
one almost correct way of writing opCmp:


int opCmp(ref const Vector3D vec) {
return cast(int)(x != vec.x
 ? x - vec.x
 : (y != vec.y
? y - vec.y
: z - vec.z));
}

Ali


This is the closes thing to what the OP wrote, but it is a *very* 
(IMO) strange way to sort 3D elements.


In basic English, it's:
Whoever has the smallest X, or, if tied,
Whoever has the smallest Y, or, if tied,
Whoever has the smallest Z

OP: Is this how you wanted to sort?

This is strange to me because ordering is (usually) tied to a 
norm, where basically, opCmp returns whoever has the smallest 
norm. Yet this ordering isn't really tied to any norm.


OP: Can you confirm how you want to sort? Usually, 3DVector are 
sorted using any of Euclidian, Manhatan, Maximum or Minimum norm:

https://en.wikipedia.org/wiki/Norm_(mathematics)#Examples

If you can define a norm function, then opCmp becomes:

int opCmp(in Vector3D iRhs)
{
auto nLhs = this.norm();
auto nRhs = iRhs.norm();
return (nLhs  nRhs) - (nLhs  nRhs);
}


This is standard boilerplate opCmp. It avoids branching too.


Unable to compile Phobos using wiki's instruction

2013-06-29 Thread Geod24

Hi folks,
As I'm learning phobos, I wanted a more inside look and did a co 
of the libs + dmd.

DMD compiles fine (using dmc), as well as druntime.
But when it comes to phobos, I'm not able to compile, I get:

[...]
DMD v2.064-devel-42b668b-dirty DEBUG
std.md5 is scheduled for deprecation. Please use std.digest.md 
instead
The 'crc32' module has been scheduled for deprecation. Please use 
'std.digest.cr

c' instead.
std\process.d(490): Error: undefined identifier 
GetHandleInformation
std\process.d(491): Error: undefined identifier 
HANDLE_FLAG_INHERIT
std\process.d(493): Error: undefined identifier 
SetHandleInformation
std\process.d(494): Error: undefined identifier 
HANDLE_FLAG_INHERIT
std\process.d(495): Error: undefined identifier 
HANDLE_FLAG_INHERIT
std\process.d(512): Error: undefined identifier 
CREATE_UNICODE_ENVIRONMENT

std\process.d(1311): Error: undefined identifier TerminateProcess

--- errorlevel 1

G:\code\D\dmd2\src\phobos

I tested on 2 computers (win7 64b).
1) I tried win32/win64, using both the built compiler (DMD 
2.064-devel) and 2.63.2 downloaded from the website. I have VS 
2010 as well as 2012 installed.
2) I tried win64, using only the devel compiler. I also tweaked 
the Makefile (Setting C:\ instead of \ for the SDK / VS path, and 
setting VS version to 11 as I only have VS2012 installed).


For the rest I stricly followed 
http://wiki.dlang.org/Building_DMD (I even have %DM_HOME% in my 
user's env).


Any help will be greatly appreciated, as I'm pretty sure I am 
missing the obvious.


Re: Unable to compile Phobos using wiki's instruction

2013-06-29 Thread Andrej Mitrovic

On Saturday, 29 June 2013 at 15:03:05 UTC, Geod24 wrote:

Hi folks,
As I'm learning phobos, I wanted a more inside look and did a 
co of the libs + dmd.


Try getting the latest druntime from git-head, since these 
symbols were moved from phobos into druntime a few pull requests 
ago.


Re: Unable to compile Phobos using wiki's instruction

2013-06-29 Thread Andrej Mitrovic

On Saturday, 29 June 2013 at 15:15:08 UTC, Andrej Mitrovic wrote:
On Saturday, 29 June 2013 at 15:14:19 UTC, Andrej Mitrovic 
wrote:

On Saturday, 29 June 2013 at 15:03:05 UTC, Geod24 wrote:

Hi folks,
As I'm learning phobos, I wanted a more inside look and did a 
co of the libs + dmd.


Try getting the latest druntime from git-head, since these 
symbols were moved from phobos into druntime a few pull 
requests ago.


Also not that you're going to have to build druntime again, and
then phobos. It's because druntime will create new .di import
modules, which contain those symbols.


I meant *note*


Re: Unable to compile Phobos using wiki's instruction

2013-06-29 Thread Andrej Mitrovic

On Saturday, 29 June 2013 at 15:14:19 UTC, Andrej Mitrovic wrote:

On Saturday, 29 June 2013 at 15:03:05 UTC, Geod24 wrote:

Hi folks,
As I'm learning phobos, I wanted a more inside look and did a 
co of the libs + dmd.


Try getting the latest druntime from git-head, since these 
symbols were moved from phobos into druntime a few pull 
requests ago.


Also not that you're going to have to build druntime again, and
then phobos. It's because druntime will create new .di import
modules, which contain those symbols.


Re: Opaque structs

2013-06-29 Thread monarch_dodra

On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote:

Shouldn't doing anything value-related on
an empty struct be invalid anyway?


Why ?

The fact that the struct has no members is an implementation 
detail which should have no impact on the user of the struct.


Re: sort error

2013-06-29 Thread monarch_dodra

On Saturday, 29 June 2013 at 14:54:13 UTC, snow wrote:

On Saturday, 29 June 2013 at 14:20:05 UTC, Ali Çehreli wrote:
Not knowing whether it applies to your case, the following is 
one almost correct way of writing opCmp:


   int opCmp(ref const Vector3D vec) {
   return cast(int)(x != vec.x
? x - vec.x
: (y != vec.y
   ? y - vec.y
   : z - vec.z));
   }

The reason I said almost is due to the usual floating point 
equality comparison warnings. Values that are supposed to be 
equal may not compare equal due to accumulated earlier 
floating point calculation errors.


Ali


Thats a cool way, thanks. But the exception is still coming.


Not for me, Ali's code works.


Both solutions  throw -1,0 or 1.


What do you mean throw -1,0 or 1 ?

So my first solution should work, too. Sure that the exception 
is coming, because of the compare function?


Your code throws an exception for me, ali's doesn't. The only 
difference is the compare function. So *pretty* much sure, yes.


That said, in debug code, there *should* be an assert rather than 
a dumb range error. This requires an enhancement.


Re: Unable to compile Phobos using wiki's instruction

2013-06-29 Thread Geod24

On Saturday, 29 June 2013 at 15:15:49 UTC, Andrej Mitrovic wrote:
On Saturday, 29 June 2013 at 15:15:08 UTC, Andrej Mitrovic 
wrote:
On Saturday, 29 June 2013 at 15:14:19 UTC, Andrej Mitrovic 
wrote:

On Saturday, 29 June 2013 at 15:03:05 UTC, Geod24 wrote:

Hi folks,
As I'm learning phobos, I wanted a more inside look and did 
a co of the libs + dmd.


Try getting the latest druntime from git-head, since these 
symbols were moved from phobos into druntime a few pull 
requests ago.


Also not that you're going to have to build druntime again, and
then phobos. It's because druntime will create new .di import
modules, which contain those symbols.


I meant *note*


Successfully built it after fetching the up-to-date repo, thank 
you !


Re: Interacting between two different programs

2013-06-29 Thread Jeremy DeHaan

On Saturday, 29 June 2013 at 07:45:01 UTC, yaz wrote:

On Saturday, 29 June 2013 at 06:08:28 UTC, Jeremy DeHaan wrote:
I've been toying around with the idea of working on an IDE, 
mostly because I think it would be an interesting/fun project 
to work on. In any case, the only thing I cannot seem to wrap 
my head around is how programs like Code Blocks and Visual 
Studio, and various other IDE's interact with debuggers as if 
it isn't some external thing.


How does someone have one program interact with another like 
this? Can you have one send its output to the other's input? 
Do they somehow share the same IO's? I've never had to write 
code that does anything like this so I'm you great minds out 
there can shed some light.


Thanks in advance!


You can use std.phobos.pipeProcess to interact with an external 
process that you spawn. This works by connecting the standard 
streams between the child and parent processes, so that they 
can send and receive data.
GDB provides an interface that can be used with this kind of 
intercommunication. It is called GDB MI. You can read about it 
here 
http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_211.html#SEC216



This was exactly what I was looking for, thanks!

And thank you as well, Anthony. This is a lot of good information.



Error: this for method name needs to be type S not type MapResult!...

2013-06-29 Thread Peter Neubauer

Please explain why this error happens in the following code:

import std.algorithm;

struct S
{
  void foo ()
  {
int f1 (int a) { return conv(a); }
int delegate (int) f2 = conv;

int[] x = [1, 2, 3];
x.map!conv;// ERROR
x.map!f1;  // fine
x.map!f2;  // also fine
  }

  int conv (int a)
  {
return a+1;
  }
}

--- compile output:

/usr/include/d/std/algorithm.d(404): Error: this for conv needs to be 
type S not type MapResult!(conv, int[])
/usr/include/d/std/algorithm.d(438): Error: this for conv needs to be 
type S not type MapResult!(conv, int[])
/usr/include/d/std/algorithm.d(450): Error: this for conv needs to be 
type S not type MapResult!(conv, int[])
/usr/include/d/std/algorithm.d(390): Error: template instance 
std.algorithm.MapResult!(conv, int[]) error instantiating
/home/peter/proggen/goliza.reduced/gtp.d(12):instantiated from 
here: map!(int[])
/home/peter/proggen/goliza.reduced/gtp.d(12): Error: template instance 
std.algorithm.map!(conv).map!(int[]) error instantiating


---

Thanks,
-Peter


Cryptic Error message with scope(failure) and AA

2013-06-29 Thread Anthony Goins

Is this known?
I've heard there are many problems with associative arrays.

dmd 2.063

---
module scopefailtest;

int[char] AAarray;

void main(string[] args)
{
 AAarray = ['a':1, 'b':2, 'c':3];
 foreach(aa; AAarray)
 {
  scope(failure)continue;
  aa = 32;
 }
}
---

dmd output
Error: cannot implicitly convert expression (0) of type int to 
void



Works without scope(failure)
Works with non Associative Array

No helpful description.
No file or line number.
Very hard to find.


  1   2   >