Re: Wich: opIndex overloading by return type

2020-04-19 Thread unDEFER via Digitalmars-d-learn
It is easy. You can make both types as children of common parent 
class myT, and when return myT.


Re: How to build dmd properly?

2018-12-18 Thread unDEFER via Digitalmars-d-learn

On Tuesday, 18 December 2018 at 16:19:33 UTC, unDEFER wrote:
Yes, thank you for the hint. You are almost right. I did not 
ENABLE_DEBUG=1, but I also did not ENABLE_RELEASE=1


So it is the bug. I will report about it.


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


Re: How to build dmd properly?

2018-12-18 Thread unDEFER via Digitalmars-d-learn

On Tuesday, 18 December 2018 at 15:54:28 UTC, Seb wrote:

On Tuesday, 18 December 2018 at 14:35:46 UTC, unDEFER wrote:

What I could build wrong and how to build dmd properly?


Maybe you built dmd.d with debug assertions? (ENABLE_DEBUG=1)

You can build dmd with the `./build.d` script or `make -f 
posix.mak -j4` (assuming you are in `src).


Anyway, the internal assertions should never fail, so this 
definitely deserves a bug report if that was the case.


Yes, thank you for the hint. You are almost right. I did not 
ENABLE_DEBUG=1, but I also did not ENABLE_RELEASE=1


So it is the bug. I will report about it.


How to build dmd properly?

2018-12-18 Thread unDEFER via Digitalmars-d-learn

Hello, I have the next code (minimized with DustMite):

struct Tup(T...)
{
bool opEquals() {
foreach (i; T)
static if (__traits(compiles, mixin("new 
InputRangeObject11261!(abs_class)")))

msg;
}
}

/**/

void test3()
{
Tup!(int, double) ;
}

interface InputRange11261(E)
{
}
template InputRangeObject11261(R)
{
alias typeof(init.front()) E;

class InputRangeObject11261 : InputRange11261!E
{
}
}

class abs_class
{
}


The problem that I'm compiling dmd v2.083.1 and the version which 
built I gives me the next error:


---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the 
information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help 
with the reduction.

---
DMD v2.083.1
predefs   DigitalMars Posix linux ELFv1 CRuntime_Glibc 
CppRuntime_Gcc LittleEndian D_Version2 all D_SIMD 
D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_ModuleInfo 
D_Exceptions D_TypeInfo D_HardFloat

binarydmd
version   v2.083.1
config
/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/dmd.conf
DFLAGS
-I/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/../../../../../druntime/import -I/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/../../../../../phobos -L-L/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC

---
core.exception.AssertError@dmd/dsymbolsem.d(5356): Assertion 
failure


??:? _d_assertp [0xf0233ed]
dmd/dsymbolsem.d:5356 
_ZN22DsymbolSemanticVisitor5visitEP20InterfaceDeclaration 
[0xee4c9a0]
dmd/dclass.d:1129 _ZN20InterfaceDeclaration6acceptEP7Visitor 
[0xee0a439]
dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope 
[0xee3d538]
dmd/dtemplate.d:7427 void 
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) 
[0xee5ff53]
dmd/dtemplate.d:7445 void 
dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*) [0xee5ffca]
dmd/dsymbolsem.d:5671 void 
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) [0xee4d3ce]
dmd/dsymbolsem.d:2573 
_ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance [0xee443be]
dmd/dtemplate.d:7474 _ZN16TemplateInstance6acceptEP7Visitor 
[0xee60085]
dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope 
[0xee3d538]
dmd/typesem.d:2676 _ZN14ResolveVisitor5visitEP12TypeInstance 
[0xef1399c]

dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519]
dmd/typesem.d:2418 void dmd.typesem.resolve(dmd.mtype.Type, ref 
const(dmd.globals.Loc), dmd.dscope.Scope*, 
dmd.expression.Expression*, dmd.mtype.Type*, 
dmd.dsymbol.Dsymbol*, bool) [0xef12f1f]
dmd/typesem.d:1608 _ZN19TypeSemanticVisitor5visitEP12TypeInstance 
[0xef113e8]

dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519]
dmd/typesem.d:533 _Z12typeSemanticP4Type3LocP5Scope [0xef0e0b6]
dmd/dsymbolsem.d:4515 pure @nogc @safe dmd.mtype.Type 
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).__dgliteral2() [0xee4ba59]
dmd/dsymbolsem.d:4497 dmd.mtype.Type 
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).resolveBase!(dmd.mtype.Type).resolveBase(lazy dmd.mtype.Type) [0xee4e220]
dmd/dsymbolsem.d:4515 
_ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration [0xee49cc4]
dmd/dclass.d:986 _ZN16ClassDeclaration6acceptEP7Visitor 
[0xee0a00d]
dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope 
[0xee3d538]
dmd/dtemplate.d:7427 void 
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) 
[0xee5ff53]
dmd/dtemplate.d:7445 void 
dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*) [0xee5ffca]
dmd/dsymbolsem.d:5671 void 
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) [0xee4d3ce]
dmd/dsymbolsem.d:2573 
_ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance [0xee443be]
dmd/dtemplate.d:7474 _ZN16TemplateInstance6acceptEP7Visitor 
[0xee60085]
dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope 
[0xee3d538]
dmd/typesem.d:2676 _ZN14ResolveVisitor5visitEP12TypeInstance 
[0xef1399c]

dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519]
dmd/typesem.d:2418 void dmd.typesem.resolve(dmd.mtype.Type, ref 
const(dmd.globals.Loc), dmd.dscope.Scope*, 
dmd.expression.Expression*, dmd.mtype.Type*, 
dmd.dsymbol.Dsymbol*, bool) [0xef12f1f]
dmd/typesem.d:1608 _ZN19TypeSemanticVisitor5visitEP12TypeInstance 
[0xef113e8]

dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519]
dmd/typesem.d:533 _Z12typeSemanticP4Type3LocP5Scope [0xef0e0b6]
dmd/expressionsem.d:3094 
_ZN25ExpressionSemanticVisitor5visitEP6NewExp [0xee7cb92]

dmd/expression.d:3171 

Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn

So it looks like a bug, and I have reported about it:

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


Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn

So more digging..
dtor of Thread calls in GC.collect() if thread is finished.
But it's do nothing because

bool not_registered = !next && !prev && (sm_tbeg !is this);

is always true... So how to register the thread?


Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn
So in digging by this problem, I have made simple patch to 
druntime. I have added in druntime/src/core/thread.d to


final Thread start() nothrow

of class Thread

import core.stdc.stdio;
printf("start Thread\n");


And to

~this() nothrow @nogc

import core.stdc.stdio;
printf("detach Thread\n");

I recompiled phobos to apply changes to druntime and I see that 
"start Thread" there is, but "detach Thread" printed only at the 
end of process even if I do GC.collect().


So dtor of class Thread doesn't call on GC. Why?


Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn

Hello!
I have the program which uses BDB and while testing often makes 
spawn. And after 12 hours of testing bdb said:

mmap: Cannot allocate memory

But the problem that I've found that it is not BDB created too 
many maps. Watching for /proc/[PID]/maps shows that number of 
anonymous mapped regions increases on 2 every spawn process, and 
never decreases even after finishing the spawned thread.
According to logs my program made 32543 spawns for test time. And 
my /proc/sys/vm/max_map_count = 65530. So only 444 maps was 
allocated by other reasons and 65086 by spawn.


So what to do? How to make spawn decrease count of anonymous 
mapped regions?


Dizzy Omega 0.37

2018-12-01 Thread unDEFER via Digitalmars-d-announce

Hello, everyone!
I have done the second demo version of my game fully written in D.

Dizzy is a puzzle game, Purpose of which is the collection and 
use of items.
Dizzy Omega (Dizzy on Mars) is the sequel of the game Dizzy Y 
(which was for ZX-Spectrum).


The game has 3D graphic, but 2D logic.

The second demo has 53 screens, 39 items, 32 from which you can 
use. Some of them several times.


Site of the project: https://dizzy-omega.sourceforge.io


Re: How to debug FinalizeError?

2018-11-29 Thread unDEFER via Digitalmars-d-learn
On Thursday, 29 November 2018 at 14:51:40 UTC, Steven 
Schveighoffer wrote:
You need to compile druntime in debug mode. One thing you can 
do is implement the function locally, and then break on it 
(it's a C linkage, so I think the linker will grab your copy 
instead of the one in druntime)


i.e. in your code, do:

extern(C) void onFinalizeError(TypeInfo info, Throwable e, 
string file = __FILE__, size_t line = __LINE__)

{
   import core.stdc.stdio;
   printf("break here\n");
}


Big thanks, Steve. I will try it. Every night will do debugging 
and maybe at one night it will happen again :-)


Re: How to debug FinalizeError?

2018-11-28 Thread unDEFER via Digitalmars-d-learn
No I'm not preallocating any exceptions. It was idea, but I 
removed all calls which can make throw.
I'm using very old dmd 2.074.1, so as I have patched it for my 
text editor with IDE functions. I had a year break in 
development, so now I need to rewrite all my patches.

But exactly the output of my program looks like this:

core.exception.FinalizeError@src/rt/lifetime.d(1407): 
Finalization error


=== Bypassed ===

 BerkeleyDB exceptions mixed with output of 
destructors ||


core.exception.InvalidMemoryOperationError@src/core/exception.d(696): Invalid 
memory operation


It means that "Invalid memory operation" occurred earlier than 
"Finalization error"?
The line on which shows the pointer src/rt/lifetime.d(1407) is 
exactly:

onFinalizeError(*pc, e);
Why gdb doesn't see this function?

My program (the text editor) had run test all night under gdb 
with break on InvalidMemoryOperationError and didn't fall. So it 
is very-very-very hard to reproduce.
And I haven't ideas where maybe this throw. At least I don't see 
any throw in explicit form.


Re: derelict-sdl2 automatically stripping the SDL_ prefix from names

2018-11-28 Thread unDEFER via Digitalmars-d-learn
Hello, as I know allMembers returns members not recursively. If 
you want to get really all members you need to make recursive 
function. In my program I used the next routine to print all 
members of module:


static void allMembersOfModule(string module_name, bool 
root=false)()

{
static if (module_name != "object" &&
module_name != __MODULE__)
{
mixin("import "~module_name~";");

pragma(msg, module_name~":");

foreach(member; __traits(allMembers, mixin(module_name)))
{
static if (__traits(compiles, mixin(member)) &&
(!__traits(compiles, __traits(getProtection, 
mixin(member))) ||
__traits(getProtection, mixin(member)) != 
"private" &&
__traits(getProtection, mixin(member)) != 
"package"))

pragma(msg, member);
}

static if (root || module_name == "std.algorithm" || 
module_name == "std.range")

{
import std.algorithm.searching: startsWith;

foreach(member; __traits(allMembers, 
mixin(module_name)))

{
static if (__traits(compiles, mixin(member)) &&
__traits(compiles, 
mixin(member).stringof.startsWith("module ")) &&

mixin(member).stringof.startsWith("module "))
{
allMembersOfModule!(member);
}
}
}
}
}

As I know it worked good. Maybe it helps to you also.


How to debug FinalizeError?

2018-11-28 Thread unDEFER via Digitalmars-d-learn
Hello! After long-long time of debugging, I just have decided 
InvalidMemoryOperationError in my program. But now my program 
after few hours of testing again crashes with "Finalization 
error".


What this error means exactly? I again did something wrong in 
destructor?
And how to debug it? I tried "break onFinalizeError" in gdb like 
"break onInvalidMemoryOperationError", but it says:


Function "onFinalizeError" not defined.

There are too few information about this error in documentation 
and forum, and I didn't find anything about it in wiki.


Thank you.


Re: Usage of memory by arrays

2018-04-05 Thread unDEFER via Digitalmars-d

So, I completely found all answers.
In my game of 260 Mb:
100 Mb consumes GC,
100 Mb consumes scene in glNewList.
And 30 Mb textures in glTexImage2D.

Very well, now I know what to do and how to get it smaller.
Big thanks to all.


Re: Usage of memory by arrays

2018-04-05 Thread unDEFER via Digitalmars-d
On Thursday, 5 April 2018 at 22:23:12 UTC, Steven Schveighoffer 
wrote:
1. Compare to C malloc-ing 1.2MB at once (GC uses C malloc 
underneath)


Yes after initialize malloc'ed 1.2Mb in C it consumes 1.6 Mb. 4.8 
Mb => 4.9 Mb


2. Have you examined smaller numbers for total? Does it scale 
linearly or is there a threshold? (my guess is the latter)


OK, if total = 1000 the last test shows 12916 Kbytes. It's fine.

Note that the GC does keep some metadata, but it's 1/32 the 
size of the actual memory, so I'm not sure it's relevant here.


Is there an end goal for this exercise? That is, did you find a 
problem and are trying to diagnose it by using this test? Maybe 
if we know the real problem you are having, it can be explained 
differently.


I just don't like that my game application takes too much memory.
I will think more.


Re: Usage of memory by arrays

2018-04-05 Thread unDEFER via Digitalmars-d

On Thursday, 5 April 2018 at 22:06:10 UTC, Jonathan M Davis wrote:

You could also look at how x.capacity compares to x.length as 
well as core.memory.GC.stats() to see what the GC thinks that 
it's using. On my system, the x.capacity was only 9 greater 
than x.length, and GC.stats printed as


Yes, capacity for me also have only 9 greater.
So.. in my game GS.stats() shows 105 Mb, but the system shows 320 
Mb of usage memory by the process...
The same under Windows. Really don't understand what this all 
means.


Re: Usage of memory by arrays

2018-04-05 Thread unDEFER via Digitalmars-d

OK, without reallocation:

8<
void main()
{
float[3] f;
float[3][] x;
writefln("float = %s bytes", float.sizeof);
writefln("float[3] = %s bytes", f.sizeof);

int before = MemoryUsage();

int total = 100;
x = new float[3][total*1000];

int after = MemoryUsage();
writefln("%dK * float[3] = %d Kbytes", total, (after-before));
}
>8

$ ./memory
float = 4 bytes
float[3] = 12 bytes
100K * float[3] = 2300 Kbytes

Why this so?


Re: Usage of memory by arrays

2018-04-05 Thread unDEFER via Digitalmars-d
On Thursday, 5 April 2018 at 21:11:53 UTC, Steven Schveighoffer 
wrote:


But the old block doesn't go away! It's collected and stored in 
a free list for future allocations.


-Steve


Big thanks, -Steve! Really program like the next:

==8<==
void main()
{
float[3] f;
float[3][] x;
float[3][] y;
writefln("float = %s bytes", float.sizeof);
writefln("float[3] = %s bytes", f.sizeof);

int total = 200;
foreach(i; 0..total)
{
foreach (j; 0..1000)
{
x ~= [0.01, 0.02, 0.03];
}
}

int before = MemoryUsage();
foreach(i; 0..total/2)
{
foreach (j; 0..1000)
{
y ~= [0.01, 0.02, 0.03];
}
}
int after = MemoryUsage();
writefln("%dK * float[3] = %d Kbytes", total/2, 
(after-before));

}
==>8==

Prints:
float = 4 bytes
float[3] = 12 bytes
100K * float[3] = 1320 Kbytes

Very well. I'm thinking how to optimize my game program to not be 
"pathological" on loading the models.


Usage of memory by arrays

2018-04-05 Thread unDEFER via Digitalmars-d

Hello!
Here very simple test program:
--->8
import std.conv;
import std.stdio;

import std.string;

int MemoryUsage()
{
auto file = File("/proc/self/status");
foreach (line; file.byLine())
{
if (line[0..6] == "VmRSS:")
{
return line[7..$-3].strip().to!(int);
}
}
return 0;
}

void main()
{
float[3] f;
float[3][] x;
writefln("float = %s bytes", float.sizeof);
writefln("float[3] = %s bytes", f.sizeof);

int before = MemoryUsage();

int total = 100;
foreach(i; 0..total)
{
foreach (j; 0..1000)
{
x ~= [0.01, 0.02, 0.03];
}
}

int after = MemoryUsage();
writefln("%dK * float[3] = %d Kbytes", total, (after-before));
}
---8<

It prints:
$ ./memory
float = 4 bytes
float[3] = 12 bytes
100K * float[3] = 2356 Kbytes

Why not 1200 Kbytes?


Re: Dizzy Omega 0.17

2018-04-05 Thread unDEFER via Digitalmars-d-announce

On Thursday, 5 April 2018 at 14:33:16 UTC, ashit axar wrote:


do i need to install derelict ?
im using windows7


No, You don't need derelict (it is needed only at compile time 
and dub downloads it automatically).. Which video card you have? 
Maybe you tried run any other OpenGL games?


Dizzy Omega 0.17

2018-04-04 Thread unDEFER via Digitalmars-d-announce

I have done the first demo version of my game fully written in D.

Dizzy is a puzzle game, Purpose of which is the collection and 
use of items.
Dizzy Omega (Dizzy on Mars) is the sequel of the game Dizzy Y 
(which was for ZX-Spectrum).


The game has 3D graphic, but 2D logic.

The first demo has 24 screens, 17 items, 9 from which you can 
use. Some of them several times.


Site of the project: https://dizzy-omega.sourceforge.io


Re: Hacking the compiler: Get Scope after some line of function

2017-07-27 Thread unDEFER via Digitalmars-d-learn

On Thursday, 27 July 2017 at 11:59:51 UTC, unDEFER wrote:

So how to get scope e.g. after line "B b;"?


I have found. That in scopes was found symbols from declarations, 
you must iterate by declarations (DeclarationExp) and add symbols 
by sc.insert(decexp.declaration);


Hacking the compiler: Get Scope after some line of function

2017-07-27 Thread unDEFER via Digitalmars-d-learn
Hello! I'm trying to do some strange thing: compile some 
Statement (do semantic3 phase) in the scope of other function.

Other function is for example:

auto megafunction()
{
B b;
uint a = 25;
return b;
}

AST of this code looks like:

FuncDeclaration
{
fbody = CompoundStatement
{
 ExpStatement
 {
 exp = DeclarationExp
 }
 ExpStatement
 {
 exp = DeclarationExp
 }
 ReturnStatement;
}
}

So if I'm trying to take fbody._scope, all works correctly (other 
functions and templates from this module are declared), but 
neither a nor b are declared in this scope.

But exp.declaration._scope is null.

So how to get scope e.g. after line "B b;"?


Re: How to make autocompletion for IDE?

2017-07-26 Thread unDEFER via Digitalmars-d-learn

On Wednesday, 26 July 2017 at 07:41:20 UTC, Andrea Fontana wrote:

Did you try with [1]?

[1] http://forum.dlang.org/post/okktlu$2bin$1...@digitalmars.com


Thank you, interesting. But I'm afraid it is not enough.


Re: Cast to subclass in the dmd compiler

2017-07-26 Thread unDEFER via Digitalmars-d-learn

On Wednesday, 26 July 2017 at 06:50:21 UTC, Jacob Carlborg wrote:
For Expression, there's a field called "op" that indicates what 
kind of expression it is, which can used in combination with a 
cast.


Thank you for hint!


Re: Cast to subclass in the dmd compiler

2017-07-25 Thread unDEFER via Digitalmars-d-learn

I have found the answer in the code.
Right code is:

Import imp = m.isImport();
if (imp !is null)

Thank you.


Cast to subclass in the dmd compiler

2017-07-25 Thread unDEFER via Digitalmars-d-learn

Hello!
I'm hacking dmd compiler and trying to look on members array just 
after parse module.


for(uint i = 0; i < members.dim; i++)
{
 Dsymbol m = (*members)[i];

// It is good, but further:

Import imp = cast(Import) m;
if (imp !is null)
{
printf(" import %s.%s\n", imp.packages.toChars(), 
imp.id.toChars());

}
// ...
}

For really imports casting doing well. But for not imports it 
again casts, imp not is null and  the compiler crashes.

What I'm doing wrong?


Re: How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn

On Tuesday, 25 July 2017 at 10:42:40 UTC, Basile B. wrote:

I think that you underestimate the amount of work needed and 
your solution which is to use the compiler with -o- looks bad. 
What you really need is a compiler front-end which is basically 
what libdparse + DSymbol are. DCD uses them.


No, with feature like
auto func()
and
void templ(T)(T a)
if (is(a))
{}

It is impossible to consider all it by myself. It means write the 
second compiler.

So I just want to use the ready compiler.


Re: How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn

On Tuesday, 25 July 2017 at 10:35:14 UTC, Andrea Fontana wrote:

If you want to add UFCS suggestions to DCD it would be useful 
for your project and all other IDEs too!


Andrea


Thank you, I will think. But if it was easy, authors self would 
do it :-)


Re: How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn

On Tuesday, 25 July 2017 at 10:24:13 UTC, Andrea Fontana wrote:

On Tuesday, 25 July 2017 at 10:23:33 UTC, Andrea Fontana wrote:

On Tuesday, 25 July 2017 at 10:06:47 UTC, unDEFER wrote:

Any ideas?


I think you should use/contribute to DCD project
https://github.com/dlang-community/DCC

Andrea


Sorry, this is the right link:
https://github.com/dlang-community/DCD


Yes this project where "Not working: UFCS suggestions and That 
one feature that you REALLY needed".. I want to have all features 
that I really need :-)
But If I will not find how do UFCS suggestions fast, I probably 
will use DCD for all other things..


How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn

Hello!
I have written my text editor with highlighting, and now I want 
to add IDE features to it.
I want to make autocompletion, but not only complete members of 
class/struct, but also all functions which maybe used with type, 
if the first argument of the function is this type. I.e. in 
"a".fromStringz() style instead of fromStringz(a).


For it I will take editable now sources, add to it lines like 
this:


  foreach(d; __traits(allMembers, std.string))
  {
  if (is(typeof(mixin("\"abc\"."~d~"()"
  pragma(msg, "\"abc\"."~d~"()" );
  }

So it will print all methods which can be called for strings as 
"abc".function().

And I want to compile this file with options "-c -o-".
The problem that compilation for files with avarage count of 
imports may take e.g. 7 seconds..


7 seconds is too long to wait autocompletion.
But compiler really do this "task" with autocompletion requests 
very fast.


And I think how to implement the next:
Add the task to some other file task.d. import it to the first 
file with mixin(import("task.d")). Change syscall open() to my 
function which if will see that it opens "task.d" waiting the 
time when user will ask autocomplete (press Ctrl-space), and then 
write the task to "task.d" and continue execution of compiler...


The problem that I see in this conception is that seems not 
possible write such import which will be imported only when 
compiler starts handle templates and simultaneously in the place 
where will be accessed all local variables of a function.


Any ideas?


Re: regex(q"<[^]>")

2017-07-19 Thread unDEFER via Digitalmars-d
On Wednesday, 19 July 2017 at 16:59:24 UTC, Dmitry Olshansky 
wrote:

On Monday, 17 July 2017 at 17:00:10 UTC, unDEFER wrote:

Please file at:
issues.dlang.org

Thanks!

---
Dmitry Olshansky


Thank you,
https://issues.dlang.org/show_bug.cgi?id=17668
https://issues.dlang.org/show_bug.cgi?id=17667


Re: regex(q"<[^]>")

2017-07-18 Thread unDEFER via Digitalmars-d

On Tuesday, 18 July 2017 at 08:56:12 UTC, Anton Fediushin wrote:
Not a bug, but I think that `regex()` should fail with a nice 
exception, not silently fail.


Yes, exception, not assert.


Re: regex(q"<[^]>")

2017-07-17 Thread unDEFER via Digitalmars-d

On Monday, 17 July 2017 at 20:43:29 UTC, unDEFER wrote:

Sorry, fixed in the newest DMD also as the other bug in regex...


Oh, no. Not fixed. Fixed only other bug.


Re: regex(q"<[^]>")

2017-07-17 Thread unDEFER via Digitalmars-d

Sorry, fixed in the newest DMD also as the other bug in regex...


regex(q"<[^]>")

2017-07-17 Thread unDEFER via Digitalmars-d

Hello!
The code in the header leads to assertion!
But the user inputed data don't must leads to any assertions!


Re: Too slow readln

2017-07-16 Thread unDEFER via Digitalmars-d-learn
I understand the main problem. dirEntries by default follows 
symlinks.

Without it my first grep works only 28.338s. That really cool!


Re: Too slow readln

2017-07-16 Thread unDEFER via Digitalmars-d-learn

On Sunday, 16 July 2017 at 17:37:34 UTC, Jon Degenhardt wrote:

On Sunday, 16 July 2017 at 17:03:27 UTC, unDEFER wrote:

[snip]

How to write in D grep not slower than GNU grep?


GNU grep is pretty fast, it's tough to beat it reading one line 
at a time. That's because it can play a bit of a trick and do 
the initial match ignoring line boundaries and correct line 
boundaries later. There's a good discussion in this thread 
("Why GNU grep is fast" by Mike Haertel): 
https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html


--Jon


Thank you. I understand yet another trick:
$ find . -exec file -bi {} +
is the same
$ file -bi `find .`


Too slow readln

2017-07-16 Thread unDEFER via Digitalmars-d-learn

Hello, there!

I have the next "grep" code:
https://dpaste.dzfl.pl/7b7273f96ab2

And I have the directory to run it:
$ time /home/undefer/MyFiles/Projects/TEST/D/grep "HELLO" .
./strace.log: [pid 18365] write(1, "HELLO\n", 6HELLO

real1m17.096s
user0m54.828s
sys 0m13.340s

The same result I get with ldc2..

The same with bash and grep:
$ time for i in `find .`; do file -b "$i" | grep -q text && grep 
-a "HELLO" "$i"; done

[pid 18365] write(1, "HELLO\n", 6HELLO

real0m42.461s
user0m23.244s
sys 0m22.300s

Only `file` for all files:
$ time find . -exec file {} + >/dev/null

real0m15.013s
user0m14.556s
sys 0m0.436s

Only grep for all files:
$ for i in `find .`; do file -b "$i" | grep -q text && echo "$i"; 
done > LIST1

$ time for i in `cat LIST1`; do grep -a "HELLO" "$i"; done
[pid 18365] write(1, "HELLO\n", 6HELLO

real0m4.431s
user0m1.112s
sys 0m3.148s

So 15+4.4 much lesser than 42.46. Why? How "find" so fast can run 
"file" so many times?

And why 42.461s much lesser 1m17.096s?

The second version of grep:
https://dpaste.dzfl.pl/9db5bc2f0a26

$ time /home/undefer/MyFiles/Projects/TEST/D/grep2 "HELLO" `cat 
LIST1`

./strace.log: [pid 18365] write(1, "HELLO\n", 6HELLO

real0m1.871s
user0m1.824s
sys 0m0.048s

$ time grep -a "HELLO" `cat LIST1`
./strace.log:[pid 18365] write(1, "HELLO\n", 6HELLO

real0m0.075s
user0m0.044s
sys 0m0.028s

The profiler says that readln eats CPU. So why 0m0.075s much 
lesser 0m1.871s?


How to write in D grep not slower than GNU grep?


Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Thank you. I will write if will find the reason of description 
corruption.


Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn

Seems I have found. I must do:
try{
File file;
try {
file = File(path);
}
catch (Exception exp)
{
return;
}

//Some actions with file
}
catch (ErrnoException)
{
return;
}




Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn

On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote:
Where does that `File` come from? If it's std.stdio.File, that 
one is a struct with internal reference counting, so it 
shouldn't crash in the above. Could you provide a minimal 
working (in this case crashing) example?


Yes File is std.stdio.File. And I can't provide a minimal 
crashing example because this code crashes very rarely.


I just want to put try/catch and don't know where to do it.


Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn

What the God? I was not ready to post...

File file;
try {
file = File(path);
}
catch (Exception exp)
{
return;
}

try {
//Some actions with file
}
catch (ErrnoException)
{
return;
}


catch (ErrnoException) is necessary because there is sometimes 
"Bad file descriptor" error.
But now I have "Bad descriptior" in destructor. Where I must put 
my try/catch section to avoid it?


Thank you!


Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn

Hello! I have the code like this:

File file;
try {
file = File(path);
}
catch (Exception exp)
{
return;
}

...
try {

}


Re: How to write Good IDE?

2017-02-05 Thread unDEFER via Digitalmars-d

On Sunday, 5 February 2017 at 17:11:02 UTC, MGW wrote:

On Sunday, 5 February 2017 at 16:16:42 UTC, unDEFER wrote:

On Sunday, 5 February 2017 at 14:37:48 UTC, MGW wrote:



Can't load libQtE5Widgets64.so from current directory.
Tried
$ export LD_LIBRARY_PATH=`pwd`; ./ide5 -i pr1.ini
$ export LIBRARY_PATH=`pwd`; ./ide5 -i pr1.ini
$ sudo ldconfig `pwd`

Nothing helps..


Existence of Qt-5, including QScript is necessary. You have to 
provide existence of dependent libraries.


I have:
./libQtE5Widgets64.so: 
/usr/lib/x86_64-linux-gnu/libQt5Script.so.5: version `Qt_5' not 
found (required by ./libQtE5Widgets64.so)
./libQtE5Widgets64.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: 
version `Qt_5.6' not found (required by ./libQtE5Widgets64.so)
./libQtE5Widgets64.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: 
version `Qt_5' not found (required by ./libQtE5Widgets64.so)
./libQtE5Widgets64.so: 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5: version `Qt_5' not 
found (required by ./libQtE5Widgets64.so)
./libQtE5Widgets64.so: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: 
version `Qt_5' not found (required by ./libQtE5Widgets64.so)


Although e.g.
$ ls -l /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
lrwxrwxrwx 1 root root 21 ноя 30  2015 
/usr/lib/x86_64-linux-gnu/libQt5Script.so.5 -> 
libQt5Script.so.5.5.1

$ ls -l /usr/lib/x86_64-linux-gnu/libQt5Script.so.5.5.1
-rw-r--r-- 1 root root 2508384 ноя 30  2015 
/usr/lib/x86_64-linux-gnu/libQt5Script.so.5.5.1


Seems you want Qt 5.6


Re: How to write Good IDE?

2017-02-05 Thread unDEFER via Digitalmars-d

On Sunday, 5 February 2017 at 14:37:48 UTC, MGW wrote:

On Sunday, 5 February 2017 at 10:43:38 UTC, unDEFER wrote:

$ dmd ide5 qte5 qte5prs asc1251 ini -release -m64
ide5.d(130): Error: undefined identifier 'Highlighter', did 
you mean variable 'highlighter'?

Скорее всего qte5.d взята из примеров, а правильная есть:
QtE5-master/source/qte5.d


Can't load libQtE5Widgets64.so from current directory.
Tried
$ export LD_LIBRARY_PATH=`pwd`; ./ide5 -i pr1.ini
$ export LIBRARY_PATH=`pwd`; ./ide5 -i pr1.ini
$ sudo ldconfig `pwd`

Nothing helps..


Для общения можно использовать https://vk.com/vk_dlang


I haven't vk and never will have.
Я тоже не имею аккаута на vk.com, но это не мешает мне общаться 
с русcкоязычным

сообществом D.


Maybe is good link, but it closes tab in firefox, own and tab 
opened before..


Re: How to write Good IDE?

2017-02-05 Thread unDEFER via Digitalmars-d

On Sunday, 5 February 2017 at 09:20:36 UTC, MGW wrote:


// Compile executable ide5 for 64
// Компилируем для 64 разрядного варианта
dmd ide5 qte5 qte5prs asc1251 ini -release -m64


$ dmd ide5 qte5 qte5prs asc1251 ini -release -m64
ide5.d(130): Error: undefined identifier 'Highlighter', did you 
mean variable 'highlighter'?



Для общения можно использовать https://vk.com/vk_dlang


I haven't vk and never will have.


Re: How to write Good IDE?

2017-02-04 Thread unDEFER via Digitalmars-d

On Friday, 3 February 2017 at 19:17:54 UTC, MGW wrote:

On Wednesday, 1 February 2017 at 15:12:42 UTC, unDEFER wrote:

And what important for you for Good IDE?


Simple IDE. It is possible that that is useful from this what 
is. I permanently use it as it is very quickly.


https://www.youtube.com/watch?v=RBan5Dwt_JM
https://github.com/MGWL/QtE5/tree/master/ide5


Wow, without DCD? Looking interesting.
How to build ide5?

$ dub build
Performing "debug" build using dmd for x86_64.
qte5 0.0.7: building configuration "exampleLinux"...
Linking...
Running post-build commands...
Error load: libQtE5Widgets64.so
Copying files for qte5...

$ dmd -of=ide_5 ide5/ide5.d  ide5/ini.d  ide5/qte5prs.d  
source/asc1251.d  source/qte5.d

$ ./ide_5 -d
Error load: libQtE5Widgets64.so


Re: unDE 0.2.0 - unusual command line and keybar

2017-02-03 Thread unDEFER via Digitalmars-d-announce

On Friday, 3 February 2017 at 17:11:26 UTC, Chris Wright wrote:
I think `mkdirRecurse` doesn't complain about directories that 
already exist.


Thank you!


Re: unDE 0.2.0 - unusual command line and keybar

2017-02-03 Thread unDEFER via Digitalmars-d-announce

On Friday, 3 February 2017 at 14:18:05 UTC, Basile B. wrote:

Also before that there's two FileException thrown because you 
use mkdir() systematically with a silent try catch. You should 
rather test if the the directories exist (when you create 
~/.unde/  and ~/.unde/bdb/, global_state.d) because it tends to 
be annoying when trying to get that stack trace for the real 
exception !


OK, will be fixed.


Re: unDE 0.2.0 - unusual command line and keybar

2017-02-03 Thread unDEFER via Digitalmars-d-announce

On Friday, 3 February 2017 at 14:05:58 UTC, Basile B. wrote:

What is the name of the static lib we have to install for for 
"DB" ?


/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: ne 
peut trouver -ldb
collect2: error: ld returned 1 exit status
Error: linker exited with status 1


You must usr libdb 5.3. Your seg.fault because you use version 
lesser.


Re: How to write Good IDE?

2017-02-03 Thread unDEFER via Digitalmars-d

On Friday, 3 February 2017 at 12:37:53 UTC, Jacob Carlborg wrote:
The old Eclipse plugin for D1, Descent [1], is the gold 
standard when it comes to IDE's for D. Check the features list 
[2] to get some ideas and inspiration.


[1] http://www.dsource.org/projects/descent
[2] http://www.dsource.org/projects/descent#Features


Thank you! Good links.


Re: How to write Good IDE?

2017-02-02 Thread unDEFER via Digitalmars-d

On Friday, 3 February 2017 at 01:31:03 UTC, Chris Wright wrote:

It's awkward to use dmdfe as a library, mainly because it's not 
vetted to work with the GC. You *can* disable the GC, invoke 
dmdfe, copy out the data you need, and then enable the GC.


Thank you Chris, really I don't want use dmd as library

You could fork dmdfe, add your own fields and datastructures 
for things you need that aren't there already, add extra 
analysis that suits you, and change error handling to account 
for partially completed lines of code.


The last is more possible that I want. But not with dmd, but 
maybe with gcc/gdc. I really don't know how to fast support 
several languages. And maybe first version will support only D.


So.. I want to create own IDE for 6 months..


Re: How to write Good IDE?

2017-02-02 Thread unDEFER via Digitalmars-d

On Thursday, 2 February 2017 at 15:04:10 UTC, Jack Stouffer wrote:


Speed.


Yes, speed it will one of the main characteristic of my IDE.


How to write Good IDE?

2017-02-01 Thread unDEFER via Digitalmars-d

Hello!
So my unDE 0.2.0 is released 
(http://forum.dlang.org/thread/yzfthfipouzhejfsk...@forum.dlang.org), and this means that the time to write unDE 0.3.0 - text editor and IDE.


And I grab my head when thinking how much I want to implement.

1) It must shows unused modules
2) It must shows parts of modules which used by module
3) It must shows not caught exceptions
4) It must autocomplete always even "string".to

