[Issue 17151] Auto Completion should suggest missing imports

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17151

Rainer Schuetze  changed:

   What|Removed |Added

Summary|Auto Completion doesn't |Auto Completion should
   |work|suggest missing imports

--


[Issue 17151] Auto Completion doesn't work

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17151

Rainer Schuetze  changed:

   What|Removed |Added

 CC||r.sagita...@gmx.de

--- Comment #2 from Rainer Schuetze  ---
If you execute "Build Phobos Browse Info" from the Visual D menu and enable
"Expansion from JSON browse information", the completion list will also show
the available symbols without considering the context. Depending on the other
expansions options, you might have to press Ctrl+Space again.

I agree, having the info of the required module in the completion list would be
helpful. Adding the appropriate import automatically is also requested in issue
13912.

I'll update the title a bit here.

--


Re: Natural sorted list of files

2017-02-07 Thread Dmitry via Digitalmars-d-learn

On Wednesday, 8 February 2017 at 07:41:29 UTC, Ali Çehreli wrote:
test.naturalSort would sort the array in place before calling 
writeln and 'test' would appear naturally sorted as well. I've 
fixed it like this:


Great! Thank you!



Re: Natural sorted list of files

2017-02-07 Thread Ali Çehreli via Digitalmars-d-learn

On 02/06/2017 09:00 PM, Dmitry wrote:
> On Monday, 6 February 2017 at 18:57:17 UTC, Ali Çehreli wrote:
>> I think  it's now std.algorithm.chunkBy. Please fix Rosetta
>
> Thank you!
> I fixed

Thank you!

> but anyway it works incorrect (it doesn't any changes):

The problem was with the following loop:

foreach (test; tests)
writeln(test, "\n", test.naturalSort, "\n");

test.naturalSort would sort the array in place before calling writeln 
and 'test' would appear naturally sorted as well. I've fixed it like this:


foreach (test; tests) {
printTexts("Test strings", test);
printTexts("Normally sorted", test.dup.sort());
printTexts("Naturally sorted", test.dup.naturalSort());
}

I had fun inserting "[sic]"s both in source code and in the output for 
the INDEPENENT typo in the problem description. :D


void printTexts(Range)(string tag, Range range) {
const sic = range.front.canFind("INDEPENENT") ? " [sic]" : "";
writefln("\n%s%s:\n%-(  |%s|%|\n%)", tag, sic, range);
}

I also made the output more readable:

Test strings:
  |ignore leading spaces: 2-2|
  | ignore leading spaces: 2-1|
  |
 ignore leading spaces: 2+1|
  |  ignore leading spaces: 2+0|

Normally sorted:
  |
 ignore leading spaces: 2+1|
  |  ignore leading spaces: 2+0|
  | ignore leading spaces: 2-1|
  |ignore leading spaces: 2-2|

Naturally sorted:
  |  ignore leading spaces: 2+0|
  |
 ignore leading spaces: 2+1|
  | ignore leading spaces: 2-1|
  |ignore leading spaces: 2-2|

[...]

Ali



Re: code.dlang.org internal server error

2017-02-07 Thread Daniel Kozak via Digitalmars-d

vibed.org is down too, it would be nice to have some mirrors of those sites


Dne 8.2.2017 v 07:35 Eugene Wissner via Digitalmars-d napsal(a):

On Wednesday, 8 February 2017 at 05:49:55 UTC, Ali Çehreli wrote:

code.dlang.org gives the following error:

500 - Internal Server Error

Internal Server Error

Ali


code.dlang.org is quite often down with the same errror.




Re: code.dlang.org internal server error

2017-02-07 Thread Eugene Wissner via Digitalmars-d

On Wednesday, 8 February 2017 at 05:49:55 UTC, Ali Çehreli wrote:

code.dlang.org gives the following error:

500 - Internal Server Error

Internal Server Error

Ali


code.dlang.org is quite often down with the same errror.


Re: Pass type directly to a template function?

2017-02-07 Thread Ali Çehreli via Digitalmars-d-learn

On 02/07/2017 01:17 AM, Chris Katko wrote:


void function3(T)(T) //hypothetical, specify the datatype in the
argument list
{
T data;
}


Related:

  https://dlang.org/library/object/type_info.html

and

  https://dlang.org/library/object/object.factory.html

This compiles but I'm not sure how to use it effectively:

import std.stdio;

auto function3(TypeInfo ti)
{
return ti.initializer();
}

void main()
{
writeln(function3(typeid(float)));
writeln(function3(typeid(double)));
}

Ali



code.dlang.org internal server error

2017-02-07 Thread Ali Çehreli via Digitalmars-d

code.dlang.org gives the following error:

500 - Internal Server Error

Internal Server Error

Ali


Re: CI is broken

2017-02-07 Thread Walter Bright via Digitalmars-d

On 2/2/2017 12:56 PM, Jack Stouffer wrote:

dscanner doesn't recognize the new DIP1000 syntax, so it errors out when running
on CircleCI.


Brian Schott has fixed it:

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


Re: My next D related talk

2017-02-07 Thread Walter Bright via Digitalmars-d

On 2/7/2017 7:20 AM, Ethan Watson wrote:

http://www.rebootdevelop.hr/speakers/

Somewhere down the bottom of that list of speakers is my name. I'll be there
talking about Binderoo, and will be announcing the first stable release at that
conference.


Pretty dazz!



The speaker list is an all-star line up of game development. Just a few 
examples:

Tim Cain (Fallout)
SUDA51 (Grasshopper games)
CliffyB (Epic, Gears of War)
Chris Taylor (Total Annihilation)
Chet Faliszek (Team Fortress 2, Portal 2)
Koji Igarashi (Castlevania: Symphony of the Night)
Chris Avellonne (Planescape: Torment)

Just being on the same list as those names is intimidating.


My experience in being in an illustrious lineup is I get motivated to do my 
best, and it turns out to be great fun.




But of note, Jonathan Blow will also be speaking there. I expect he'll be doing
a Jai thing. I also expect I'll have to answer some of his questions during my
talk. Which will get *very* interesting indeed.


It would be fun to talk to Jonathan. You're in for a good time!



Re: Internal error on Wiki page

2017-02-07 Thread rikki cattermole via Digitalmars-d

On 08/02/2017 3:19 PM, Ali Çehreli wrote:

On 02/06/2017 06:43 PM, Luís Marques wrote:

This page  shows
an error instead of displaying the Wiki content:

[54c97baea4172eeabd69f522] 2017-02-06 13:47:44: Fatal exception of type
"Error"




Probably related. Help! :)

