[OT] Is there anybody from D-community in Tel Aviv?

2016-12-09 Thread Suliman via Digitalmars-d
I plan to visit Tel Aviv from 31 December to 6-th of January of 
next year.

Is there anybody who take part in D-community there?


Re: CTFE Status

2016-12-09 Thread Stefan Koch via Digitalmars-d

On Monday, 31 October 2016 at 13:29:01 UTC, Stefan Koch wrote:
Hi Guys, since I got a few complaints about giving minor status 
updates in the announce group, I am opening this thread.


I will start with giving an overview of what works and what 
does not work.


Currently the only basic type you can do arithmetic on is int.
Altough you can compare longs since a few days.

These are the constructs that will work.

- foreach on static arrays strings and range-foreach  (those 
kinds (0 .. 64)).

- switches (even deeply nested ones)
- for and while loops
- ternary expressions (? :)
- if and else statements (as long as you don't use && and || )
- lables and gotos
- arithmetic expressions as well as post and pre increment and 
decrement


Constructs that will not work (but are actively worked on)

- assignment to static array cells
- long ulong arithmetic.
- function calls
- dynamic arrays and slices
- pointers
- structs
- && and ||
- sliceing

Constructs that will not work and are futher down the list.

- classes
- closures
- boundschecks
- asserts

Please note that there will probably be bugs all over the place.
So even the working features might not be working completely.


FunctionPointers and plain function calls are currently in 
progress!
Also I made further performance improvements to the 
Bytecode-generator.
As of now it needs around 50 nano-seconds per generated 
instruction.
Generation + Interpretation execution of trivial functions now 
takes LESS then a microsecond on contemporary machines!




[Issue 16961] New: Fix Algorithms to Account for ref Value Front and Avoid Copying Where Unnecessary.

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16961

  Issue ID: 16961
   Summary: Fix Algorithms to Account for ref Value Front and
Avoid Copying Where Unnecessary.
   Product: D
   Version: D2
  Hardware: x86
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: sprink.nore...@gmail.com

Some algorithms make copies of range's "front", where a copy could be expensive
and unneeded.

For example, there is absolutely no reason to be creating a copy if front
returns by references for a comparison function "cmp()":

https://github.com/dlang/phobos/blob/v2.072.1/std/algorithm/comparison.d#L595

/

int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2)
if (isInputRange!R1 && isInputRange!R2 && !(isSomeString!R1 &&
isSomeString!R2))
{
for (;; r1.popFront(), r2.popFront())
{
if (r1.empty) return -cast(int)!r2.empty;
if (r2.empty) return !r1.empty;
auto a = r1.front, b = r2.front;
if (binaryFun!pred(a, b)) return -1;
if (binaryFun!pred(b, a)) return 1;
}
}

/

D doesn't allow generic code to be written in a way to account for both (by
value and references) so a simple wrapper would need to be used to fix this:

/

struct Value(T)
{
T value;
ref T get() { return value; }
}

struct ValueRef(T)
{
T* value;
ref T get() { return *value; }
}

auto makeValue(T)(T v) { return Value!T(v);}
auto makeValue(T)(ref T v) { return ValueRef!T(); }


// in cmp() now:

auto a = r1.front.makeValue;
auto b = r2.front.makeValue;

if (binaryFun!pred(a.get(), b.get())) return -1;
if (binaryFun!pred(b.get(), a.get())) return 1;

/


Not pretty but we are not likely to see an alternative fix for this using a
language feature, which would involve "ref" variables and rvalue references.

"Just use Pointers": This doesn't actually solve the problem of writing generic
code, it just shifts the burden of writing duplicate code from the library
maintainer to the user.

Implementing this will allow for truer generic functions, reducing copying
where unneeded. No need to write two separate functions to use pointers for
expensive to copy objects. As a side effect this will also allow objects which
cannot be copied to work, for algorithms which do no copying, or should not do
any copying of objects.

--


Re: ETA: std.experimental.allocator -> std.allocator

2016-12-09 Thread Ilya Yaroshenko via Digitalmars-d
Q4: Current allocator API requires DRuntime to be linked. So, 
they are not compatible with BetterC mode. Can this be fixed 
before std.experimental.allocator -> std.allocator migration? 
--Ilya


Re: Separate IP parts

2016-12-09 Thread Anonymouse via Digitalmars-d-learn

On Saturday, 10 December 2016 at 03:51:34 UTC, brocolis wrote:

How do I separate IP parts with dlang?

I found this very cool trick, with C++: 
http://stackoverflow.com/a/5328190


std::string ip ="192.168.1.54";
std::stringstream s(ip);
int a,b,c,d; //to store the 4 ints
char ch; //to temporarily store the '.'
s >> a >> ch >> b >> ch >> c >> ch >> d;
std::cout << a << "  " << b << "  " << c << "  "<< d;

I wonder what's the equivalent D code.


Not much of a trick, but:

import std.algorithm : splitter, map;
import std.range : take;
import std.conv  : to;
import std.array : array;

string ip = "192.168.1.54";

auto parts = ip
.splitter('.')
.take(4)
.map!((a) => a.to!int)
.array;

assert(parts[0] == 192);
assert(parts[1] == 168);
assert(parts[2] == 1);
assert(parts[3] == 54);

Remove the .array to keep it lazy, but then you can't index it 
for the values, only walk through them in a foreach.


ETA: std.experimental.allocator -> std.allocator

2016-12-09 Thread Seb via Digitalmars-d

Hi all,

tl;dr: I would like to start having GC-free methods and data 
structures in Phobos, which depends on std.allocator being stable 
(i.e not in experimental).
Q1: So I would like to know what's missing/blocking this? Is it 
just time?
(FYI: std.experimental.allocator has been merged in October 2015 
and released in November 2015 with 2.069)


One thing that I heard a bit is that there's no defined guideline 
on how Allocator APIs should look like. I have seen two good 
patterns so far that, but they both have their pros/cons. As I 
think this is very important when std.allocator will be used in 
Phobos I summarized them below to help everyone to get into the 
discussion.
Q2: What is your favorite Allocator API pattern and how should 
Phobos APIs facilitate opt-in GC-free algorithms/data structures?