I have seen pretty tool from Hackerpilot (DCD, dfmt, Dscanner), 
but it doesn't cover this list.


And I think how easier may be implement such IDE? From zero, or 
maybe possible to use parts of dmd/gdc?

And what important for you for Good IDE?


Re: unDE 0.2.0 - unusual command line and keybar

2017-01-30 Thread unDEFER via Digitalmars-d-announce

On Monday, 30 January 2017 at 11:20:40 UTC, FreeSlave wrote:

Can't load 
/home/freeslave/git_projects/unde/images/clear_errors.png: 
Invalid renderer


Yes, it is very strange message, I still didn't find how to clean 
it out...


Re: unDE 0.2.0 - unusual command line and keybar

2017-01-29 Thread unDEFER via Digitalmars-d-announce

On Sunday, 29 January 2017 at 23:57:30 UTC, FreeSlave wrote:

On Sunday, 29 January 2017 at 19:00:30 UTC, unDEFER wrote:


Very interesting concept (Probably it's not new, but I never 
actually used file managers like this). It looks you put much 
love and effort in it. Damn, you even made packages for many 
different Linux distros! (I'm always lazy when things come to 
packaging, so I'm just amazed that you made so many).


Thank you

Why did you not give a link to github repo? I had to search it 
myself https://github.com/unDEFER/unde


Because it is only mirror and I update it only on releases.

How can I build and run unde myself? I built it via dub build 
and installed ttf-ancient-fonts, but it still throws exception 
when I try to run ./unde:
object.Exception@source/unde/font.d(714): TTF_OpenFont: 
Couldn't open 
/usr/share/fonts/truetype/ancient-scripts/Symbola_hint.ttf


Look source/unde/font.d, there is many "versions" where may be 
installed these fonts. If you find your paths you can use 'dub 
build -c "Version"'.

Else you can add own or make symbolic links.

Also you can say your distro and maybe the next time I will make 
package for you.


unDE 0.2.0 - unusual command line and keybar

2017-01-29 Thread unDEFER via Digitalmars-d-announce
unDE's not DE which in the future must be replacement for all 
programs in OS.
But today is very original file manager, image and text viewer 
and (what discovered with 0.2.0 version) command line and keybar.

More information: http://unde.sourceforge.net/en/ch25.html
Video with English subtitles: https://youtu.be/XY7Jegxq6vg


Re: bdb2d and openSUSE

2017-01-25 Thread unDEFER via Digitalmars-d

So, the problem:
$ cc --version
cc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  
There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE.


$ cc 
.dub/build/OpenSUSE-debug-linux.posix-x86_64-dmd_2071-186D122990333E297AD7D4BDA72364C7/unde.o -o .dub/build/OpenSUSE-debug-linux.posix-x86_64-dmd_2071-186D122990333E297AD7D4BDA72364C7/unde -g -m64 -Xlinker --no-as-needed -L/usr/local/BerkeleyDB.5.3/lib64/ -lutil -ldb -ldl -L/usr/lib64 -Xlinker --export-dynamic ../../.dub/packages/bdb2d-5.3.28/bdb2d/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-9E956773380BE684D56F8F1619A72458/libdb.a ../../.dub/packages/derelict-ft-1.1.3/derelict-ft/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-C5461FBF3AF191B3583F388641667679/libDerelictFT.a ../../.dub/packages/derelict-sdl2-2.0.2/derelict-sdl2/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-211F2539A3F0A6356A2312EFBC7AF002/libDerelictSDL2.a ../../.dub/packages/derelict-util-2.0.6/derelict-util/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-DAD1CE5EB4AA073E02604396A45B67FE/libDerelictUtil.a -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl

(with -ldb in the middle) doesn't work

$ cc 
.dub/build/OpenSUSE-debug-linux.posix-x86_64-dmd_2071-186D122990333E297AD7D4BDA72364C7/unde.o -o .dub/build/OpenSUSE-debug-linux.posix-x86_64-dmd_2071-186D122990333E297AD7D4BDA72364C7/unde -g -m64 -Xlinker --no-as-needed -L/usr/local/BerkeleyDB.5.3/lib64/ -lutil -ldb -ldl -L/usr/lib64 -Xlinker --export-dynamic ../../.dub/packages/bdb2d-5.3.28/bdb2d/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-9E956773380BE684D56F8F1619A72458/libdb.a ../../.dub/packages/derelict-ft-1.1.3/derelict-ft/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-C5461FBF3AF191B3583F388641667679/libDerelictFT.a ../../.dub/packages/derelict-sdl2-2.0.2/derelict-sdl2/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-211F2539A3F0A6356A2312EFBC7AF002/libDerelictSDL2.a ../../.dub/packages/derelict-util-2.0.6/derelict-util/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-DAD1CE5EB4AA073E02604396A45B67FE/libDerelictUtil.a -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl -ldb

(with -ldb at the end) works


bdb2d and openSUSE

2017-01-24 Thread unDEFER via Digitalmars-d
Hello! Trying to build my project for Open SuSE and my project 
bdb2d unexpectedly brings error:


Linking...
../../.dub/packages/bdb2d-5.3.28/bdb2d/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-9E956773380BE684D56F8F1619A72458/libdb.a(db_126_1b8.o):
 In function 
`_D10berkeleydb2db2Db6__ctorMFC10berkeleydb5dbenv5DbEnvkZC10berkeleydb2db2Db':
/home/undefer/unDE/unde-code/../../.dub/packages/bdb2d-5.3.28/bdb2d/source/berkeleydb/db.d:68:
 undefined reference to `db_create'
../../.dub/packages/bdb2d-5.3.28/bdb2d/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-9E956773380BE684D56F8F1619A72458/libdb.a(dbenv_1a4_1b8.o):
 In function `_D10berkeleydb5dbenv5DbEnv6__ctorMFkZC10berkeleydb5dbenv5DbEnv':
/home/undefer/unDE/unde-code/../../.dub/packages/bdb2d-5.3.28/bdb2d/source/berkeleydb/dbenv.d:89:
 undefined reference to `db_env_create'
../../.dub/packages/bdb2d-5.3.28/bdb2d/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-9E956773380BE684D56F8F1619A72458/libdb.a(dbexception_284_455.o):
 In function 
`_D10berkeleydb11dbexception11DbException6__ctorMFAyaiC10berkeleydb5dbenv5DbEnvAyamZC10berkeleydb11dbexception11DbException':
/home/undefer/unDE/unde-code/../../.dub/packages/bdb2d-5.3.28/bdb2d/source/berkeleydb/dbexception.d:161:
 undefined reference to `db_strerror'
../../.dub/packages/bdb2d-5.3.28/bdb2d/.dub/build/library-debug-linux.posix-x86_64-dmd_2071-9E956773380BE684D56F8F1619A72458/libdb.a(dbsequence_2a6_3df.o):
 In function 
`_D10berkeleydb10dbsequence10DbSequence6__ctorMFC10berkeleydb2db2DbkZC10berkeleydb10dbsequence10DbSequence':
/home/undefer/unDE/unde-code/../../.dub/packages/bdb2d-5.3.28/bdb2d/source/berkeleydb/dbsequence.d:51:
 undefined reference to `db_sequence_create'
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.


db_create, db_env_create, db_strerror, db_sequence_create all 
defined in the project as extern(C) functions; and all it defined 
as C-functions in external libdb.a library.


The code works under Ubuntu, Linux Mint, Debian, Fedora, but not 
OpenSuse.


What particulars of building under OpenSuSE?




Re: Hangs on toStringZ()

2016-12-28 Thread unDEFER via Digitalmars-d
On Wednesday, 28 December 2016 at 12:39:46 UTC, Nemanja Boric 
wrote:
Right, nothing wrong with threads, but super tricky to combine 
it with fork. So, it could be that one of your threads is using 
GC at the point of the forking, so it keeps the GC locked. Now 
you fork, and _all your threads don't exist anymore, they are 
vanished, and if you don't do some clever stuff in atfork 
handler, there will be no cleanup_ - you just have copy of the 
thread that called fork. So, the thread that should release GC 
lock doesn't exist anymore, and there's nothing to release 
mutex, and it will stay locked forever in your forked process.


Thanks a lot for such detailed explanation!


Re: Hangs on toStringZ()

2016-12-28 Thread unDEFER via Digitalmars-d
On Wednesday, 28 December 2016 at 11:32:09 UTC, Nemanja Boric 
wrote:
My other guess is that you're using D threads in your 
application?


Of course I'm using D threads, but with it all is normally.



Re: Hangs on toStringZ()

2016-12-28 Thread unDEFER via Digitalmars-d
On Wednesday, 28 December 2016 at 11:30:22 UTC, Nemanja Boric 
wrote:

What you should do is following:

1. Allocate all needed data, convert all D strings into C 
strings, etc.

2. fork
3. exec immediately, not using anything from standard library 
between 2 and 3.


OK, thank you.. I'm trying it and still haven't hanging.


Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d

On Tuesday, 27 December 2016 at 21:33:46 UTC, Marc Schütz wrote:

What context are you calling this from? Is this in a signal 
handler? Or from inside a destructor of a GC-owned object?


It is child of my process after fork and before execl. No signal 
handler, no destructor, no catch-block, usual code.


Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d

The last backtrace shows that it hangs on the line:

immutable(char) *bash = "/bin/bash".toStringz();


Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d

On Tuesday, 27 December 2016 at 18:01:36 UTC, Stefan Koch wrote:

Have you tried assigning it to a variable ?


Yes, I have tried, now backtrace of hanged process is:

(gdb) bt
#0  0x7f4e18260c6d in ?? ()
#1  0x in ?? ()


Re: Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d

On Tuesday, 27 December 2016 at 17:50:14 UTC, Stefan Koch wrote:

The string is allocated on the gc-ed heap.
And since it's an R value it might get destroyed before execl 
is finished.
Assign the result of toStringz to a char* variable and use that 
in the call.


But execl not goes to Seg.fault. It hangs before call execl..


Re: Using dlopen/dlsym

2016-12-27 Thread unDEFER via Digitalmars-d

It works on my Ubuntu 16.04 and dmd v2.071.1
But it wants to call dlopen() as core.sys.posix.dlfcn.dlopen().


Hangs on toStringZ()

2016-12-27 Thread unDEFER via Digitalmars-d

Hello I have very simple line with exec-command:

execl("/bin/bash".toStringz(), "/bin/bash".toStringz(), 
"-c".toStringz(), command.toStringz(), null);


And on this line on toStringz my program sometimes hangs.
backtrace:

(gdb) bt
#0  0x7f3acd535c6d in nanosleep () at 
../sysdeps/unix/syscall-template.S:84
#1  0x0066f57e in 
core.thread.Thread.sleep(core.time.Duration) ()
#2  0x006b2824 in 
core.internal.spinlock.SpinLock.yield(ulong) shared

()
#3  0x006b27c0 in core.internal.spinlock.SpinLock.lock() 
shared ()
#4  0x006a7244 in 
gc.gc.GC.runLocked!(gc.gc.GC.mallocNoSync(ulong, uint, ref ulong, 
const(TypeInfo)), gc.gc.mallocTime, gc.gc.numMallocs, ulong, 
uint, ulong, const(TypeInfo)).runLocked(ref ulong, ref uint, ref 
ulong, ref const(TypeInfo)) ()
#5  0x006a0bc6 in gc.gc.GC.malloc(ulong, uint, ulong*, 
const(TypeInfo))