code.dlang.org/

500 - Internal Server Error

Internal Server Error

Ali


Last I checked they are not integrated or use the same technologies.
New post please.



Re: Internal error on Wiki page

2017-02-07 Thread Ali Çehreli via Digitalmars-d

On 02/06/2017 06:43 PM, Luís Marques wrote:

This page  shows
an error instead of displaying the Wiki content:

[54c97baea4172eeabd69f522] 2017-02-06 13:47:44: Fatal exception of type
"Error"




Probably related. Help! :)

code.dlang.org/

500 - Internal Server Error

Internal Server Error

Ali



Re: My next D related talk

2017-02-07 Thread extrawurst via Digitalmars-d

On Tuesday, 7 February 2017 at 15:20:23 UTC, Ethan Watson wrote:

http://www.rebootdevelop.hr/speakers/

Somewhere down the bottom of that list of speakers is my name. 
I'll be there talking about Binderoo, and will be announcing 
the first stable release at that conference.


[...]


Hey congratz Ethan! By the way will you be at GDC in 3 weeks ?

~Stephan


Re: Pass type directly to a template function?

2017-02-07 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 21:40:04 UTC, Dukc wrote:

On Tuesday, 7 February 2017 at 10:21:20 UTC, Mike Parker wrote:

function2!float(); //?
function3!float(); //?


Yes, this is how it's done.


Not quite with function3, because it takes one unnamed runtime 
parameter. It can be called like function1 however. The value 
of the parameter does not matter because it's unused, only the 
type.


Yes, I missed the runtime parameter.


Re: Workaround for DIP 1005

2017-02-07 Thread Walter Bright via Digitalmars-d

On 2/7/2017 7:00 AM, Andrea Fontana wrote:

I don't understand why we can't use a template like:

auto fun_time(SysTime)(SysTime tm)
{
import std.datetime;
static assert (is(SysTime == std.datetime.SysTime));
return tm;
}

void main()
{
  import std.stdio;
  import std.datetime;

  fun_time(Clock.currTime()).writeln;
}


It's an interesting idea, but it will have problems with overloading, as the 
template selection will match on everything.




Re: Name That Technique!

2017-02-07 Thread deadalnix via Digitalmars-d

On Saturday, 4 February 2017 at 23:54:12 UTC, David Gileadi wrote:

That's obviously a self important lookup.


This. So much this.


I'm afraid you are the only one who appreciate my humor :)


Re: Array start index

2017-02-07 Thread Ali Çehreli via Digitalmars-d-learn

On 02/07/2017 02:04 PM, Bastiaan Veelo wrote:

>> This optimization cannot work if the array is a static array inside
>> the same struct. It would work with a dynamic array but then it would
>> probably be slower than applying the *(ptr+index) technique.
>
> You mean slower than the _payload[index - first] technique? Is that
> because of heap memory versus stack memory?

Mandatory disclaimer: We can't be sure without testing.

Not exactly because stack versus heap because the whole object might be 
sitting in heap memory anyway:


alias S = StaticArray!(/* ... */);

S[] objects;
objects ~= S(/* ... */);

So, all of those are on the heap.

It's more about having everything at hand, near each other, close in 
memory. If the member is a static array, then when we have an S[], all 
members are there to be operated on. If the array in dynamic, then an 
S[] has indirections, reaching out to the heap, which may involve 
long-latency memory reads.


foreach (s; objects) {
s[42];// May have a cache miss and read from memory
}

In the static array case, the entire body of s is already on the cache.

On the other hand, when the objects are large, then few of those can fit 
in the cache. etc. One needs to profile to see what works better.


> Am I correct that the reason that a dynamic array would work is because
> it is allocated independently from the struct, meaning that its address
> stays the same even if the struct is moved?

Yes, that would be a requirement to prevent the self-reference.

> We could .reserve a dynamic
> array in initialize() to prevent it being resized.

Makes sense.

Another solution that came to my mind: You can keep the self-referencing 
solution but make sure that the objects are not moved after initialize():


S[] objects;
objects.reserve(100);
objects.each!(o => o.initialize());
// The objects will not move if you're careful

> Thanks again.
> Bastiaan.

Ali



Re: Array start index

2017-02-07 Thread Bastiaan Veelo via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 20:33:35 UTC, Ali Çehreli wrote:

On 02/07/2017 02:11 AM, Bastiaan Veelo wrote:

> We do not need to take measures against the GC?

Of course we have to and the struct that I wrote is illegal 
because it is self-referencing through the _ptr member. (D has 
the right to move structs around, making my _ptr potentially 
pointing to an illegal address.)


Gosh am I glad I brought that up, and for people like you hanging 
out in the learn group. Thanks for pointing this out!


This optimization cannot work if the array is a static array 
inside the same struct. It would work with a dynamic array but 
then it would probably be slower than applying the *(ptr+index) 
technique.


You mean slower than the _payload[index - first] technique? Is 
that because of heap memory versus stack memory?


Am I correct that the reason that a dynamic array would work is 
because it is allocated independently from the struct, meaning 
that its address stays the same even if the struct is moved? We 
could .reserve a dynamic array in initialize() to prevent it 
being resized.


Thanks again.
Bastiaan.


Passing variables, preserving UDAs: A Gripe

2017-02-07 Thread Nick Sabalausky via Digitalmars-d
Suppose I have some code that operates on a variable's value and its 
UDAs. And I want to refactor that code into a reusable function. Sounds 
simple enough, right?


So, consider a basic example:


class Foo
{
@("Hello")
string s;
}

void doStuff(alias var)()
{
var = "abc";

import std.traits;
assert(hasUDA!(var, "Hello") == true);
}

void main()
{
@("Hello")
string s;
doStuff!(s);

auto foo = new Foo();
// Error: need 'this' for 'doStuff' of type 'pure nothrow @nogc 
@safe void()'

doStuff!(foo.s);
}