Q3: Are there any plans on providing language support for custom 
allocators? E.g.


new int[10] -> theAllocator.makeArray
new FancyClass(foo) -> theAllocator.make!FancyClass(foo)


1) Allocator with GCAllocator as default argument
-

I think that's how most people use the Allocator. A prominent 
example is the EMSI's container library [1].
The basic idea is that by default all allocations are handled 
conveniently by the GCAllocator.


import std.experimental.allocator.gc_allocator: GCAllocator;

void myFun(Allocator = shared GCAllocator)(int foo, ref Allocator 
alloc = Allocator.instance)

{
import std.experimental.allocator : makeArray, dispose;
auto b = alloc.makeArray!int(10); // instead of new int[10]
alloc.dispose(b);
}

unittest
{
myFun(2);
import std.experimental.allocator.mallocator: Mallocator;
myFun(2, Mallocator.instance);
}

Please note that although since 2.072 for make/makeArray 
attributes are automatically propagated, due to the global 
sharedness of the GCAllocator such templated code can't be @safe 
(see e.g. [2] for a discussion).


2) makeX pattern


The idea here is to provide a special makeX method that allows 
the use of custom allocator.
This pattern is intended for cases in which allocated data is 
returned to the user.


A simplified example from Phobos:

auto slice(T, size_t N)(size_t[N] lengths...);
SliceAllocationResult!(N, T) makeSlice(T, Allocator, size_t 
N)(auto ref Allocator alloc, size_t[N] lengths...);


And a short usage example:

slice!int(2, 3);
Mallocator.instance.makeSlice!int(2, 3);

Another good example is mir.combinatorics [2].

The idea here is that it's the users job to deal with the 
allocated data, he has to call dispose himself. Thus a 
convenience dispose overload may be provided.


[1] https://github.com/economicmodeling/containers
[2] https://github.com/dlang/phobos/pull/4288
[3] 
http://dlang.org/phobos/std_experimental_ndslice_slice.html#.ndarray

[4] http://docs.mir.dlang.io/latest/mir_combinatorics.html


[Issue 16949] [Reg 2.073] confusing @safe error message for fields with unsafe destructors

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16949

Martin Nowak  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|WORKSFORME  |---

--- Comment #2 from Martin Nowak  ---
(In reply to Walter Bright from comment #1)
> Already fixed:
> 
> C:\cbx\bug>..\dmd test7 -transition=safe
> test7.d(6): Error: @safe destructor 'test7.B.~this' cannot call @system
> destructor 'test7.A.~this'

Mmh, it's still broken in master, [Reg 2.073] is the current development
version for the next release.
It got fixed on the scope branch by
https://github.com/dlang/dmd/commit/592824958312f0bf370f813631c4e6d0ff1862dc
which allowed to take the address of variables in @safe code, thereby obviously
nixing a check that prevents you from taking the address of a variable in @safe
code.

If you look at both commits

https://github.com/dlang/dmd/commit/c871b7b2efb49933f8b103b775079c8731c98fa8
https://github.com/dlang/dmd/commit/592824958312f0bf370f813631c4e6d0ff1862dc

The problematic code and it's fix sum up to:

if ((dve.e1.op == TOKthis || dve.e1.op == TOKsuper) && global.params.safe)
checkAddressVar(cast(ThisExp)dve.e1)

checkAddressVar() {
if (!v.canTakeAddressOf()) // this and super are never manifest variables
error("bla");
if (sc.func && !sc.intypeof && !v.isDataseg())
// !global.params.safe was added in scope branch
if (!global.params.safe && sc.func.setUnsafe())
error("this is the diagnostic regression error");
}


If I understand this correctly the checkAddressVar call for this and super
caused the diagnostic regression and is now a noop on the scope branch.
How about we delete that part, both in master and on the scope branch?

--


Separate IP parts

2016-12-09 Thread brocolis via Digitalmars-d-learn

How do I separate IP parts with dlang?

I found this very cool trick, with C++: 
http://stackoverflow.com/a/5328190


std::string ip ="192.168.1.54";
std::stringstream s(ip);
int a,b,c,d; //to store the 4 ints
char ch; //to temporarily store the '.'
s >> a >> ch >> b >> ch >> c >> ch >> d;
std::cout << a << "  " << b << "  " << c << "  "<< d;

I wonder what's the equivalent D code.




Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:36:11 UTC, Adam D. Ruppe 
wrote:

On Saturday, 10 December 2016 at 03:29:18 UTC, unDEFER wrote:

But it works under Linux


That's just because the underlying C function handles the case. 
But the D function makes no promises about that: 
std.file.remove's documentation says "removes the file", 
leaving what it does to directories undefined.


Interestingly, the Linux kernel *does* make the distinction: 
the C remove function on Linux does a test then calls unlink or 
rmdir based on if it is a directory or not. But it didn't 
always do that.


But what you have is undefined behavior - the function is only 
guaranteed to work on files, and does not specify if it will 
work or be an error on directories.


Thank you, but I think in this case D must use unlink for 
implementation remove.


Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 01:30:52 UTC, Jonathan M Davis 
wrote:
On Saturday, December 10, 2016 01:19:45 unDEFER via 
Digitalmars-d-learn wrote:


Well, much as I'd love to rag on Windows for doing dumb and 
annoying stuff with file locks (which they do do), in this 
case, your code wouldn't have worked an other OSes either. The 
problem is that you created a directory and then used a 
function which removes files. If you want to remove a 
directory, then use rmdir (or rmdirRecurse if you want to blow 
away a non-empty directory).


- Jonathan M Davis


man remove:

remove - remove a file or directory

The function which removes only files named unlink.

The D must guarantee the same behaviour of remove on all OSes.


Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 10 December 2016 at 03:29:18 UTC, unDEFER wrote:

But it works under Linux


That's just because the underlying C function handles the case. 
But the D function makes no promises about that: 
std.file.remove's documentation says "removes the file", leaving 
what it does to directories undefined.


Interestingly, the Linux kernel *does* make the distinction: the 
C remove function on Linux does a test then calls unlink or rmdir 
based on if it is a directory or not. But it didn't always do 
that.


But what you have is undefined behavior - the function is only 
guaranteed to work on files, and does not specify if it will work 
or be an error on directories.


Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Saturday, 10 December 2016 at 01:28:13 UTC, SonicFreak94 wrote:

On Saturday, 10 December 2016 at 01:19:45 UTC, unDEFER wrote:

remove("D:\\TEST");


Try rmdir instead.


But it works under Linux


Re: The module 'foo' is already defined in 'libmylib.so'

2016-12-09 Thread timotheecour via Digitalmars-d-learn

On Saturday, 10 December 2016 at 02:39:33 UTC, timotheecour wrote:
Have a look at what `trace -E d_executable args` and `trace -E 
c++_executable args`

print on startup and grep for dlopen calls and the like.


do you mean strace?
I have trace on OSX but I'm asking for linux.


Looking at the code for $checkModuleCollisions in druntime 
[src/rt/sections_elf_shared.d:859]:


```
 * Check for module collisions. A module in a shared library 
collides
 * with an existing module if it's ModuleInfo is interposed 
(search
 * symbol interposition) by another DSO.  Therefor two modules 
with the
 * same name do not collide if their DSOs are in separate symbol 
resolution

 * chains.
```

Not exactly sure what that means nor how to fix my issue:

```
void some_fun(){
  handle=dlopen2("path/liblib.so", RTLD_LAZY | RTLD_LOCAL);
  // error: The module 'foo' is already defined in 'libmylib.so'
}
```

How would I modify the code to avoid this?


Re: The module 'foo' is already defined in 'libmylib.so'

2016-12-09 Thread timotheecour via Digitalmars-d-learn
Have a look at what `trace -E d_executable args` and `trace -E 
c++_executable args`

print on startup and grep for dlopen calls and the like.


do you mean strace?
I have trace on OSX but I'm asking for linux.



Re: staticIota is easy

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn

On 12/09/2016 05:34 PM, Stefan Koch wrote:

On Friday, 9 December 2016 at 18:52:59 UTC, Ali Çehreli wrote:

I thought I needed something like staticIota in a unittest to effect
static foreach over a number range and I found one in druntime's
implementation:


https://github.com/dlang/druntime/blob/master/src/core/internal/traits.d#L106


(I wonder why that one is implemented in divide-and-conquer fashion.
Perhaps due to faster compilation that way?)



Yes it is.
n log n
instead of n^2



Makes sense. I was stopping my counting at n: both looked O(n) to me. :)