()
#6  0x006721d3 in gc_qalloc ()
#7  0x006a99a1 in rt.lifetime.__arrayAlloc(ulong, 
const(TypeInfo), const(TypeInfo)) ()

#8  0x0067523a in _d_newarrayU ()
#9  0x00675324 in _d_newarrayiT ()
#10 0x0068fde6 in std.string.toStringz(const(char)[]) ()
#11 0x0068fe79 in 
std.string.toStringz(const(immutable(char)[])) ()
#12 0x00592dc9 in 
unde.command_line.run.fork_command(unde.global_state.CMDGlobalState, immutable(char)[], immutable(char)[], std.concurrency.Tid) (

tid=..., command=..., cwd=..., cgs=0x7f3abcdffb80)
at source/unde/command_line/run.d:2002

What is it? For what it waits?


Re: Many documentation examples can now be run online

2016-12-19 Thread unDEFER via Digitalmars-d-announce

Excellent work, thank you!


Re: unDE 0.1.0: original file manager, image and text viewer

2016-12-16 Thread unDEFER via Digitalmars-d-announce

On Friday, 16 December 2016 at 19:03:29 UTC, MGW wrote:

Очень интересная работа. Взглянул на некоторые проблемы с 
другой стороны.

Интересно, это реализовано на D?