Note the error. Naturally, that cannot compile, because you can't 
instantiate a template based on the value of a variable at runtime (ie, 
based on the value of `foo`).


This can be made to *compile* if you pass by runtime ref instead of alias:


void doStuff(T)(ref T var)
{
var = "abc";

import std.traits;
assert(hasUDA!(var, "Hello") == true); // Fail!
}

void main()
{
auto foo = new Foo();
doStuff(foo.s); // Ok
}


But as expected, the UDAs are not preserved because UDAs are attached to 
declarations, not values.


This CAN be made to work, albeit very awkwardly:


class Foo
{
@("Hello")
string s;
}

void doStuff(alias var)()
{
var = "abc";

import std.traits;
assert(hasUDA!(var, "Hello") == true);
}

void doStuffMember(string memberName, ObjType)(ObjType obj)
{
__traits(getMember, obj, memberName) = "abc";

import std.traits;
assert(hasUDA!(__traits(getMember, obj, memberName), "Hello") == true);
}

void main()
{
@("Hello")
string s;
doStuff!(s);

auto foo = new Foo();
doStuffMember!("s")(foo);
}


But now it's:

1. A complete freaking mess

2. An unintuitively inconsistent interface

3. A blatant DRY violation

4. AFAICS, cannot be DRY-ed up particularly well without either running 
into the original problem, resorting to string mixins (which comes with 
its own problems), or saying "to hell with using D's UDA interfaces 
within my function" and just passing the result of getUDAs into the 
function to be used instead, and recreating stuff like hasUDA to operate 
on the results of getUDAs instead of the symbols directly.


5. Did I mention it's A COMPLETE FREAKING MESS for what seems like a 
very simple problem?




Re: Why File.rawRead is @system?

2017-02-07 Thread Dukc via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 09:21:18 UTC, Kagamin wrote:
Can't find a reason why it's not inferred @safe (on linux). Any 
idea?
Perhaps you are trying to read as a type for which a conversion 
from string to it is @system? Not sure if that's possible.




DWT Support Docs for Windows

2017-02-07 Thread JamesD via Digitalmars-d-dwt
I'm a programming hobbyist and I'm new to the D language.  I've 
recently struggled to get a GUI working on Windows. I finally 
made some progress, and have created a few docs that I hope will 
help others.  Constructive feedback is welcome.


The following are on https://github.com/jasc2v8/dwt-support under 
\doc:


1. Why use the DWT GUI for the D Language
2. Config DWT GUI for Eclipse DDT on Windows
3. Build DWT 64 bit on Windows


Re: Pass type directly to a template function?

2017-02-07 Thread Dukc via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 10:21:20 UTC, Mike Parker wrote:

function2!float(); //?
function3!float(); //?


Yes, this is how it's done.


Not quite with function3, because it takes one unnamed runtime 
parameter. It can be called like function1 however. The value of 
the parameter does not matter because it's unused, only the type.





Re: Array start index

2017-02-07 Thread Bastiaan Veelo via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 20:28:30 UTC, Ali Çehreli wrote:

You forgot to call that most important function. ;)


Hah of course. I assumed the name would give it some special 
meaning, like postblit.


1) I don't understand the first assert there, which does not 
pass for me, so I commented it out.


The intention is to check that (_payload.ptr - first) is larger 
than 0.


2) May bad: init() is not a good name for a struct member, so 
it should be renamed:


void initialize() {
// assert( first < cast(size_t)_payload.ptr);
   // Address space underrun.
assert(-first < size_t.max - cast(size_t)_payload.ptr); 
// Address space overrun.

this._ptr = _payload.ptr - first;
}

3) Instead of having to remember to call it, let's introduce a 
function that does it for us:


auto makeStaticArray(T, ptrdiff_t first, ptrdiff_t last)() {
auto s = StaticArray!(T, first, last)();
s.initialize();
return s;
}


OK good.


unittest {
// StaticArray!(int, -10, 10) arr;
auto arr = makeStaticArray!(int, -10, 10);

> foreach (i, ref e; arr)
> e = i;

Unrelated: That line passes because you're building 32-bits. 
Here is the error I got:


  Error: cannot implicitly convert expression (i) of type long 
to int


You can cast it:

e = cast(int)i;

or by

import std.conv : to;
e = i.to!int;


Thanks a lot for your illustrative answers, including the next 
one!


Bastiaan.


[Issue 17155] [REG2.071.0] Link failure with nested map

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17155

Vladimir Panteleev  changed:

   What|Removed |Added

Summary|[REG2.071.0]|[REG2.071.0] Link failure
   ||with nested map

--


Re: Array start index

2017-02-07 Thread Ali Çehreli via Digitalmars-d-learn

Pressed send too soon, before considering your GC question.

On 02/07/2017 02:11 AM, Bastiaan Veelo wrote:

> We do not need to take measures against the GC?

Of course we have to and the struct that I wrote is illegal because it 
is self-referencing through the _ptr member. (D has the right to move 
structs around, making my _ptr potentially pointing to an illegal address.)


This optimization cannot work if the array is a static array inside the 
same struct. It would work with a dynamic array but then it would 
probably be slower than applying the *(ptr+index) technique.


Ali



Re: Array start index

2017-02-07 Thread Ali Çehreli via Digitalmars-d-learn

On 02/07/2017 02:11 AM, Bastiaan Veelo wrote:

> void init() {
> assert( first < cast(size_t)_payload.ptr);  //
> Address space underrun.
> assert(-first < size_t.max - cast(size_t)_payload.ptr); //
> Address space overrun.
> this._ptr = _payload.ptr - first;
> }

You forgot to call that most important function. ;)

1) I don't understand the first assert there, which does not pass for 
me, so I commented it out.


2) May bad: init() is not a good name for a struct member, so it should 
be renamed:


void initialize() {
// assert( first < cast(size_t)_payload.ptr);  // 
Address space underrun.
assert(-first < size_t.max - cast(size_t)_payload.ptr); // 
Address space overrun.

this._ptr = _payload.ptr - first;
}

3) Instead of having to remember to call it, let's introduce a function 
that does it for us:


auto makeStaticArray(T, ptrdiff_t first, ptrdiff_t last)() {
auto s = StaticArray!(T, first, last)();
s.initialize();
return s;
}