How about my staticIota()? Is it n^2 inside the compiler?

Ali



Re: staticIota is easy

2016-12-09 Thread Stefan Koch via Digitalmars-d-learn

On Friday, 9 December 2016 at 18:52:59 UTC, Ali Çehreli wrote:
I thought I needed something like staticIota in a unittest to 
effect static foreach over a number range and I found one in 
druntime's implementation:



https://github.com/dlang/druntime/blob/master/src/core/internal/traits.d#L106

(I wonder why that one is implemented in divide-and-conquer 
fashion. Perhaps due to faster compilation that way?)




Yes it is.
n log n
instead of n^2



Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread SonicFreak94 via Digitalmars-d-learn

On Saturday, 10 December 2016 at 01:19:45 UTC, unDEFER wrote:

remove("D:\\TEST");


Try rmdir instead.


Re: Getters/setters generator

2016-12-09 Thread Stefan Koch via Digitalmars-d-announce

On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote:

Hello,

we've just open sourced a small module ("accessors") that helps 
to generate getters and setters automatically:

https://github.com/funkwerk/accessors
http://code.dlang.org/packages/accessors

It takes advantage of the UDAs and mixins. A simple example 
would be:


import accessors;

class WithAccessors
{
@Read @Write
private int num_;

mixin(GenerateFieldAccessors);
}

It would generate 2 methods "num": one to set num_ and one to 
get its value. Of cause you can generate only @Read without 
@Write and vice versa. There are some more features, you can 
find the full documentation in the README.
"GenerateFieldAccessors" mixin should be added into each 
class/struct that wants to use auto generated accessors.


Oh my this is going to be a compiletime hog if used excessively.
Due the use of fqn.



Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 21:20:12 UTC, Martin Krejcirik 
wrote:

On Friday, 9 December 2016 at 16:50:05 UTC, unDEFER wrote:

And in mini program it works and shows diagnostic message.
Where my diagnostic message in more complicate program???


Try redirecting stdout and stderr to a file(s). There are cases 
when the console itself can crash.


OK, thank you. Next time with other crashes I will try.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 20:35:07 UTC, Ali Çehreli wrote:

Assuming boundschecking is turned off, I think you get unlucky 
in the mini program and happen to hit a '\0' byte.


No, no.. the program built in debug mode with dub.


mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn

Hello!

$ cat try.d
import std.file;

void main ()
{
mkdir("D:\\TEST");
remove("D:\\TEST");
}

$ ./try.exe

std.file.FileException@std\file.d(731): D:\TEST: Access Denied.




What I don't know about removing directories in Windows?
Why I can't remove directory which just time created?


Re: A new linker wlink32

2016-12-09 Thread rikki cattermole via Digitalmars-d

On 10/12/2016 12:00 PM, jest wrote:

The wlink32 is a 32 bit linker for Windows.
It is an effort of me, (Manos) and LADSoft (David Lindauer) to produce a
modern linker.
It is based on the original ALINK of Anthony A.J. Williams.
But ALINK does not support MS-COFF import libraries and
its support for making DLLs was limited and had bugs.

Attributes of wlink32:

1). Supports OMF and MS-COFF object and library files.
2). Supports response files as input.
3). Supports MS-COFF import libraries.
4). Supports .res files.
5). Produce external and embed manifest files.

You you can download this from here.

http://www.manoscoder.gr/w32cc/viewtopic.php?f=12=24


So, have you tested it as a replacement for Optlink?


Re: [OT] Interesting blog post on disadvantages of the pure functional paradigm

2016-12-09 Thread Timon Gehr via Digitalmars-d

On 10.12.2016 00:25, qznc wrote:

On Friday, 9 December 2016 at 10:25:49 UTC, Kagamin wrote:

On Friday, 9 December 2016 at 10:01:13 UTC, qznc wrote:

http://beza1e1.tuxen.de/articles/functional.html


What about python and javascript?


Python and Javascript are mixed paradigm languages. You could argue if
purity and immutability are part of FP, then Python and Javascript lack
essential parts of FP and are not mixed. That is a good point. It is
also what hardcore FP programmers think about those languages. They pity
them.
...


I don't think it is necessarily the best approach to start with an 
imperative language and then say that purity and immutability are 
somehow features you add on top in order to obtain FP. [1]


It is just as valid to consider impure languages as restrictions of pure 
functional programming languages where all computations take place in a 
specific non-customizable monad.


If the starting point is logic, functional is more fundamental, if the 
starting point is current hardware, imperative is more fundamental. I 
think it is useful to understand both of those perspectives well.




If FP is about being declarative, then logic programming (Prolog) is
even more so.


Questionable.

Quick google search finds this post, there might be better explanations: 
https://synthese.wordpress.com/2010/08/21/prologs-death/





[1] Also, immutability, in the D sense, is not essential. What is 
important is value semantics. Immutability actually prevents lazy 
functional programming.


Re: How about a bounty for a new windows installer using inno setup ?

2016-12-09 Thread Jesse Phillips via Digitalmars-d

On Friday, 9 December 2016 at 17:05:24 UTC, Kagamin wrote:
On Friday, 9 December 2016 at 16:47:18 UTC, Jesse Phillips 
wrote:
An MSI can't execute an arbitrary executable, just an 
arbitrary DLL which could run an arbitrary executable :)


https://msdn.microsoft.com/en-us/library/windows/desktop/aa368563%28v=vs.85%29.aspx
 this?


Thanks, prove me wrong :)

I suppose you'd use the DLL because it has access to the MSI 
database during installation while the EXE won't.


I'm doing it because I'm replacing a 3rd party DLL and want to 
make sure the custom action is called correctly by our installer.


Re: [OT] Interesting blog post on disadvantages of the pure functional paradigm

2016-12-09 Thread qznc via Digitalmars-d

On Friday, 9 December 2016 at 10:25:49 UTC, Kagamin wrote:

On Friday, 9 December 2016 at 10:01:13 UTC, qznc wrote:

http://beza1e1.tuxen.de/articles/functional.html


What about python and javascript?


Python and Javascript are mixed paradigm languages. You could 
argue if purity and immutability are part of FP, then Python and 
Javascript lack essential parts of FP and are not mixed. That is 
a good point. It is also what hardcore FP programmers think about 
those languages. They pity them.


If FP is about being declarative, then logic programming (Prolog) 
is even more so.


Re: Installing ldc breaks gdc

2016-12-09 Thread Daniel Kozak via Digitalmars-d

Ok, thats your opinion :P


Dne 9.12.2016 v 23:04 Iain Buclaw via Digitalmars-d napsal(a):

On 9 December 2016 at 18:34, Daniel Kozak via Digitalmars-d
 wrote:


Dne 9.12.2016 v 16:59 Eduard Staniloiu via Digitalmars-d napsal(a):

Hello, everyone.

...

Based on my previous assumtion (both dmd and gdc use /usr/include/dmd/)
and the error above, I am inclined to believe that after installing ldc, gdc
is using /usr/include/d/ and it breaks.

Maybe we should consider having a separate folder in /usr/include/ for
each compiler?

Cheers,
Eduard


No thats all wrong, dmd a gdc could not use same include directory that is
not possible. GDC use

/usr/lib/gcc/x86_64-linux-gnu/5/include/d/

LDC use

/usr/include/d/

and dmd use:

/usr/include/dmd

You probably have some misconfiguration issue


No, the /usr/include/d is considered a system includes directory.  Any
distribution package headers should be installed there, not
ldc-specific header. :-)

Regards
Iain




A new linker wlink32

2016-12-09 Thread jest via Digitalmars-d

The wlink32 is a 32 bit linker for Windows.
It is an effort of me, (Manos) and LADSoft (David Lindauer) to 
produce a modern linker.

It is based on the original ALINK of Anthony A.J. Williams.
But ALINK does not support MS-COFF import libraries and
its support for making DLLs was limited and had bugs.

Attributes of wlink32:

1). Supports OMF and MS-COFF object and library files.
2). Supports response files as input.
3). Supports MS-COFF import libraries.
4). Supports .res files.
5). Produce external and embed manifest files.

You you can download this from here.

http://www.manoscoder.gr/w32cc/viewtopic.php?f=12=24


Re: CTFE Status

2016-12-09 Thread Stefan Koch via Digitalmars-d

On Friday, 9 December 2016 at 03:06:49 UTC, Stefan Koch wrote:
On Friday, 9 December 2016 at 02:10:58 UTC, Andrei Alexandrescu 
wrote:
That's pretty awesome. The new CTFE engine release will soon 
rival Tesla Model 3 in terms of interest raised :o).


In addition to artificial corpora like the above, I suggest 
comparing against real-world code - starting with simpler 
things such as bitfields instantiations.



Andrei


That will not work currently.
Since function and methods calls are still "in the works".
They will require another restructuring as well.
Therefore artificial tests are the best I can do to gunge 
performance.


Progress has been made on this front.
However I discovered that some math is translated incorrectly.
This means I have to fix the code-gen again.
So you'll have to wait a bit until this works :).


[Issue 16960] New: implicit function return breaks chaining of exceptions thrown in scope(exit)

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16960

  Issue ID: 16960
   Summary: implicit function return breaks chaining of exceptions
thrown in scope(exit)
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: acehr...@yahoo.com

The following function tries to throw an exception that has n+1 chains.
Uncomment any one of the 3 return statements inside foo() and you will get the
expected output:

foo called with 3
foo called with 2
foo called with 1
foo called with 0
thrown for 0
thrown for 1
thrown for 2
thrown for 3

However, when foo() returns implicitly without any return statement, there is
only one exception in the chain. main() detects this case by following the
.next links.

import std.stdio;
import std.string;

void foo(int n) {
writeln("foo called with ", n);
scope (exit) throw new Exception(format("thrown for %s", n));
if (n > 0) {
/* return */ foo(n - 1);
// return;
}
// return;
}