I'm translating:
"Very interesting work. I looked on some problems with other hand.
 Interesting, is it implemented on D?"

Отвечаю:
Дык, там же все исходники!

Translation of answer:
"There is all sources!!!"


Re: unDE 0.1.0: original file manager, image and text viewer

2016-12-16 Thread unDEFER via Digitalmars-d-announce

On Friday, 16 December 2016 at 14:51:53 UTC, John Colvin wrote:
This looks like a very interesting project. I have had similar 
ideas recently but haven't had time to do anything. I'm looking 
forward to seeing what you create.


Thank you!


Re: unDE 0.1.0: original file manager, image and text viewer

2016-12-15 Thread unDEFER via Digitalmars-d-announce

On Thursday, 15 December 2016 at 20:35:16 UTC, Basile B. wrote:
That's interesting, unfortunately for you there's a more 
advanced version of a ZUI file explorer 
(http://eaglemode.sourceforge.net/index.html). How much your 
respective projects are related ?


As I understand eaglemode is only viewer. I want to go further. 
After version 0.1.0 there is will:

0.2.0 - command line
0.3.0 - text editor with IDE (with extremely support of D of 
course)

0.4.0 - graphic editor
and so on..


unDE 0.1.0: original file manager, image and text viewer

2016-12-15 Thread unDEFER via Digitalmars-d-announce

Hello, my dear friends!
So many days you answers on many my questions.
And today I glad to present my work: unDE 0.1.0.
It is very original file manager, image and text viewer.
More information: http://unde.sourceforge.net/en/ch24.html
Video with English subtitles: https://youtu.be/29zuxU9eyXo


Re: mkdir; remove; under Windows throw Exception

2016-12-10 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 18:30:53 UTC, Adam D. Ruppe 
wrote:

On Saturday, 10 December 2016 at 18:09:43 UTC, unDEFER wrote:

I know, but why it works in Linux by Linux documentation?


Coincidence. That detail is undefined in the D documentation 
which means the implementation is free to do whatever is easier 
for it in a platform-specific manner.


OH, OK. Undocumented behavior is undocumented behavior...


Re: mkdir; remove; under Windows throw Exception

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

On Saturday, 10 December 2016 at 14:10:15 UTC, ag0aep6g wrote:

On 12/10/2016 04:39 AM, unDEFER wrote:

man remove:

remove - remove a file or directory


That's documentation for C, not for D.


I know, but why it works in Linux by Linux documentation?



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 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 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: 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: 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: 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: 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: 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?


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?


Re: D with CygWin

2016-12-06 Thread unDEFER via Digitalmars-d

So it was not finish :-(

mkdir("C:\\cygwin\\home\\undefer\\TEST") is working
mkdir("/home/undefer/TEST") creates directory and hangs, doesn't 
pass control to the next instruction.


DirEntry("/") works in my simple program, but doesn't work in big 
program..


windbg, gdb doen't help at all.

It is failure :-(


Re: The order of libraries makes error in dub

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

On Monday, 5 December 2016 at 15:16:27 UTC, unDEFER wrote:
2) Its put to linker command at the first "libdb53d.lib 
WS2_32.lib" and AFTER that -m32mscoff. As result "cannot open 
file".


Oh, the reason was mistype. And I have found how-to hide linker 
warning ("lflags-windows": ["/NODEFAULTLIB:LIBCMTD"]).


Full correct dub.json:
===
{
"name": "bdb2d",
"targetName": "db",
"targetType": "library",
"description": "BerkeleyDB to D bindings.",
"authors": ["Nikolay (unDEFER) Krivchenkov"],
"homepage": "http://unde.su;,
"license": "GPL-3.0 or later",
"libs-posix": ["db"],
"libs-windows-dmd": ["libdb53sd", "WS2_32"],
"dflags-windows": ["-m32mscoff"],
"lflags-windows": ["/NODEFAULTLIB:LIBCMTD"],

"subPackages": [
{
"name": "reader",
"description": "BerkeleyDB Transaction test. Reader",
"targetName": "reader",
"targetType": "executable",
"sourceFiles": ["transactions_test/reader.d"],
"targetPath": "transactions_test",
"dependencies": {
"bdb2d": "*"
}
}, {
"name": "writer",
"description": "BerkeleyDB Transaction test. Writer",
"targetName": "writer",
"targetType": "executable",
"sourceFiles": ["transactions_test/writer.d"],
"targetPath": "transactions_test",
"dependencies": {
"bdb2d": "*"
}
}
]
}


Thank you to all, the thread is closed.


Re: The order of libraries makes error in dub

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

On Monday, 5 December 2016 at 14:59:26 UTC, Mike Parker wrote:

"libs-windows-dmd":["libdb53d.lib","ws2_32.lib"]


I have used "sourceFiles-windows-dmd", because it is the single 
that I could find.
Thank you, "libs-windows-dmd":["libdb53d","WS2_32"] works much 
better, but again these errors:

1) Its put to linker command "db.lib" from libs-posix
2) Its put to linker command at the first "libdb53d.lib 
WS2_32.lib" and AFTER that -m32mscoff. As result "cannot open 
file".