unittest {
// StaticArray!(int, -10, 10) arr;
auto arr = makeStaticArray!(int, -10, 10);

> foreach (i, ref e; arr)
> e = i;

Unrelated: That line passes because you're building 32-bits. Here is the 
error I got:


  Error: cannot implicitly convert expression (i) of type long to int

You can cast it:

e = cast(int)i;

or by

import std.conv : to;
e = i.to!int;

Ali



Re: mysql-native: preview3 (docs)

2017-02-07 Thread Suliman via Digitalmars-d-announce
@Nick, could you explain how connection working if I am close it 
after opening and only then do request to DB. See comments on SO.


Re: Initialization of dynamic multidimensional array

2017-02-07 Thread berni via Digitalmars-d-learn

auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";


This looks like what I was looking for. At least I think I 
understand what's going on here. The other two suggestions are 
beyond my scope yet, but I'll come back, when I improved on my D 
skills. Thanks for your replies.




[Issue 17141] CommonType!(dchar, char) returns uint

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17141

Jack Stouffer  changed:

   What|Removed |Added

   Severity|normal  |major

--- Comment #1 from Jack Stouffer  ---
Raising the priority of this because chain is really gimped by this bug. Every
call to chain with character ranges requires an extra call to map to cast the
results for it to work correctly.

--


[Issue 17152] DMD segfaults because of struct with static const struct members

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17152

--- Comment #1 from Sophie  ---
Apparently this issue is fixed in master, will close the issue as soon as I'm
able to confirm

--


[Issue 17154] std.conv.toChars doesn't support $ in slicing

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17154

--- Comment #2 from github-bugzi...@puremagic.com ---
Commit pushed to JackStouffer-patch-2 at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/d5ae07f0f125bdefe92b4035dfb35f613dbf9a8a
Fix Issue 17154 - Added opDollar to std.conv.toChars

--


[Issue 17154] std.conv.toChars doesn't support $ in slicing

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17154

Jack Stouffer  changed:

   What|Removed |Added

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

--


Re: Workaround for DIP 1005

2017-02-07 Thread Chris Wright via Digitalmars-d
On Tue, 07 Feb 2017 15:00:17 +, Andrea Fontana wrote:
> I don't understand why we can't use a template like:

You can. However, that makes things awkward when you want to pass that as 
a delegate. It makes it awkward to read. You don't get to specify the 
return type unless it happens to be the same as a parameter type.

A near equivalent is:

  template extractDate()
  {
import std.datetime;
Date extractDate(SysTime time)
{
  return time.date;
}
  }

Better type checking, but you need to refer to it as `extractDate!()` 
sometimes. That's still better than having to refer to it as `extractDate!
(SysTime)`.


[Issue 17154] std.conv.toChars doesn't support $ in slicing

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17154

Jack Stouffer  changed:

   What|Removed |Added

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

--


[Issue 17154] std.conv.toChars doesn't support $ in slicing

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17154

--- Comment #1 from github-bugzi...@puremagic.com ---
Commit pushed to JackStouffer-patch-2 at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/43fb9d2b32d20b421ea4efc19d729268a4e28152
Fix Issue 17154 - Added opDollar to std.conv.toChars

--


[Issue 17154] std.conv.toChars doesn't support $ in slicing

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17154

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

   What|Removed |Added

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

--


[Issue 17154] New: std.conv.toChars doesn't support $ in slicing

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17154

  Issue ID: 17154
   Summary: std.conv.toChars doesn't support $ in slicing
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: j...@jackstouffer.com

https://github.com/dlang/phobos/pull/5081

--


[Issue 17153] New: std.container.array.Array cannot be used in @nogc code

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17153

  Issue ID: 17153
   Summary: std.container.array.Array cannot be used in @nogc code
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: j...@jackstouffer.com

https://github.com/dlang/phobos/pull/5036

--


Re: CI is broken

2017-02-07 Thread Jack Stouffer via Digitalmars-d

On Thursday, 2 February 2017 at 20:56:35 UTC, Jack Stouffer wrote:

...


Now the Project Tester and the doc builder are both broken.


Re: D at FOSDEM this weekend

2017-02-07 Thread Johan Engelen via Digitalmars-d

On Tuesday, 7 February 2017 at 17:05:48 UTC, Johan Engelen wrote:


A recording of Kai's talk is online here: 
https://fosdem.org/2017/schedule/event/ldc_d_optimization/


Thanks for a nice talk Kai :-)

(please excuse the thread steal)
Some additional answers to the questions raised:

- Using LLVM IR PGO, instead of front-end PGO
Yep... I think frontend PGO is doomed... sad :/ calculating 
statement execution counts from a minimal set of counters was 
nice to work on and interesting code. VCP can be done by the 
backend too (and IIRC _is_ already done) if it has access to 
vtables, etc. To enable backend VCP, I believe clang emits a 
little bit extra (e.g. vtables) to IR where it is not needed 
otherwise. With LTO, the backend already has all the info it 
needs.
Performance-wise, the IR PGO should result in a better profile as 
it can profile optimized code which can be hugely different from 
non-optimized code (inlining!!!).
At the very least, we now have the PGO infrastructure ready and 
can easily provide an IR PGO flag (and should soon!).  When 
Clang/LLVM/LDC versions are in-sync, this should give us 
cross-language LTO+PGO. (^_^)


- Memory alloc call profiling
Something related in progress in LLVM: 
https://reviews.llvm.org/D28965


-Johan


[Issue 17152] New: DMD segfaults because of struct with static const struct members

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17152

  Issue ID: 17152
   Summary: DMD segfaults because of struct with static const
struct members
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: meapineap...@gmail.com

DMD 2.072.0 crashes when compiling this program:

struct Test{
static const A = Test([1, 2, 3]);
static const B = Test([4, 5, 6]);
int[] x;
}
void main(){}

> dmd test.d
Segmentation fault: 11

Changing from const to immutable does not affect the error.

It works fine if one of the static const members are removed. It works fine if
the members are static enum instead of static const.

--


Re: Internal error on Wiki page

2017-02-07 Thread Vladimir Panteleev via Digitalmars-d

On Tuesday, 7 February 2017 at 17:19:22 UTC, Dragos Carp wrote:

Uploading files still do not work :(

[23227d1256dea1e9bc1f46bd] 2017-02-07 17:16:45: Fatal exception 
of type "Error"


Should be fixed now.


Re: Internal error on Wiki page

2017-02-07 Thread Dragos Carp via Digitalmars-d
On Tuesday, 7 February 2017 at 13:39:38 UTC, Vladimir Panteleev 
wrote:

On Tuesday, 7 February 2017 at 10:25:13 UTC, Joakim wrote:
Maybe you just need to regenerate those pages in the cache or 
something, but when I load both the links we gave and then 
reload them, they're still broken for me.


Ah, right. Those two should be fixed. If anyone notices any 
others, anyone can fix them using an URL like 
http://wiki.dlang.org/?title=Page_title_goes_here=purge .


Uploading files still do not work :(

[23227d1256dea1e9bc1f46bd] 2017-02-07 17:16:45: Fatal exception 
of type "Error"


Re: D at FOSDEM this weekend

2017-02-07 Thread Johan Engelen via Digitalmars-d

On Tuesday, 7 February 2017 at 16:57:26 UTC, Johan Engelen wrote:
On Friday, 3 February 2017 at 06:59:32 UTC, David Nadlinger 
wrote:


Kai Nacke is going to give a talk on PGO in LDC in the LLVM 
dev room [1], and I'll also be around.


How did it go?


A recording of Kai's talk is online here: 
https://fosdem.org/2017/schedule/event/ldc_d_optimization/


Re: D at FOSDEM this weekend

2017-02-07 Thread Johan Engelen via Digitalmars-d

On Friday, 3 February 2017 at 06:59:32 UTC, David Nadlinger wrote:


Kai Nacke is going to give a talk on PGO in LDC in the LLVM dev 
room [1], and I'll also be around.


How did it go?

- Johan


[Issue 17151] Auto Completion doesn't work

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17151

--- Comment #1 from scello...@gmail.com ---
Oh nevermind, i forgot to import std.stdio

What would be nice is import suggestion like in VS or IntelliJ for C#/Java

That will help beginers like me a lot!

--


Re: Initialization of dynamic multidimensional array

2017-02-07 Thread Ilya Yaroshenko via Digitalmars-d-learn

On Sunday, 5 February 2017 at 20:33:06 UTC, berni wrote:

With X not known at compile time:


auto arr = new int[][](X,X);
for (int i=0;i

[Issue 17151] New: Auto Completion doesn't work

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17151

  Issue ID: 17151
   Summary: Auto Completion doesn't work
   Product: D
   Version: D2
  Hardware: x86
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: visuald
  Assignee: nob...@puremagic.com
  Reporter: scello...@gmail.com

Hello

Auto completion doesn't work, i installed latest verison: Visual D 0.44-beta2

I can create the project, but completion doesn't work

for example:


I want writeln("Hello Test");

if i type: writl i expect to see a popup with list (code completion) but
nothing happens

--


Re: My next D related talk

2017-02-07 Thread Meta via Digitalmars-d

On Tuesday, 7 February 2017 at 15:20:23 UTC, Ethan Watson wrote:

http://www.rebootdevelop.hr/speakers/

Somewhere down the bottom of that list of speakers is my name. 
I'll be there talking about Binderoo, and will be announcing 
the first stable release at that conference.


The speaker list is an all-star line up of game development. 
Just a few examples:


Tim Cain (Fallout)
SUDA51 (Grasshopper games)
CliffyB (Epic, Gears of War)
Chris Taylor (Total Annihilation)
Chet Faliszek (Team Fortress 2, Portal 2)
Koji Igarashi (Castlevania: Symphony of the Night)
Chris Avellonne (Planescape: Torment)

Just being on the same list as those names is intimidating.

But of note, Jonathan Blow will also be speaking there. I 
expect he'll be doing a Jai thing. I also expect I'll have to 
answer some of his questions during my talk. Which will get 
*very* interesting indeed.


Wow, that's a star-studded list. Good luck with your talk.


Mir Algorithm preview: the new ndslice, dlang Iterators, fast generics

2017-02-07 Thread Ilya Yaroshenko via Digitalmars-d

Hi all,

This is early preview before the announce of Mir Algorithm and 
the new ndslice. Ndslice is a dlang package for multidimensional 
and numeric worlds.


The new ndslice has three kinds:

1. Universal:
numpy-like, similar to the old ndslice,

2. Canonical:
BLAS-like, raw stride is assumed to be 1

3. Contiguous:
Contiguous in memory, no strides are required.

New ndslice is 90% reworked.

Mir Algorithm has its own map, retro, stride, reduce, naryFun, 
bitwise, to and others stuff from Phobos. But they are 
implemented differently, may have different API (like iota), and 
may boost your program and compilation speed few times.


Ah, ndslice is based on iterators! Dlang iterators! Dlang 
iterators are only random access, other kinds of iterators can be 
replaced with D Ranges. There are strong reasons why iterators 
are the best for random access and multidimensional worlds. They 
will be described in the future this year. Do not worry, we do 
not need to write C++-like code, iterators are used internally by 
ndslices :-)


We have full backward compatibility with Phobos Range API, so we 
can mix Phobos and Mir code. Iterators are useful if we want to 
implement custom and fast ndslices. Big collection of predefined 
ndslices can be found at mir.ndslice.topology .


Mir Algorithm is already used in Tamedia's lincount (for bitwise 
and accelerated bit count), Mir main repository. A PR with update 
for the D Computer Vision library is 85% ready.


Docs
http://docs.algorithm.dlang.io
==

Github
https://github.com/libmir/mir-algorithm
==

Dub
http://code.dlang.org/packages/mir-algorithm
==

Feedback is welcome!

For commercial support: ilyayaroshenko at gmail dot com

Best regards,
Ilya



Re: My next D related talk

2017-02-07 Thread Ethan Watson via Digitalmars-d

On Tuesday, 7 February 2017 at 15:20:23 UTC, Ethan Watson wrote:

http://www.rebootdevelop.hr/speakers/


I forgot to mention. I may not submit a DConf talk this year as a 
result. But I do want to attend, and I will see if one of the 
other Remedy guys wants to give a talk (he's been working on an 
ARC garbage collector for our usage that will get pushed out to 
Binderoo at some point).


My next D related talk

2017-02-07 Thread Ethan Watson via Digitalmars-d

http://www.rebootdevelop.hr/speakers/

Somewhere down the bottom of that list of speakers is my name. 
I'll be there talking about Binderoo, and will be announcing the 
first stable release at that conference.


The speaker list is an all-star line up of game development. Just 
a few examples:


Tim Cain (Fallout)
SUDA51 (Grasshopper games)
CliffyB (Epic, Gears of War)
Chris Taylor (Total Annihilation)
Chet Faliszek (Team Fortress 2, Portal 2)
Koji Igarashi (Castlevania: Symphony of the Night)
Chris Avellonne (Planescape: Torment)

Just being on the same list as those names is intimidating.

But of note, Jonathan Blow will also be speaking there. I expect 
he'll be doing a Jai thing. I also expect I'll have to answer 
some of his questions during my talk. Which will get *very* 
interesting indeed.


Re: Workaround for DIP 1005

2017-02-07 Thread Jack Stouffer via Digitalmars-d

On Tuesday, 7 February 2017 at 15:00:17 UTC, Andrea Fontana wrote:

...


I think I misunderstood your comment. Please forgive the noise.

I need more coffee




Re: Workaround for DIP 1005

2017-02-07 Thread Jack Stouffer via Digitalmars-d

On Tuesday, 7 February 2017 at 15:00:17 UTC, Andrea Fontana wrote:

I don't understand why we can't use a template like:

auto fun_time(SysTime)(SysTime tm)
{
import std.datetime;
static assert (is(SysTime == std.datetime.SysTime));
return tm;
}

void main()
{
  import std.stdio;
  import std.datetime;

  fun_time(Clock.currTime()).writeln;
}

I think I missed something.


Because Systime's are used in the signiture, a local import 
cannot be used. Local imports are only evaluated if the function 
is used in the program and are local to that scope. Therefore, 
when the signitures are being evaluated, the compiler has no 
information about std.datetime, and therefore fails with a symbol 
not found error.


Re: Workaround for DIP 1005

2017-02-07 Thread Andrea Fontana via Digitalmars-d

On Friday, 3 February 2017 at 15:41:56 UTC, Daniel N wrote:
On Friday, 3 February 2017 at 14:43:01 UTC, Dominikus Dittes 
Scherkl wrote:
DIP 1005 provides new syntax to make it possible to avoid 
global imports.

Any thoughts?


I like it!

template imp(string mod)
{
  mixin("import imp = " ~ mod ~ ";");
}

auto fun_time(imp!"std.datetime".SysTime tm)
{
  return tm;
}

void main()
{
  import std.stdio;
  import std.datetime;

  fun_time(Clock.currTime()).writeln;
}


I don't understand why we can't use a template like:

auto fun_time(SysTime)(SysTime tm)
{
import std.datetime;
static assert (is(SysTime == std.datetime.SysTime));
return tm;
}

void main()
{
  import std.stdio;
  import std.datetime;

  fun_time(Clock.currTime()).writeln;
}

I think I missed something.




Re: How do I call a C++ struct default constructor from D?

2017-02-07 Thread MGW via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 13:37:01 UTC, Atila Neves wrote:

Here still example
https://pp.vk.me/c636630/v636630885/46579/neSdIip1ySI.jpg



Re: How do I call a C++ struct default constructor from D?

2017-02-07 Thread MGW via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 13:37:01 UTC, Atila Neves wrote:

On Tuesday, 7 February 2017 at 10:46:24 UTC, kinke wrote:

I've only every done trivial C++ integration before. As soon as 
I tried something "real" it all broke down incredibly fast. 
Probably going to have to file some bugs on name mangling.



Atila


Perhaps this video will help
https://www.youtube.com/watch?v=HTgJaRRfLPk



Re: Internal error on Wiki page

2017-02-07 Thread Vladimir Panteleev via Digitalmars-d

On Tuesday, 7 February 2017 at 10:25:13 UTC, Joakim wrote:
Maybe you just need to regenerate those pages in the cache or 
something, but when I load both the links we gave and then 
reload them, they're still broken for me.


Ah, right. Those two should be fixed. If anyone notices any 
others, anyone can fix them using an URL like 
http://wiki.dlang.org/?title=Page_title_goes_here=purge .


Re: How do I call a C++ struct default constructor from D?

2017-02-07 Thread Atila Neves via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 10:46:24 UTC, kinke wrote:

On Tuesday, 7 February 2017 at 10:15:09 UTC, Atila Neves wrote:

I can declare a C++ struct like so:

extern(C++, mynamespace)
struct Foo {
   //...
}

But... I don't want to repeat the initialisation code for that 
struct's default constructor. I can't declare one in D because 
D doesn't allow default constructors for structs. What's my 
way out? Thanks,


Atila


I'm afraid there's no way out. I summarized some of my C++ 
interop findings incl. default constructor here: 
http://forum.dlang.org/thread/nqxsdehlydizatopr...@forum.dlang.org


Ugh, I was afraid of that. I ended up having to write (!) a C++ 
function that returned the default-initialised struct and called 
that from D.


It got uglier soon after...

I've only every done trivial C++ integration before. As soon as I 
tried something "real" it all broke down incredibly fast. 
Probably going to have to file some bugs on name mangling.



Atila




Re: Call for arms: Arch Linux D package maintenance

2017-02-07 Thread Daniel Kozak via Digitalmars-d-announce
Dne 7.2.2017 v 12:52 Joseph Rushton Wakeling via Digitalmars-d-announce 
napsal(a):



On Thursday, 2 February 2017 at 10:08:19 UTC, Daniel Kozak wrote:

I belive arch would prefer flatpak ;)


Didn't notice this before, but: the good thing about both snap and 
flatpak is one doesn't have to choose between them; these packages can 
coexist on the same system.


So as long as Arch is prepared to have an up to date snapd in its 
repos, snap packages should Just Work for those who want to use them.

Yes that is true ;)


Re: Call for arms: Arch Linux D package maintenance

2017-02-07 Thread Joseph Rushton Wakeling via Digitalmars-d-announce

On Thursday, 2 February 2017 at 10:08:19 UTC, Daniel Kozak wrote:

I belive arch would prefer flatpak ;)


Didn't notice this before, but: the good thing about both snap 
and flatpak is one doesn't have to choose between them; these 
packages can coexist on the same system.


So as long as Arch is prepared to have an up to date snapd in its 
repos, snap packages should Just Work for those who want to use 
them.


Re: How do I call a C++ struct default constructor from D?

2017-02-07 Thread kinke via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 10:15:09 UTC, Atila Neves wrote:

I can declare a C++ struct like so:

extern(C++, mynamespace)
struct Foo {
   //...
}

But... I don't want to repeat the initialisation code for that 
struct's default constructor. I can't declare one in D because 
D doesn't allow default constructors for structs. What's my way 
out? Thanks,


Atila


I'm afraid there's no way out. I summarized some of my C++ 
interop findings incl. default constructor here: 
http://forum.dlang.org/thread/nqxsdehlydizatopr...@forum.dlang.org


Re: Internal error on Wiki page

2017-02-07 Thread Joakim via Digitalmars-d
On Tuesday, 7 February 2017 at 06:57:41 UTC, Vladimir Panteleev 
wrote:

On Tuesday, 7 February 2017 at 02:43:36 UTC, Luís Marques wrote:
This page 
 shows 
an error instead of displaying the Wiki content:


[54c97baea4172eeabd69f522] 2017-02-06 13:47:44: Fatal 
exception of type "Error"


Hi,

I've updated the MediaWiki software to the latest version 
yesterday, to fix a compatibility issue with PHP 7 that was 
preventing file uploads.


Unfortunately, the MediaWiki guys have made the upgrade process 
considerably more convoluted due to changes in how extensions 
and their dependencies are loaded and managed - which is why 
there was more downtime for this than usual.


Hopefully all should be fixed now.


Maybe you just need to regenerate those pages in the cache or 
something, but when I load both the links we gave and then reload 
them, they're still broken for me.


Re: Pass type directly to a template function?

2017-02-07 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 09:17:04 UTC, Chris Katko wrote:
Can I pass a type, instead of a variable of a type, to a 
template function in order to decide the datatype of T in a 
function?


Yes. That's rather the point.



function1(f); //works


That is actually shorthand for this:

function1!float(f);

The compiler is inferring the type of f for you.




function2!float(); //?
function3!float(); //?


Yes, this is how it's done.


function3(float);  //?
function3(double); //?


No. This won't compile.





It seems like this would be a useful construct for Factory 
pattern that assembles any class that you specify as long as 
the called methods work out. (ala Duck Typing, "if it walks() 
and quacks() like a duck, it's a duck")


The range infrastructure is based on this concept.





How do I call a C++ struct default constructor from D?

2017-02-07 Thread Atila Neves via Digitalmars-d-learn

I can declare a C++ struct like so:

extern(C++, mynamespace)
struct Foo {
   //...
}

But... I don't want to repeat the initialisation code for that 
struct's default constructor. I can't declare one in D because D 
doesn't allow default constructors for structs. What's my way 
out? Thanks,


Atila


Re: Array start index

2017-02-07 Thread Bastiaan Veelo via Digitalmars-d-learn

On Monday, 6 February 2017 at 23:42:55 UTC, Ali Çehreli wrote:

Then you use _ptr when indexing:

// Support e = arr[5];
ref T opIndex(ptrdiff_t index) {
assert(index >= first);
assert(index <= last);
return *(_ptr + index);
}

Ali


Thank you very much for your time. Sadly this gives me an access 
violation. The traceback doesn't seem right though, as it seems 
to jump to opIndexAssign from where opIndex is used. If I'm not 
mistaken, I have confirmed that _ptr is a valid address, see 
below. We do not need to take measures against the GC?


- Bastiaan.


On Windows:

rdmd -main -unittest -debug -g source\epcompat\array.d

object.Error@(0): Access Violation

0x00402057 in void epcompat.array.__unittestL81_1() at 
C:\SARC\Pascal2017\D\epcompat\source\epcompat\array.d(88)
0x0040465C in void epcompat.array.__modtest() at 
C:\SARC\Pascal2017\D\epcompat\source\epcompat\array.d(39)
0x0040A455 in int 
core.runtime.runModuleUnitTests().__foreachbody1(object.ModuleInfo*)
0x0040C007 in int object.ModuleInfo.opApply(scope int 
delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*))

0x00406808 in _d_run_main
0x004046D4 in main at 
C:\SARC\Pascal2017\D\epcompat\source\epcompat\array.d(7)

0x004225DD in mainCRTStartup
0x779C62C4 in BaseThreadInitThunk
0x77B50FD9 in RtlSubscribeWnfStateChangeNotification
0x77B50FA4 in RtlSubscribeWnfStateChangeNotification

The complete source:

module epcompat.array;

// Test with rdmd -main -unittest -debug -g 
source\epcompat\array.d


alias StaticArray_offset StaticArray;

/*
 * A fixed-length array with an index that runs from $(D_PARAM 
first)

 * to $(D_PARAM last) inclusive.
 *
 * Implemented by means of an offset pointer.
 */
struct StaticArray_offset(T, ptrdiff_t first, ptrdiff_t last) {
T[last - first + 1] _payload;
T* _ptr;

void init() {
assert( first < cast(size_t)_payload.ptr);  
// Address space underrun.
assert(-first < size_t.max - cast(size_t)_payload.ptr); 
// Address space overrun.

this._ptr = _payload.ptr - first;
}

size_t length() {
return _payload.length;
}

// Support e = arr[5];
ref T opIndex(ptrdiff_t index) {
assert(index >= first);
assert(index <= last);
return *(_ptr + index);
}

// Support arr[5] = e;
void opIndexAssign(U : T)(auto ref U value, ptrdiff_t index) {
assert(index >= first);
assert(index <= last);
*(_ptr + index) = value;
}   // Line 39

// Support foreach(e; arr).
int opApply(scope int delegate(ref T) dg)
{
int result = 0;

for (int i = 0; i < _payload.length; i++)
{
result = dg(_payload[i]);
if (result)
break;
}
return result;
}

// Support foreach(i, e; arr).
int opApply(scope int delegate(ptrdiff_t index, ref T) dg)
{
int result = 0;

for (int i = first; i <= last; i++)
{
result = dg(i, *(_ptr + i));
if (result)
break;
}
return result;
}

// Write to binary file.
void toFile(string fileName)
{
import std.stdio;
auto f = File(fileName, "wb");
if (f.tryLock)
{
f.rawWrite(_payload);
}
}
}

unittest {
StaticArray!(int, -10, 10) arr;
assert(arr.length == 21);

foreach (ref e; arr)
e = 42;

assert(arr[-10] == 42); // Line 88
assert(arr[0]   == 42);
assert(arr[10]  == 42);

foreach (i, ref e; arr)
e = i;

assert(arr[-10] == -10);
assert(arr[0]   ==   0);
assert(arr[5]   ==   5);
assert(arr[10]  ==  10);

arr[5] = 15;
assert(arr[5]   == 15);
}



Re: Why File.rawRead is @system?

2017-02-07 Thread Basile B. via Digitalmars-d-learn

On Tuesday, 7 February 2017 at 09:21:18 UTC, Kagamin wrote:
Can't find a reason why it's not inferred @safe (on linux). Any 
idea?


Uh ? It's safe

Just tried


import std.stdio;

void main(string[] args) @safe
{
File f;
ubyte[] z;
z = f.rawRead(z);
}


And it compiles (DMD 2.073, Linux, X86_64)


Why File.rawRead is @system?

2017-02-07 Thread Kagamin via Digitalmars-d-learn
Can't find a reason why it's not inferred @safe (on linux). Any 
idea?


Pass type directly to a template function?

2017-02-07 Thread Chris Katko via Digitalmars-d-learn
Can I pass a type, instead of a variable of a type, to a template 
function in order to decide the datatype of T in a function?


void function(T)(T x) //works
 {
T data;
//do stuff with T, ignoring x.
}


void function2(T)() //hypothetical, specify the type... somehow?
{
T data;
}

void function3(T)(T) //hypothetical, specify the datatype in the 
argument list

{
T data;
}


void main()
{
float f=0;
float d=0;
function1(f); //works
function1(d); //works

function2!float(); //?
function3!float(); //?

function3(float);  //?
function3(double); //?
}



It seems like this would be a useful construct for Factory 
pattern that assembles any class that you specify as long as the 
called methods work out. (ala Duck Typing, "if it walks() and 
quacks() like a duck, it's a duck")





[Issue 8816] It should be illegal for enums to declare members named init, max, or min

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8816

RazvanN  changed:

   What|Removed |Added

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

--


[Issue 8816] It should be illegal for enums to declare members named init, max, or min

2017-02-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8816

RazvanN  changed:

   What|Removed |Added

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

--- Comment #4 from RazvanN  ---
Cannot reproduce on DMD64 D Compiler v2.074.0-devel-4ee9f51 Ubuntu 16.04
64-bit.
For all test cases (min/max/init) the compiler outputs "Cannot modify manifest
constant $constants".

--


Re: The extent of trust in errors and error handling

2017-02-07 Thread Steve Biedermann via Digitalmars-d

On Wednesday, 1 February 2017 at 19:25:07 UTC, Ali Çehreli wrote:
tl;dr - Seeking thoughts on trusting a system that allows 
"handling" errors.


One of my extra-curricular interests is the Mill CPU[1]. A 
recent discussion in that context reminded me of the 
Error-Exception distinction in languages like D.


1) There is the well-known issue of whether Error should ever 
be caught. If Error represents conditions where the application 
is not in a defined state, hence it should stop operating as 
soon as possible, should that also carry over to other 
applications, to the OS, and perhaps even to other systems in 
the whole cluster?


For example, if a function detected an inconsistency in a DB 
that is available to all applications (as is the case in the 
Unix model of user-based access protection), should all 
processes that use that DB stop operating as well?


2) What if an intermediate layer of code did in fact handle an 
Error (perhaps raised by a function pre-condition check)? 
Should the callers of that layer have a say on that? Should a 
higher level code be able to say that Error should not be 
handled at all?


For example, an application code may want to say that no 
library that it uses should handle Errors that are thrown by a 
security library.


Aside, and more related to D: I think this whole discussion is 
related to another issue that has been raised in this forum a 
number of times: Whose responsibility is it to execute function 
pre-conditions? I think it was agreed that pre-condition checks 
should be run in the context of the caller. So, not the 
library, but the application code, should require that they be 
executed. In other words, it should be irrelevant whether the 
library was built in release mode or not, its pre-condition 
checks should be available to the caller. (I think we need to 
fix this anyway.)


And there is the issue of the programmer making the right 
decision: One person's Exception may be another person's Error.


It's fascinating that there are so many fundamental questions 
with CPUs, runtimes, loaders, and OSes, and that some of these 
issues are not even semantically describable. For example, I 
think there is no way of requiring that e.g. a square root 
function not have side effects at all: The compiler can allow a 
piece of code but then the library that was actually linked 
with the application can do anything else that it wants.


Thoughts? Are we doomed? Surprisingly, not seems to be as we 
use computers everywhere and they seem to work. :o)


Ali

[1] http://millcomputing.com/


If you can recover from an error depends on the capabilities of 
the language and the guarantees it makes for errors.


If the language has no pointers and it gives you the guarantee, 
that no memory can be unintentionally overwritten in any other 
way, then you can recover from an error. Because you have the 
guarantee, that no memory corruption can happen.


If it's exactly specified, what happens when an error happens, 
you can decide if it's safe to continue. But for that you need to 
know exactly what the runtime does when this error is raised. If 
you aren't 100% sure what your state is, you shouldn't continue. 
(this matters more in life critical software, than in command 
line tools, but still...).


Or if you have a software stack like erlang, where you can just 
restart the failing process. In erlang it doesn't matter if it's 
an exception or an error. If a process fails, restart it and move 
on. This works, because processes are isolated and an error can't 
corrupt other processes.


So there are many approaches to this problem and all of them are 
a bit different. The final answer can only be, it depends on the 
language and the guarantees it makes. (And how much you trust the 
compiler to do the right thing 
[https://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf] :D)