void main() {
// Never mind the unconventional range limits:
// Throws one exception for each value in the range 0..n, including n.
enum chainLength = 3;
enum expectedLength = chainLength + 1;

try {
foo(chainLength);
}
catch (Exception original) {
size_t count = 0;
for (Throwable ex = original; ex; ex = ex.next) {
writeln(ex.msg);
++count;
}
if (count != expectedLength) {
writefln("Expected %s but walked %s links", expectedLength, count);
writefln("\nTHE ORIGINAL EXCEPTION:\n\n%s", original);
}
}
}

Ali

--


Re: Installing ldc breaks gdc

2016-12-09 Thread Iain Buclaw via Digitalmars-d
On 9 December 2016 at 18:34, Daniel Kozak via Digitalmars-d
 wrote:
>
>
> Dne 9.12.2016 v 16:59 Eduard Staniloiu via Digitalmars-d napsal(a):
>>
>> Hello, everyone.
>>
>> ...
>>
>> Based on my previous assumtion (both dmd and gdc use /usr/include/dmd/)
>> and the error above, I am inclined to believe that after installing ldc, gdc
>> is using /usr/include/d/ and it breaks.
>>
>> Maybe we should consider having a separate folder in /usr/include/ for
>> each compiler?
>>
>> Cheers,
>> Eduard
>>
> No thats all wrong, dmd a gdc could not use same include directory that is
> not possible. GDC use
>
> /usr/lib/gcc/x86_64-linux-gnu/5/include/d/
>
> LDC use
>
> /usr/include/d/
>
> and dmd use:
>
> /usr/include/dmd
>
> You probably have some misconfiguration issue
>

No, the /usr/include/d is considered a system includes directory.  Any
distribution package headers should be installed there, not
ldc-specific header. :-)

Regards
Iain


Re: Installing ldc breaks gdc

2016-12-09 Thread Iain Buclaw via Digitalmars-d
On 9 December 2016 at 18:53, Matthias Klumpp via Digitalmars-d
 wrote:
> Hi!
>
> This issue should be fixed since LDC 1:1.1.0-2, which Xenial doesn't have.
> Ideally, fetch a newer version from Debian or a PPA to solve this issue.
>
> Cheers,
> Matthias
>

Thanks


Re: The program exits unexpectedly

2016-12-09 Thread Martin Krejcirik via Digitalmars-d-learn

On Friday, 9 December 2016 at 16:50:05 UTC, unDEFER wrote:

And in mini program it works and shows diagnostic message.
Where my diagnostic message in more complicate program???


Try redirecting stdout and stderr to a file(s). There are cases 
when the console itself can crash.


Re: The program exits unexpectedly

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn

On 12/09/2016 08:50 AM, unDEFER wrote:
> On Friday, 9 December 2016 at 14:29:38 UTC, unDEFER wrote:
>> I'm afraid that the problem that my program wants to say something,
>> but there is no "flush" so message leaves in the buffer.
>
> I have found, it was code like:
>
> string path = "C:";
> string parent = path[0..path.lastIndexOf("\\")];

That's a bug because you're not checking the return value of 
lastIndexOf. According to its documentation, lastIndexOf returns -1 if 
it fails to find the needle:


  http://dlang.org/phobos/std_string.html#.lastIndexOf

ptrdiff_t found = path.lastIndexOf("\\");
if (found == -1) {
// Not found
}
else {
// Now we can use it:
string parent = path[0..path.lastIndexOf("\\")];
// ...
 }

The added complication is the fact that ptrdiff_t can be converted to 
size_t and you get a huge string when doing path[0..path.lastIndexOf("\\")]


Do you have boundschecking turned off? It should catch such an error.

> And in mini program it works and shows diagnostic message.
> Where my diagnostic message in more complicate program???

Assuming boundschecking is turned off, I think you get unlucky in the 
mini program and happen to hit a '\0' byte.


Ali



[OT] An interesting paper on advanced introspection

2016-12-09 Thread Andrei Alexandrescu via Digitalmars-d

https://eb.host.cs.st-andrews.ac.uk/drafts/elab-reflection.pdf

Shows some of the more advanced/esoteric stuff that can be done with 
introspection. -- Andrei


Re: Getters/setters generator

2016-12-09 Thread Andrei Alexandrescu via Digitalmars-d-announce

On 12/9/16 5:27 AM, Eugene Wissner wrote:

Hello,

we've just open sourced a small module ("accessors") that helps to
generate getters and setters automatically:
https://github.com/funkwerk/accessors
http://code.dlang.org/packages/accessors

It takes advantage of the UDAs and mixins. A simple example would be:

import accessors;

class WithAccessors
{
@Read @Write
private int num_;

mixin(GenerateFieldAccessors);
}

It would generate 2 methods "num": one to set num_ and one to get its
value. Of cause you can generate only @Read without @Write and vice
versa. There are some more features, you can find the full documentation
in the README.
"GenerateFieldAccessors" mixin should be added into each class/struct
that wants to use auto generated accessors.


Love it, and was toying with similar ideas too. One good extension is to 
add a predicate to the setter, which guards the assignment. -- Andrei


staticIota is easy

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn
I thought I needed something like staticIota in a unittest to effect 
static foreach over a number range and I found one in druntime's 
implementation:



https://github.com/dlang/druntime/blob/master/src/core/internal/traits.d#L106

(I wonder why that one is implemented in divide-and-conquer fashion. 
Perhaps due to faster compilation that way?)


Then I realized that this is actually pretty easy with D:

template staticIota(size_t N) {
import std.range: iota;
import std.meta: aliasSeqOf;
alias staticIota = aliasSeqOf!(N.iota);
}

unittest {
size_t count = 0;
foreach (i; staticIota!10) {
mixin("++count;");
}
assert(count == 10);
}

void main() {
}

I realized that I don't actually need it but I wanted to share. :)

Ali

P.S. Related, I've been using D for a living since I started working for 
Weka.IO in June. (I think the only mention of that was in this blog 
post: https://dlang.org/blog/2016/06/). The more I use D, the more I 
like it but you already know it. ;)


Re: Installing ldc breaks gdc

2016-12-09 Thread Matthias Klumpp via Digitalmars-d

Hi!