Re: The order of libraries makes error in dub

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

On Monday, 5 December 2016 at 11:51:52 UTC, unDEFER wrote:


"libs-posix": ["db"],
"sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"],
"dflags-windows": ["-m32mscoff"],

"subPackages": [



I understand that I don't must add "sourceFiles-windows-dmd" to 
lib project, I must add it to subPackages, but dub places the 
names of lib BEFORE -m32mscoff. So it doesn't work.

Say me: dub for windows not ready??




The order of libraries makes error in dub

2016-12-05 Thread unDEFER via Digitalmars-d-learn
Hello, dub makes string like the next to compile my program 
(WS_32.LIB at the beginning):


$ dmd -m32mscoff -lib 
-of.dub\\build\\library-debug-windows-x86-dmd_2072-83D2723917096513EB360761C22DDD87\\db.lib -debug -g -w -version=Have_bdb2d WS_32.LIB libdb53d.lib source/berkeleydb/* -vcolumns

Error: Error reading file 'WS_32.LIB'

So it shows error.

In other order (libraries at the end):
$ dmd -m32mscoff -lib 
-of.dub\\build\\library-debug-windows-x86-dmd_2072-83D2723917096513EB360761C22DDD87\\db.lib -debug -g -w -version=Have_bdb2d -Isource source/berkeleydb/* libdb53sd.lib WS2_32.LIB -vcolumns


No error.

But (again WS_32.LIB at beginning):
$ dmd -m32mscoff WS2_32.LIB libdb53sd.lib 
transactions_test/writer source/berkeleydb/*
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use 
of other libs; use /NODEFAULTLIB:library


Again no error, only warning.

How to make with dub correct compilable compile line?

my dub.json:
===
{
"name": "bdb2d",
"targetName": "db",
"targetType": "library",
"description": "BerkeleyDB to D bindings.",
"authors": ["Nikolay (unDEFER) Krivchenkov"],
"homepage": "http://unde.su;,
"license": "GPL-3.0 or later",
"libs-posix": ["db"],
"sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"],
"dflags-windows": ["-m32mscoff"],

"subPackages": [
{
"name": "reader",
"description": "BerkeleyDB Transaction test. Reader",
"targetName": "reader",
"targetType": "executable",
"sourceFiles": ["transactions_test/reader.d"],
"targetPath": "transactions_test",
"dependencies": {
"bdb2d": "*"
}
}, {
"name": "writer",
"description": "BerkeleyDB Transaction test. Writer",
"targetName": "writer",
"targetType": "executable",
"sourceFiles": ["transactions_test/writer.d"],
"targetPath": "transactions_test",
"dependencies": {
"bdb2d": "*"
}
}
]
}
==


Re: How to use library compiled with Microsoft Visual Studio 2015 in D?

2016-12-05 Thread unDEFER via Digitalmars-d-learn
OK, I have found. It must be library WS2_32.LIB from Microsoft 
SDK. But dumpbin doesn't show __imp__htonl@4 symbol there. The 
magic!

Thank you!


Re: How to use library compiled with Microsoft Visual Studio 2015 in D?

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

On Monday, 5 December 2016 at 07:21:30 UTC, Jacob Carlborg wrote:
If you compile your D code with the "-m32mscoff" flag it will 
produce COFF objects and use the Visual Studio tool chain 
(linker and runtime). Compiling for 64bit (-m64) will always 
produce COFF objects.


Big thanks! -m32mscoff is great!
But now I have the problem of unresolved external symbols, e.g. 
"__imp__htonl@4".
What I'm doing? I'm going to Microsoft Visual Studio directory 
and run the script:
$ for i in `/bin/find.exe . -iname "*.lib"`; do bin/dumpbin 
/SYMBOLS $i | /bin/grep __imp__htonl@4 && echo $i; done

308  UNDEF  notype   External | __imp__htonl@4
./atlmfc/lib/nafxcw.lib
3C6  UNDEF  notype   External | __imp__htonl@4
./atlmfc/lib/nafxcwd.lib
332  UNDEF  notype   External | __imp__htonl@4
./atlmfc/lib/uafxcw.lib
3D6  UNDEF  notype   External | __imp__htonl@4
./atlmfc/lib/uafxcwd.lib

Try to link with found libraries, but it doesn't work. The 
symbols still unresolved.

What I'm doing wrong?


How to use library compiled with Microsoft Visual Studio 2015 in D?

2016-12-04 Thread unDEFER via Digitalmars-d-learn
Hello! I have compiled libdb (BerkeleyDB) with Microsoft Visual 
Studio 2015.

1) "Debug" mode. I have libdb53d.dll file. Do implib.
The linker doesn't seen symbols from the library! Do "lib -l". In 
the list of symbols "db_create", linker searches "_db_create". Is 
it the problem?
2) "Debug-Static" mode. I have libdb53d.lib file. Try to compile. 
linker say that it has unsupported COFF format. Read about 
COFF2OMF, buy extended utils to get it.

$ coff2omf libdb53d.lib
Segmentation Fault
Try like on page http://www.digitalmars.com/ctg/coff2omf.html:
$ link /lib /convert file.lib
LINK : warning LNK4044: unrecognized option '/convert'; ignored

So nothing works. How to use a library compiled with Microsoft 
Visual Studio 2015 in D?


Re: D with CygWin

2016-12-04 Thread unDEFER via Digitalmars-d

DONE!!!

===
$ cat try.d
import std.stdio;
import std.string;
import cygwin.std.file;
import cygwin.loader;

void main()
{
CygwinInit();

foreach (string name; dirEntries("/", SpanMode.shallow))
{
writefln(name);
}
}
===

$ ./try.exe
/bin
/Cygwin-Terminal.ico
/Cygwin.bat
/Cygwin.ico
/dev
/etc
/home
/lib
/sbin
/tmp
/usr
/var
/proc
/cygdrive


The sources of "cygwin" package for D will be available as part 
of my unDE project soon.


Re: D with CygWin

2016-12-04 Thread unDEFER via Digitalmars-d

I have found. I have to use cygwin_dll_init
==
$ cat try.d
import std.stdio;
import std.string;
import core.sys.windows.windows;

extern(C)
{
alias int   function(const (char)*, int, ...) open_t;
alias void   function() init_t;
alias void  function(const (char)*s) perror_t;
alias size_t function(int fs, void *buf, size_t count) 
read_t;

open_t _my_open;
init_t  init;
perror_t my_perror;
read_t  my_read;
}

void main()
{
writefln("Open Library");
HMODULE mod = cast(HMODULE) 
LoadLibrary("C:\\cygwin\\bin\\cygwin1.dll");

if (mod is null)
{
writefln("Failed load cygwin1.dll");
return;
}

writefln("Get Proc Init");
init = cast(init_t) GetProcAddress(mod, 
"cygwin_dll_init");

if (init is null)
{
writefln("Failed open init symbol %s", 
GetLastError());

return;
}

init();

writefln("Get Proc Open");
_my_open = cast(open_t) GetProcAddress(mod, "open");
if (_my_open is null)
{
writefln("Failed open open symbol %s", 
GetLastError());

return;
}

writefln("Get Proc read");
my_read = cast(read_t) GetProcAddress(mod, "read");
if (my_read is null)
{
writefln("Failed open read symbol %s", 
GetLastError());

return;
}

writefln("_open");
int res = (*_my_open)(toStringz("/proc/cpuinfo"), 0);
writefln("res=%s", res);
if (res < 0)
{
my_perror("Can't open file");
}

char[1024] buf;
my_read(res, buf.ptr, buf.length);

writefln("%s", buf);
}


$ ./try.exe
Open Library
Get Proc Init
Get Proc Open
Get Proc read
_open
res=0
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model   : 76
model name  : Intel(R) Pentium(R) CPU  N3700  @ 1.60GHz
...


The problem of the method only errno variable which doesn't 
content right error number.


Re: D with CygWin

2016-12-03 Thread unDEFER via Digitalmars-d

So, just another attempt..

=
import std.stdio;
import std.string;
import core.sys.windows.winbase;

extern(C)
{
alias int   function(in char*, int, ...) open_t;
open_t _my_open;
extern uint   errno;
}

void main()
{
writefln("Open Library");
auto mod = LoadLibrary("C:\\cygwin\\bin\\cygwin1.dll");
if (mod == null)
{
writefln("Failed load cygwin1.dll");
return;
}

writefln("Get Proc");
_my_open = cast(open_t) GetProcAddress(mod, "open");
if (_my_open == null)
{
writefln("Failed open open symbol");
return;
}

writefln("_open");
int res = _my_open(toStringz("/bin/bash"), 0);
writefln("res=%s errno=%s", res, errno);
}
=

The code compiles without problem, BUT without last 2 lines it 
runs, and with last 2 lines it said that executable is corrupted.

Why???


Re: Delegates: Print 0..9

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

On Thursday, 1 December 2016 at 20:12:15 UTC, Ali Çehreli wrote:


First, the scary syntax that produces a lambda from an int:
...
Better:
...


All methods.. Thank you!


  1   2   >