This issue should be fixed since LDC 1:1.1.0-2, which Xenial 
doesn't have.
Ideally, fetch a newer version from Debian or a PPA to solve this 
issue.


Cheers,
Matthias



Re: Installing ldc breaks gdc

2016-12-09 Thread Johannes Pfau via Digitalmars-d
Am Fri, 09 Dec 2016 15:59:07 +
schrieb Eduard Staniloiu :

> Hello, everyone.
> 
> So I have found that installing ldc will break gdc.
> 
> The setup:
> 
> I have a VM running a 64bit Ubuntu 16.04, as you can see from the 
> output of uname -a:
> 
>Linux ubuntu-xenial 4.4.0-51-generic #72-Ubuntu SMP Thu Nov 24 
> 18:29:54 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
> 
> I have installed:
>dmd --version: DMD64 D Compiler v2.072.0
>gdc --version: gdc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 
> 20160609
> 
> With this setup, in /usr/include we can find dmd/
> /usr/include/dmd
> |-- druntime
> |   `-- import
> |   |-- core
> |   |-- etc
> 
> As far as I can tell(guess), both dmd and gdc are using this one.
> 
> I installed ldc2 (using apt-get install ldc):
>ldc2 --version: LDC - the LLVM D compiler (0.17.1):
>based on DMD v2.068.2 and LLVM 3.8.0
>Default target: x86_64-pc-linux-gnu
> 
> After installing ldc2, in /usr/include a new folder, d/, was 
> created
> /usr/include/d
> |-- core
> |-- etc
> |-- ldc
> `-- std
> 
> And now, the issue:
> After the steps above, when I try to compile something using gdc, 
> it fails with the following error:
> 
> /usr/include/d/core/stdc/stdarg.d:48:5: error: undefined 
> identifier _va_list_tag
>   alias __va_list = __va_list_tag;
>   ^
> 
> Based on my previous assumtion (both dmd and gdc use 
> /usr/include/dmd/) and the error above, I am inclined to believe 
> that after installing ldc, gdc is using /usr/include/d/ and it 
> breaks.
> 
> Maybe we should consider having a separate folder in 
> /usr/include/ for each compiler?
> 
> Cheers,
> Eduard
> 

Archlinux uses /usr/include/dlang/[dmd|gdc|ldc]. Maybe debian/ubuntu
should do that as well or maybe we could even change the path in
upstream GDC.


Re: Installing ldc breaks gdc

2016-12-09 Thread Daniel Kozak via Digitalmars-d



Dne 9.12.2016 v 16:59 Eduard Staniloiu via Digitalmars-d napsal(a):

Hello, everyone.

...

Based on my previous assumtion (both dmd and gdc use 
/usr/include/dmd/) and the error above, I am inclined to believe that 
after installing ldc, gdc is using /usr/include/d/ and it breaks.


Maybe we should consider having a separate folder in /usr/include/ for 
each compiler?


Cheers,
Eduard

No thats all wrong, dmd a gdc could not use same include directory that 
is not possible. GDC use


/usr/lib/gcc/x86_64-linux-gnu/5/include/d/

LDC use

/usr/include/d/

and dmd use:

/usr/include/dmd

You probably have some misconfiguration issue



Re: How about a bounty for a new windows installer using inno setup ?

2016-12-09 Thread Kagamin via Digitalmars-d

On Friday, 9 December 2016 at 16:47:18 UTC, Jesse Phillips wrote:
An MSI can't execute an arbitrary executable, just an arbitrary 
DLL which could run an arbitrary executable :)


https://msdn.microsoft.com/en-us/library/windows/desktop/aa368563%28v=vs.85%29.aspx
 this?


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 14:29:38 UTC, unDEFER wrote:
I'm afraid that the problem that my program wants to say 
something, but there is no "flush" so message leaves in the 
buffer.


I have found, it was code like:

string path = "C:";
string parent = path[0..path.lastIndexOf("\\")];

And in mini program it works and shows diagnostic message.
Where my diagnostic message in more complicate program???


Re: How about a bounty for a new windows installer using inno setup ?

2016-12-09 Thread Jesse Phillips via Digitalmars-d

On Friday, 9 December 2016 at 10:35:00 UTC, Kagamin wrote:
On Thursday, 8 December 2016 at 20:04:01 UTC, Jesse Phillips 
wrote:
These sequences can call "Custom Actions" which are just table 
entries that point to a DLL (there is more to Custom Actions).


Why not just unpack the stuff and run a configuration program? 
The latter would be useful anyway.


An MSI can't execute an arbitrary executable, just an arbitrary 
DLL which could run an arbitrary executable :) If you're running 
an MSI for security you're screwed.


Now if you're question is why not forgo the MSI and create a 
self-extracting archive which runs a post "install" 
configuration, well then you're writing your own installer and 
will need to fully handle upgrades and uninstall (I say fully 
since even with an MSI there is still uninstall steps you must 
specify, but generally only if you're doing special install steps 
that need to be undone)


To me an MSI is a weird complicated mess, but I'm kind of 
interested to dig in and understand how the MSIexec reads and 
processes the DB (beyond the basics).


[Issue 16699] [REG 2.070] stack corruption with scope(exit)

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16699

--- Comment #31 from anonymous4  ---
The obvious solution is to create a different merge PR that will just merge and
nothing more.

--


Re: Getters/setters generator

2016-12-09 Thread Eugene Wissner via Digitalmars-d-announce

On Friday, 9 December 2016 at 12:37:58 UTC, Iakh wrote:


Is there possibility to remove affixes in generated accessor 
names?


No, there is no way to manipulate the accessor names. What 
affixes do you mean?


Installing ldc breaks gdc

2016-12-09 Thread Eduard Staniloiu via Digitalmars-d

Hello, everyone.

So I have found that installing ldc will break gdc.

The setup:

I have a VM running a 64bit Ubuntu 16.04, as you can see from the 
output of uname -a:


  Linux ubuntu-xenial 4.4.0-51-generic #72-Ubuntu SMP Thu Nov 24 
18:29:54 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


I have installed:
  dmd --version: DMD64 D Compiler v2.072.0
  gdc --version: gdc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 
20160609


With this setup, in /usr/include we can find dmd/
/usr/include/dmd
|-- druntime
|   `-- import
|   |-- core
|   |-- etc

As far as I can tell(guess), both dmd and gdc are using this one.

I installed ldc2 (using apt-get install ldc):
  ldc2 --version: LDC - the LLVM D compiler (0.17.1):
  based on DMD v2.068.2 and LLVM 3.8.0
  Default target: x86_64-pc-linux-gnu

After installing ldc2, in /usr/include a new folder, d/, was 
created

/usr/include/d
|-- core
|-- etc
|-- ldc
`-- std

And now, the issue:
After the steps above, when I try to compile something using gdc, 
it fails with the following error:


/usr/include/d/core/stdc/stdarg.d:48:5: error: undefined 
identifier _va_list_tag

 alias __va_list = __va_list_tag;
 ^

Based on my previous assumtion (both dmd and gdc use 
/usr/include/dmd/) and the error above, I am inclined to believe 
that after installing ldc, gdc is using /usr/include/d/ and it 
breaks.


Maybe we should consider having a separate folder in 
/usr/include/ for each compiler?


Cheers,
Eduard



[Issue 4125] std.numeric.gcd can use a binary GCD

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=4125

Alexandru Razvan Caciulescu  changed:

   What|Removed |Added

 CC||alexandru.razva...@gmail.co
   ||m

--- Comment #7 from Alexandru Razvan Caciulescu  
---
After conducting some benchmarks we arrived to the conclusion that currently
the dmd compiler works best with Euclid's algorithm for GCD, otherwise we use
Stein's algorithm for ldc or gdc.

I tested both the previously shared benchmarks on the forum and a couple of my
own  and noted that gcd_binary2 implemented by bearophile_h...@eml.cc has the
best results, so I used that.

PR: https://github.com/dlang/phobos/pull/4940

--


[Issue 15421] The behaviours of the topNs differ with the bottom

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15421

Andrei Alexandrescu  changed:

   What|Removed |Added

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

--


[Issue 15401] partialSort should accept two ranges

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15401
Issue 15401 depends on issue 15421, which changed state.

Issue 15421 Summary: The behaviours of the topNs differ with the bottom
https://issues.dlang.org/show_bug.cgi?id=15421

   What|Removed |Added

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

--


Re: Range of uncopyable elements

2016-12-09 Thread Jerry via Digitalmars-d-learn
On Thursday, 8 December 2016 at 23:08:35 UTC, Jonathan M Davis 
wrote:
I've seen that in C++ code all the time, especially if you're 
dealing with
smart pointers, because otherwise you have to do stuff like 
(*iter)->foo()

instead of just var->foo().


Smart pointers weren't introduced until C++11. I'm talking about 
std library code that would have to be generic. Not user code 
where the type in the iterator is known.



Except that C++ _does_ have special iterators. They're just not 
as common.


Still not as common and C++ has a way to

With the upcoming improvements to @safe and return ref, it 
_might_ happen that there will be a way for a function to 
accept rvalues by ref. Andrei has indicated that a really good 
proposal might be accepted. But that's a separate issue from 
having ref on local variables, which is what would be required 
for what you're suggesting, and both Walter and Andrei have 
been adamant that that is not worth it - even without getting 
rvalue references into the mix. I don't know that it would be 
impossible to convince them otherwise, but I would be _very_ 
surprised if anyone managed to talk them into it.


Exactly, the problem will continue to persist even if rvalue 
references are included into D. It's not well thought out, 
isInputRange reflects that.


And for the most part, with ranges, this is pretty much a 
non-issue. It does become an issue when you start worrying 
about ranges with a non-copyable front, but this is literally 
only the second or third thread that I have ever seen where 
anyone complained about it. Much as it is annoying when someone 
runs int ito, it's not a big complaint that folks have. And 
given how much of a pain it would be to deal with in general, I 
seriously question that it's worth it - especially when simply 
using pointers fixes the problem.


That's not an acceptable workaround. It complicates code for no 
reason. If that's the decision that is going to be accepted. Then 
there should be helper functions included in the standard to 
reflect that.




Re: CTFE Status

2016-12-09 Thread Faux Amis via Digitalmars-d

On 2016-12-09 00:00, Stefan Koch wrote:

On Thursday, 8 December 2016 at 19:49:47 UTC, Faux Amis wrote:

Any reason for the infinite depth update posting style?
I would have loved to see each update to be a child of the root post
with its own discussions tree.
Currently, the posts are quite unreadable in tree view (thunderbird).


On 2016-10-31 14:29, Stefan Koch wrote:

Hi Guys, since I got a few complaints about giving minor status updates
in the announce group, I am opening this thread.


The reason it that I don't use the tree view.
I just answer to myself every time I have an update.
It looks fine on the web-frontend.


Might you consider making use of the tree data structure?
It really has quite nice properties with regard to discussions..
(check the threaded view mode, everybody else seems to use it like that)
Anyway, I kinda missed the updates because I thought it was just a very 
deep discussion until I noticed it was mostly you posting ;)






Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
I'm afraid that the problem that my program wants to say 
something, but there is no "flush" so message leaves in the 
buffer.


Re: Getters/setters generator

2016-12-09 Thread Iakh via Digitalmars-d-announce

mixin template GenerateFieldAccessorMethods()
{
static enum GenerateFieldAccessorMethods()
{
string result = "";
return result;
}
}

Strange syntax


Re: Getters/setters generator

2016-12-09 Thread Iakh via Digitalmars-d-announce

On Friday, 9 December 2016 at 10:27:05 UTC, Eugene Wissner wrote:

Hello,

we've just open sourced a small module ("accessors") that helps 
to generate getters and setters automatically:

https://github.com/funkwerk/accessors
http://code.dlang.org/packages/accessors

It takes advantage of the UDAs and mixins. A simple example 
would be:


import accessors;

class WithAccessors
{
@Read @Write
private int num_;

mixin(GenerateFieldAccessors);
}

It would generate 2 methods "num": one to set num_ and one to 
get its value. Of cause you can generate only @Read without 
@Write and vice versa. There are some more features, you can 
find the full documentation in the README.
"GenerateFieldAccessors" mixin should be added into each 
class/struct that wants to use auto generated accessors.


Is there possibility to remove affixes in generated accessor 
names?


[Issue 6133] Improvements to RedBlackTree

2016-12-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6133

--- Comment #2 from Carlos Ballesteros Velasco  ---
@Infiltrator Probably it changed to not be compatible. But you can find the
original collection in the git history here, if you want to try to merge or PR
it:
https://github.com/soywiz/smrr-server/blob/8c89dd5120009880eb82663f161fa9dff0f6a983/server/smr/excollections.d

--


Re: @property

2016-12-09 Thread ArturG via Digitalmars-d-learn
My issue isn't about @property, it just shows 3 cases where i 
think that dmd is missing a check for alias this.


Even if D didnt had @property or parentesis less function call,
due to alias opCall this it should be possible to call opCall 
without parentesis.




Re: [OT] Interesting blog post on disadvantages of the pure functional paradigm

2016-12-09 Thread Kagamin via Digitalmars-d

On Friday, 9 December 2016 at 10:01:13 UTC, qznc wrote:

http://beza1e1.tuxen.de/articles/functional.html


What about python and javascript?


Getters/setters generator

2016-12-09 Thread Eugene Wissner via Digitalmars-d-announce

Hello,

we've just open sourced a small module ("accessors") that helps 
to generate getters and setters automatically:

https://github.com/funkwerk/accessors
http://code.dlang.org/packages/accessors

It takes advantage of the UDAs and mixins. A simple example would 
be:


import accessors;

class WithAccessors
{
@Read @Write
private int num_;

mixin(GenerateFieldAccessors);
}

It would generate 2 methods "num": one to set num_ and one to get 
its value. Of cause you can generate only @Read without @Write 
and vice versa. There are some more features, you can find the 
full documentation in the README.
"GenerateFieldAccessors" mixin should be added into each 
class/struct that wants to use auto generated accessors.


Re: How about a bounty for a new windows installer using inno setup ?

2016-12-09 Thread Kagamin via Digitalmars-d
On Thursday, 8 December 2016 at 20:04:01 UTC, Jesse Phillips 
wrote:
These sequences can call "Custom Actions" which are just table 
entries that point to a DLL (there is more to Custom Actions).


Why not just unpack the stuff and run a configuration program? 
The latter would be useful anyway.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 10:08:24 UTC, unDEFER wrote:

On Friday, 9 December 2016 at 09:42:52 UTC, unDEFER wrote:
Exceptions works good, and prints debug message always. It is 
not exception..
I have tried to add try/catch around full loop of the program. 
It doesn't work. And program has infinite loop.

But maybe it is unhandled signal?


I have found. It exits on "stdout.flush()"


Without flush falls in different places.. And in the console 
leaves not fully printed lines.


Re: [OT] Interesting blog post on disadvantages of the pure functional paradigm

2016-12-09 Thread Kagamin via Digitalmars-d

On Friday, 9 December 2016 at 10:01:13 UTC, qznc wrote:
What is your definition of Functional Programming? Mine: 
http://beza1e1.tuxen.de/articles/functional.html


I think, it's more about being declarative.


Re: @property

2016-12-09 Thread Satoshi via Digitalmars-d-learn
On Thursday, 8 December 2016 at 22:09:14 UTC, Jonathan M Davis 
wrote:
On Thursday, December 08, 2016 16:54:57 Adam D. Ruppe via 
Digitalmars-d- learn wrote:

[...]


Yeah, it's pretty common for folks to slap @property on 
functions to make it clear that it's intended to be used as a 
property and thus is a getter or setter. So, it serves a 
purpose from the standpoint of documentation. But at this 
point, it doesn't make much differently on the technical level. 
The differences with typeof and stuff like 
std.traits.FunctionAttributes are what would be different. You 
can use the property syntax whether @property was used or not.


[...]



Thank you very much for your detailed explanation.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

On Friday, 9 December 2016 at 09:42:52 UTC, unDEFER wrote:
Exceptions works good, and prints debug message always. It is 
not exception..
I have tried to add try/catch around full loop of the program. 
It doesn't work. And program has infinite loop.

But maybe it is unhandled signal?


I have found. It exits on "stdout.flush()"


Re: [OT] Interesting blog post on disadvantages of the pure functional paradigm

2016-12-09 Thread qznc via Digitalmars-d

On Friday, 9 December 2016 at 09:58:27 UTC, Kagamin wrote:

Functional doesn't imply purity and immutability


I disagree.

What is your definition of Functional Programming? Mine: 
http://beza1e1.tuxen.de/articles/functional.html




Re: [OT] Interesting blog post on disadvantages of the pure functional paradigm

2016-12-09 Thread Kagamin via Digitalmars-d
Functional doesn't imply purity and immutability, and mutable 
functional has cognitive problems: mutation is important, but 
functional code is too high level, so whatever happens is hidden 
from the programmer; D suffers from this too as people are 
confused whether ranges are taken by value or by reference - this 
is important because they are mutable.


Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 09:29:36 UTC, rikki cattermole 
wrote:

On 09/12/2016 10:26 PM, unDEFER wrote:
An exception/error might be thrown, try catching Error's in the 
threads function.

Also try adding an infinite loop to it.


Exceptions works good, and prints debug message always. It is not 
exception..
I have tried to add try/catch around full loop of the program. It 
doesn't work. And program has infinite loop.

But maybe it is unhandled signal?


Re: The program exits unexpectedly

2016-12-09 Thread rikki cattermole via Digitalmars-d-learn

On 09/12/2016 10:26 PM, unDEFER wrote:

Hello!
I'm starting port my program to Windows _without_ Cygwin and found big
trouble.
My main thread exits unexpectedly without any diagnostic messages. The
second thread still lives when it happens.
The visual studio debugger say that thread exits with code 2.
What it maybe?


An exception/error might be thrown, try catching Error's in the threads 
function.

Also try adding an infinite loop to it.


The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn

Hello!
I'm starting port my program to Windows _without_ Cygwin and 
found big trouble.
My main thread exits unexpectedly without any diagnostic 
messages. The second thread still lives when it happens.

The visual studio debugger say that thread exits with code 2.
What it maybe?