Re: Beta 2.098.0

2021-10-04 Thread Temtaime via Digitalmars-d-announce
On Wednesday, 29 September 2021 at 20:53:53 UTC, Martin Nowak 
wrote:
Glad to announce the first beta for the 2.098.0 release, ♥ to 
the 62 contributors.


http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.098.0.html

This release is quite a bit delayed due to [OSX build 
woes](https://github.com/dlang/installer/pull/487) and some 
personal lack of time.


As usual please report any bugs at
https://issues.dlang.org

-Martin


What is really discourages me that persons like Walter instead of 
making D great just do nothing helpful.


https://issues.dlang.org/show_bug.cgi?id=22115 was created for no 
reason and fixed same day.


While these ones will rest for some years i think ...
https://issues.dlang.org/show_bug.cgi?id=22148
https://issues.dlang.org/show_bug.cgi?id=22283


Re: Beta 2.097.2

2021-08-08 Thread Temtaime via Digitalmars-d-announce

On Wednesday, 4 August 2021 at 17:34:32 UTC, Martin Nowak wrote:
Glad to announce the first beta for the 2.097.2 point release, 
♥ to the 4 contributors.


http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.097.2.html

As usual please report any bugs at
https://issues.dlang.org

-Martin


Anyone to fix ? https://issues.dlang.org/show_bug.cgi?id=22148
noreturn is unusable for me because of this bug


utile library on dub

2021-04-01 Thread Temtaime via Digitalmars-d-announce

Hello.
I released my utile library with some helper functions.
I'm most proud of its binary (de)serializer. You can look at the 
tests here:

https://github.com/Temtaime/utile/blob/main/source/utile/binary/tests.d#L13

There's no much docs except unittests, but feel free to 
contribute / report issues.
With the serializer you can describe almost all file format as a 
struct and it will take care of the rest.


Kind regards.


Re: GC.addRange in pure function

2021-02-09 Thread Temtaime via Digitalmars-d-learn

On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote:
Why using 'new' is allowed in pure functions but calling 
GC.addRange or GC.removeRange isn't allowed?


pure is broken. Just don't [use it]


Re: Unfold string array

2020-01-05 Thread Temtaime via Digitalmars-d-learn

On Sunday, 5 January 2020 at 22:39:37 UTC, Teo wrote:

On Sunday, 5 January 2020 at 13:37:58 UTC, JN wrote:

[...]


Thanks for the input.
I just realized that I was not precise enough in my 
description. Apologies for that.

My intention is to use std.algorithm, if possible.

I read the documentation and tried using many functions like 
"joiner", "each", "fold", "group", "filter", etc. from 
std.algorithm.iteration.


In my opinion, I need to construct a predicate like
(a, b) => if b.startsWith() {join(a, b, " ")}
Unfortunately, I cannot figure out which combination of 
functions will give me the desired result.


Of course, if I am unable to find an elegant way to do it, I am 
going to iterate over the array in a way similar to what you 
suggested.


https://ideone.com/tvpreP


Re: code.dlang.org downtime

2019-12-16 Thread Temtaime via Digitalmars-d-announce

My ISP still serves old IP.
Thanks for such a blackout.
D is still not for production use, just a toy that may break 
accidentally by a will of its creators.




Re: [windows] Can't delete a closed file?

2019-05-10 Thread Temtaime via Digitalmars-d-learn

Lol, you don't have to load and unload the curl dll.
std.net.curl have its own lazy libcurl loader. But i'm not sure 
if it tries to find the dll in the temp directory. If it is the 
case, then it simply doesn't unload the dll when you have called 
some function from it.


Re: Portable D compiler builds

2019-03-31 Thread Temtaime via Digitalmars-d-announce

On Saturday, 30 March 2019 at 17:38:35 UTC, kinke wrote:

On Saturday, 30 March 2019 at 17:00:12 UTC, Temtaime wrote:
The goal is to provide a complete solution to build an 
ordinary d app without having visual studio installed.

[...]
Dmd for now can only work with omf libs and link only 32 bit 
apps, ldc - with mingw libs.


Erm nope, DMD works fine with COFF libs (-m32mscoff) and 64-bit 
(-m64) too; it's been shipping with the LLD linker and 
MinGW-based libs for a while, LDC followed suite but uses 
different MinGW-based libs. The only drawback is that these 
libs require a VC runtime installation for *running* generated 
binaries (but no MinGW). But Visual Studio or the Build Tools 
are purely optional for both compilers, and mostly interesting 
to link against the static MS libs to prevent the MS DLL 
dependencies.


Static libs for imports are taken from a pelles c compiler and 
can be redistributed, i'll add a notice and license files.


Okay that's *very* interesting, and I highly doubt they are 
allowed to do so. See recent 
https://issues.dlang.org/show_bug.cgi?id=19760.


Seems that i was sleeping for too long and missed the moment when 
they both migrated to mingw libs.
Okay, then there's really no advantages and rights for 
distributing this project. I just made those builds for myself 
for years and decided to share it.

Thanks for a notion and the link.


Re: Portable D compiler builds

2019-03-30 Thread Temtaime via Digitalmars-d-announce

On Saturday, 30 March 2019 at 14:18:05 UTC, kinke wrote:

On Friday, 29 March 2019 at 20:40:08 UTC, Temtaime wrote:
Yay, latest stable ldc was added alongside rdmd, ldmd2, 
dustmite and ddemangle tools for both ldc and dmd!


It's not quite clear to me what your goals are. Official DMD 
and LDC packages are portable, don't require any external 
dependencies either and ship with these tools.


Your DMD builds are 64-bit and compiled with LDC, vs. 32-bit 
and DMD of official builds, so that's an improvement.


I downloaded your LDC build and after a quick glance noticed 
that it's 32-bit (?) and contains
* just the x86 and x86_64 LLVM backends (e.g., no support for 
WebAssembly and dcompute),
* a phobos.lib merging both druntime and Phobos (DMD-style, 
unlike official LDC),

* NO debug and LTO versions of druntime/Phobos,
* NO dynamicCompile/JIT and compiler-rt libraries (e.g., needed 
for profiling),

* superfluous imports (the internal/hidden gc and rt packages),
* NO imports/ldc/gccbuiltins*.di,
* NO readme and license files,
* NO `-link-defaultlib-shared=false` in the config file, so 
that linking DLLs with `-shared` probably fails,
* the static MS libs which cannot be officially redistributed 
(license...) but allow people to generate binaries not 
depending on the MS runtime DLLs.


Once your goals are clearer, there may be much simpler 
solutions, e.g., augmenting the official LDC builds by the MS 
libs instead of the MinGW-based ones.


Hi, thanks for a reply.
The goal is to provide a complete solution to build an ordinary d 
app without having visual studio installed.
Static libs for imports are taken from a pelles c compiler and 
can be redistributed, i'll add a notice and license files.
Dmd for now can only work with omf libs and link only 32 bit 
apps, ldc - with mingw libs.
Many packages on code.dlang.org uses coff format, so at least for 
me other variants are not acceptable.
LTO version of phobos/runtime is on the list with some other 
features.


Re: Portable D compiler builds

2019-03-29 Thread Temtaime via Digitalmars-d-announce
Yay, latest stable ldc was added alongside rdmd, ldmd2, dustmite 
and ddemangle tools for both ldc and dmd!


Portable D compiler builds

2019-03-16 Thread Temtaime via Digitalmars-d-announce

Hello !
Glad to announce my D compiler builds.

Currently there's only DMD builds: 64-bit compiler built with LDC 
with MSVC's 2017 runtime, allowing linking your apps with all the 
COFF libraries you have.
It supports both 32-bit(limited due to a bug in lld linker) and 
64-bit apps.


Scripts that are used to make a build is published here with some 
additional info: https://github.com/Temtaime/d_builds

And the builds are going here: https://d.acomirei.ru/

It doesn't require any dependency at all - just download it, 
extract somewhere, add «bin» to PATH and use dmd, dub, dustmite 
from your command prompt without worrying about installing MSVC 
build tools or something else.


Project is in beta state, something may be not working correctly, 
so feel free to report bugs or something else.


Re: Beta 2.085.0

2019-02-17 Thread Temtaime via Digitalmars-d-announce

On Saturday, 16 February 2019 at 15:06:51 UTC, Martin Nowak wrote:
Glad to announce the first beta for the 2.085.0 release, ♥ to 
the 49 contributors.


http://dlang.org/download.html#dmd_beta 
http://dlang.org/changelog/2.085.0.html


As usual please report any bugs at
https://issues.dlang.org

-Martin


-transition=intpromote leads to compile error instead of continue 
to work as it stated in the docs.


Re: DMD backend now in D

2018-11-13 Thread Temtaime via Digitalmars-d-announce

On Monday, 12 November 2018 at 02:37:54 UTC, Walter Bright wrote:

On 11/11/2018 3:58 PM, Mike Franklin wrote:

This is a significant milestone.  Congratulations, Walter!


Many people helped out with this, too.

There are still a few .c files in 
https://github.com/dlang/dmd/tree/master/src/dmd/backend, so 
what's the significance of those?


tk.c
fp.c
os.c
strtold.c
tk/mem.c

These could be converted too, but are independent from 
everything else and hardly seem worth the bother. Sebastian has 
a PR for os.cd.



Will there ever be a day when we no longer need a C/C++ 
compiler to build DMD?


Sure.



No, as phobos is dependent on C libraries such as a zlib for 
example.

Also D is dependent on libc.


Re: phobo's std.file is completely broke!

2018-09-17 Thread Temtaime via Digitalmars-d
On Sunday, 16 September 2018 at 22:49:26 UTC, Vladimir Panteleev 
wrote:

To elaborate:

On Sunday, 16 September 2018 at 22:40:45 UTC, Vladimir 
Panteleev wrote:
If *YOU* are OK with the consequences of complexity, implement 
this in YOUR code, but do not enforce it upon others.


This is much better done in user code anyway, because you only 
need to expand / normalize the path and prepend the prefix only 
once (root of the directory tree you're operating on), instead 
of once per directory call.


We could add a `string longPath(string)` function in Phobos 
(no-op on POSIX, expands and prepends prefix on Windows). I 
believe I suggested the same in the bug report years ago when 
we discussed it.


It is absolutely not acceptable behavior. Complain to 
Microsoft. The OS should not allow users to create or select 
paths that programs cannot operate on without jumping through 
crazy hoops.


Microsoft could have solved this easily enough:

extern(System) void AllowLongPaths();

Programs (or programming language runtimes) which can handle 
paths longer than MAX_PATH could call that function. It can 
also be used as a hint to the OS that file/directory selection 
dialogs, as you mentioned, are allowed to select paths longer 
than MAX_PATH.


It's problem with phobos.
It should be able handle all the paths whatever length they have, 
on all the platforms without noising the user.


Even with performance penalty, but it should.


Re: forum best practices

2018-06-30 Thread Temtaime via Digitalmars-d

On Saturday, 30 June 2018 at 22:06:46 UTC, Walter Bright wrote:

On 6/30/2018 3:04 PM, Jonathan M Davis wrote:
>> Just quote the bit you are responding to, and then only
enough to cue
>> the reader to just what you are responding to.
Quoting at least _part_ of the message is highly desirable for 
those using

the mailing list, even it's very abbreviated.


What I said :-)


Just drop away this annoying quoting by default.


Re: toLower is totally broken in 2.080

2018-06-15 Thread Temtaime via Digitalmars-d

On Friday, 15 June 2018 at 13:30:53 UTC, Basile B. wrote:

On Friday, 15 June 2018 at 12:17:03 UTC, Temtaime wrote:

https://issues.dlang.org/show_bug.cgi?id=18993
Please, maybe someone fix and backport it to stable


Works for me w/ 2.081 but fails with dmd ~master.


Maybe i mixed up versions, then sorry. But a bug to fix anyway.


toLower is totally broken in 2.080

2018-06-15 Thread Temtaime via Digitalmars-d

https://issues.dlang.org/show_bug.cgi?id=18993
Please, maybe someone fix and backport it to stable


Re: Replacing C's memcpy with a D implementation

2018-06-10 Thread Temtaime via Digitalmars-d

On Sunday, 10 June 2018 at 22:23:08 UTC, Walter Bright wrote:

On 6/10/2018 11:16 AM, David Nadlinger wrote:
Because of the large amounts of noise, the only conclusion one 
can draw from this is that memcpyD is the slowest,


Probably because it does a memory allocation.



followed by the ASM implementation.


The CPU makers abandoned optimizing the REP instructions 
decades ago, and just left the clunky implementations there for 
backwards compatibility.



In fact, memcpyC and memcpyNaive produce exactly the same 
machine code (without bounds checking), as LLVM recognizes the 
loop and lowers it into a memcpy. memcpyDstdAlg instead gets 
turned into a vectorized loop, for reasons I didn't 
investigate any further.


This amply illustrates my other point that looking at the 
assembler generated is crucial to understanding what's 
happening.


On some cpu architectures(for example intel atoms) rep movsb is 
the fatest memcpy.


Re: On Forum Moderation

2018-05-26 Thread Temtaime via Digitalmars-d

On Saturday, 26 May 2018 at 12:35:21 UTC, rikki cattermole wrote:

On 27/05/2018 12:31 AM, Tony wrote:

On Saturday, 26 May 2018 at 12:06:13 UTC, Mike Parker wrote:

On Saturday, 26 May 2018 at 11:30:24 UTC, Tony wrote:

On Saturday, 26 May 2018 at 11:12:29 UTC, Rubn wrote:

What about self moderation? If I make an unprofessional 
comment and want to delete it? Will this be allowed now? I 
guess it's more of a feature request.


The lack of an edit feature has been brought up before and 
it was said that it doesn't exist because the forum is 
combined with an email mailing list.


The authoratative database is an NNTP server. The mailing 
list is an interface to that, and so is the forum (though it 
maintains its own copy of the DB).


Are you saying the forum could have an edit feature?


No.

The mailing list and forum should be identical.


Mailing lists are used by old fools, i really see no reason why d 
cannot have normal solution like invision power suite.


Re: stb bindings for D

2018-05-06 Thread Temtaime via Digitalmars-d-announce

On Sunday, 6 May 2018 at 09:22:00 UTC, Sisor wrote:

On Sunday, 6 May 2018 at 08:57:11 UTC, Temtaime wrote:

Oh, missed the link

https://code.dlang.org/packages/stb


Not everybody (including me) knows what stb is. So please add 
some brief description (with a link) to the documentation.


Ok, a link was added, thanks !

https://github.com/nothings/stb

Generally speaking stb is a set of libraries for various purposes.
There's some very useful libraries for 3d games, for example rect 
pack, image loading


Re: stb bindings for D

2018-05-06 Thread Temtaime via Digitalmars-d-announce

Oh, missed the link

https://code.dlang.org/packages/stb


stb bindings for D

2018-05-06 Thread Temtaime via Digitalmars-d-announce

Hello !
Recently i published stb bindings for D, it comes with 
precompiled stb library for windows, so just add this package as 
dependency for your project and work with it :)


Currently there's only stb bindings, but soon i'll add stb_image, 
stb_image write and other useful libraries.


Thanks.
Kind regards.


Re: Beta 2.079.0

2018-02-22 Thread Temtaime via Digitalmars-d-announce

Fuck selective imports.
If you have tons of functions with same name it's your naming 
scheme mistake.
If it makes compilation time slower, then fuck compiler, not 
import std;




Re: Can't cast from void*

2018-02-06 Thread Temtaime via Digitalmars-d-learn

On Tuesday, 6 February 2018 at 08:29:05 UTC, Kagamin wrote:
On Monday, 5 February 2018 at 15:33:02 UTC, Steven 
Schveighoffer wrote:

Is there a more pragmatic use case why this should be possible?


Maybe for least surprise. The error message almost convinced me 
that such cast is impossible, only because of my memory that 
this cast used to be possible kept me trying. Is 5 not good 
because it's not big enough?


Fill a bugreport.


Re: Precise GC state

2018-02-03 Thread Temtaime via Digitalmars-d
And 2k18 passes and there will be no precise gc this year it 
seems.

Great D language. Better to think to move from it away.


Re: Bump the minimal version required to compile DMD to 2.076.1

2018-01-15 Thread Temtaime via Digitalmars-d

And what builds C++ compiler from source ? :)


Re: Article: Fuzzing D code with LDC

2018-01-15 Thread Temtaime via Digitalmars-d-announce

On Saturday, 13 January 2018 at 23:59:52 UTC, Johan Engelen wrote:

It's been a work-in-progress for half a year, but finished now:

http://johanengelen.github.io/ldc/2018/01/14/Fuzzing-with-LDC.html

"A not-so-well-written article about the fuzzing capability 
recently added to LDC, using LLVM’s libFuzzer. Compiling code 
with -fsanitize=fuzzer adds control-flow instrumentation used 
to guide the fuzzing and links-in the libFuzzer library that 
drives the fuzz testing (same as Clang). -fsanitize=fuzzer is 
available from LDC 1.4.0, not on Windows. LDC 1.6.0 was used 
for the examples in this article."


Hope the article gives you enough information to start fuzz 
testing your own projects.


cheers,
  Johan

(per Ali's request, the article has a nice fuzzy font for some 
of you :P)


// `Throwable`s thrown are not bugs (in contrast to `Errors`).

They _can_ be bugs.
class Error : Throwable
class Exception : Throwable


Phobos bindings

2018-01-14 Thread Temtaime via Digitalmars-d

Phobos comes with zlib, curl and sqlite bindings.
Zlib sources come with phobos, so there's no need to build and 
link with it separately.

Why there's no curl and sqlite sources ?

For example sqlite comes as 1 file. I think we can add it too, 
isn't it ?


Re: Compiler bug or incorrect usage for pointer of Struct?

2018-01-14 Thread Temtaime via Digitalmars-d

On Sunday, 14 January 2018 at 13:24:14 UTC, Heromyth wrote:

On Sunday, 14 January 2018 at 08:05:34 UTC, Temtaime wrote:

On Sunday, 14 January 2018 at 04:02:09 UTC, Heromyth wrote:
On Saturday, 13 January 2018 at 14:11:23 UTC, H. S. Teoh 
wrote:
On Sat, Jan 13, 2018 at 12:22:17PM +, Heromyth via 
Digitalmars-d wrote: [...]




https://run.dlang.io/is/RUHtqK
It's not ok dude
It runs because you don't use any variable inside the struct 
and because struct members are simple functions with hidden 
parameter


Thanks. It's really dangerous to use a pointer to struct!

I have created another test based on your code. See here 
https://run.dlang.io/is/LOeMKG


I add *ref* in the constructor and add a new template fucntion 
writerFor. So, it goes back the scenario in my first post.


Tester tester = new Tester(buildWriter()); 	// can't compile. 
The compiler does the right thing.


Tester tester = writerFor(buildWriter());	// Here is a bug, 
because the compiler takes this!


Am I right?


There's no bug in compiler.
"auto ref" can be NOT a reference. It depends on its parameter. 
RValues are passed by value.


given

writerFor(buildWriter());

it becomes

auto writerFor(OutRange)(OutRange outRange) // NO REF, parameter 
is on the stack

{
auto res = new Tester(outRange);
return res;
}

and after writerFor the returned object points on a variable 
inside writerFor which already died


Re: Compiler bug or incorrect usage for pointer of Struct?

2018-01-14 Thread Temtaime via Digitalmars-d

On Sunday, 14 January 2018 at 04:02:09 UTC, Heromyth wrote:

On Saturday, 13 January 2018 at 14:11:23 UTC, H. S. Teoh wrote:
On Sat, Jan 13, 2018 at 12:22:17PM +, Heromyth via 
Digitalmars-d wrote: [...]

auto writerFor(OutRange)(auto ref OutRange outRange)
{
auto res = Writer!(OutRange)();
res.setSink(outRange);
return res;
}

struct Writer(OutRange)
{
private OutRange* output;

void setSink(ref OutRange output)
{
this.output = 

[...]

Here's the bug.  `output` refers to a local variable 
(parameter) in
writerFor(), which goes out of scope after writerFor() exits, 
so

this.output becomes a dangling pointer.


T


I have another test. It runs whithout any error. Here it is:

import std.stdio;

void main()
{
Tester tester = new Tester(buildWriter());
tester.run("It's OK");
}

struct StringWriter
{
void put(string s)
{
writeln(s);
}
}

StringWriter buildWriter()
{
return StringWriter();
}

class Tester
{
private StringWriter* writer;

this(StringWriter w)
{
writer = 
writer.put("ok");
}

void run(string m)
{
writer.put(m);
}
}


https://run.dlang.io/is/RUHtqK
It's not ok dude
It runs because you don't use any variable inside the struct and 
because struct members are simple functions with hidden parameter


Re: Compiler bug or incorrect usage for pointer of Struct?

2018-01-13 Thread Temtaime via Digitalmars-d

On Saturday, 13 January 2018 at 12:22:17 UTC, Heromyth wrote:
When executing the test code, it will exit abnormally. It seems 
*this.output* is pointing a free memory when executing 
*writer.write(dom)*.


I'm not sure whether there is a bug in the compiler. If it is, 
I can file a bug. If not, somebody can tell me how to fix this.


Thanks!

Here is my test code (You can test it in 
https://run.dlang.io/is/0OPBVI):


==
import std.stdio;

void main()
{
bugTest();
}

// This code is stripped from 
https://github.com/Kozzi11/experimental.xml/blob/master/source/std/experimental/xml/writer.d

void bugTest()
{
string dom = "XML DOM";

auto file = File("catalogue.xml", "w");

// It's OK
// auto textWriter = file.lockingTextWriter;
// textWriter.writerFor.write(dom);

// There's a bug
auto writer = writerFor(file.lockingTextWriter);
writer.write(dom);

file.close();
}

auto writerFor(OutRange)(auto ref OutRange outRange)
{
auto res = Writer!(OutRange)();
res.setSink(outRange);
return res;
}

struct Writer(OutRange)
{
private OutRange* output;

void setSink(ref OutRange output)
{
this.output = 
writeln("in setSink: ", this.output);
}

// void setSink(typeof(output) output)
// {
//  this.output = output;
// }

void write(string s)
{
writeln("in write: ", output);
output.put(s);
}
}


It's your bug.
file.lockingTextWriter does not return a reference.
It is passed to writerFor as a copy on the stack and in setSink 
you get a pointer of a stack variable that gets killed after 
writerFor returns.




Re: Documentation of object.destroy

2018-01-02 Thread Temtaime via Digitalmars-d

On Tuesday, 2 January 2018 at 14:39:52 UTC, Johan Engelen wrote:

On Tuesday, 2 January 2018 at 14:22:06 UTC, Temtaime wrote:


Why not zerofy the object ?


Please keep the discussion on the topic of documentation, 
thanks.


-Johan


Documentation does not correspond with the actual behavior, so 
fill a PR and that's all.

Then why even this topic is created ?


Re: Article: Finding memory bugs in D code with AddressSanitizer

2017-12-26 Thread Temtaime via Digitalmars-d-announce

The main font is very ugly.
Code font looks ok tw.


Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Temtaime via Digitalmars-d-learn

On Monday, 25 December 2017 at 14:37:01 UTC, Mengu wrote:

On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote:
Does to!(string)(char[]) do any memory allocation on 
conversion or is this similar to a cast or what else?


yes, it is allocating memory. you can test such cases with 
@nogc [0].


you can get a char[] via .dup of a string and then you can 
cast(string) if you don't want to allocate any memory.


[0] https://dlang.org/spec/attribute.html#nogc


dup allocates memory too


Re: Does to!(string)(char[]) do any memory allocation on conversion?

2017-12-25 Thread Temtaime via Digitalmars-d-learn

On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote:
Does to!(string)(char[]) do any memory allocation on conversion 
or is this similar to a cast or what else?


It is translated to idup.
So yes, it allocates memory.


Re: Translation of documentation

2017-12-23 Thread Temtaime via Digitalmars-d

On Saturday, 23 December 2017 at 16:33:46 UTC, Andrey wrote:

Hello!
I would like to make a small contribution to D. I want and I'm 
ready to begin a translation of documentation 
(https://dlang.org/spec/spec.html) from English into Russian.

What should I do to implement it?

Best regards, Andrey.


Every programmer knows English. For which purpose are you doing 
that ?

Better try to improve existing documentation.


Re: No of threads

2017-12-20 Thread Temtaime via Digitalmars-d-learn

On Wednesday, 20 December 2017 at 13:41:06 UTC, Vino wrote:

On Tuesday, 19 December 2017 at 18:42:01 UTC, Ali Çehreli wrote:

On 12/19/2017 02:24 AM, Vino wrote:
> Hi All,
>
>Request your help in clarifying the below. As per the
document
>
> foreach (d; taskPool.parallel(xxx)) : The total number of
threads that
> will be created is total CPU -1 ( 2 processor with 6 core :
11 threads)
>
> foreach (d; taskPool.parallel(xxx,1)) : The total number of
threads that
> will be created is total CPU -1 ( 2 processor with 6 core :
12 threads)

That parameter is workUnitSize, meaning the number of elements 
each thread will process per work unit. So, when you set it to 
100, each thread will work on 100 elements before they go pick 
more elements to work on. Experiment with different values to 
find out which is faster for your work load. If each element 
takes very short amount of time to work on, you need larger 
values because you don't want to stop a happy thread that's 
chugging along on elements. It really depends on each program, 
so try different values.


> foreach (d; taskPool.parallel(xxx,20)) : As in Windows 2008
whatever
> value is set for the parallel the total number of threads
does not
> increase more than 12.

taskPool is just for convenience. You need to create your own 
TaskPool if you want more threads:


import std.parallelism;
import core.thread;
import std.range;

void main() {
auto t = new TaskPool(20);
foreach (d; t.parallel(100.iota)) {
// ...
}
Thread.sleep(5.seconds);
t.finish();
}

Now there are 20 + 1 (main) threads.

Ali


Hi Ali,

 Thank you very much, below are the observations, our program 
is used to calculate the size of the folders, and we don't see 
any improvements in the execution speed from the below test, 
are we missing something. Basically we expected the total 
execution time for the test 2 , as the time taken to calculate 
the size of the biggest folder + few additional mins, the 
biggest folder size is of 604 GB.  Memory usage is just 12 MB, 
whereas the server has 65 GB and hardly 30% - 40% is used at 
any given point in time, so there is no memory constrain.



Test 1:
foreach (d; taskPool.parallel(dFiles[],1))
auto SdFiles = Array!ulong(dirEntries(d, SpanMode.depth).map!(a 
=> a.size).fold!((a,b) => a + b) (x))[].filter!(a => a  > Size);


Execution Time is 26 mins with 11+1 (main) threads and 1 
element per thread


Test 2:
auto TL = dFiles.length;
auto TP = new TaskPool(TL);
foreach (d; TP.parallel(dFiles[],1))
auto SdFiles = Array!ulong(dirEntries(d, SpanMode.depth).map!(a 
=> a.size).fold!((a,b) => a + b) (x))[].filter!(a => a  > Size);

Thread.sleep(5.seconds); TP.finish();

Execution Time is 27 mins with 153+1 (main) threads and 1 
element per thread



From,
Vino.B


GC collect stops the worlds so there's no gain.


Re: Tried C++ to D. Wrong result.

2017-11-28 Thread Temtaime via Digitalmars-d-learn

On Tuesday, 28 November 2017 at 06:46:18 UTC, Dmitry wrote:

On Monday, 27 November 2017 at 19:01:28 UTC, Ali Çehreli wrote:
P.S. I think you have an unnecessary 'ref' on the D version 
because a slice is already a reference to elements:

Fixed, thank you.


https://pastebin.com/xJXPBh0n
Converted it and it works as expected.


Re: Precise GC state

2017-11-27 Thread Temtaime via Digitalmars-d
Please stop this flame and make first real step into bringing 
precise GC to us.
Current GC in D is shit and all this speaking won't improve 
situation.

The PR is not merged although it passed all the tests.


Re: reduce condition nesting

2017-11-23 Thread Temtaime via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana 
wrote:
On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe 
wrote:

On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:

for instance in kotlin it can be replace with this:

when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else -> someDefault()
}


The `switch` statement covers some of these cases too.


Anyway you can create something like this:
https://run.dlang.io/is/7pbVXT


Syntax #4

 // Syntax #4
when
(
c1, { writeln("first");   },
c2, { writeln("second"); },
{ writeln("default"); }   
);

:)


Precise GC state

2017-11-22 Thread Temtaime via Digitalmars-d

Hi all !
https://github.com/dlang/druntime/pull/1603

Can someone investigate and bring it to us ?
4 years passed from gsoc 2013 and there's still no gc.
Many apps suffers from false pointers and bringing such a gc will 
help those who affected by it.
It seems all the tests are passed except win32 because of optlink 
failures.

Maybe there's some chance to accelerate this PR ?

Thanks all


Re: Bloat in Executable

2017-11-17 Thread Temtaime via Digitalmars-d
On Thursday, 16 November 2017 at 03:58:38 UTC, Adam D. Ruppe 
wrote:
On Thursday, 16 November 2017 at 03:32:26 UTC, codephantom 
wrote:

23k executable if 32bit (i.e. -m32 )


It is the statically linked C library. Note that if you remove 
the call to printf, the size is slashed in half.


Windows traditionally didn't do a system-wide C lib, but rather 
the various compiler vendors would do their own. To keep this 
from being a big pain for the end user, static linking can be 
employed as it apparently is with Digital Mars.



112k executable if 64bit (i.e. -m64 )


I'm not 100% sure this is the same, but I suspect it probably 
is.



.. on freebsd ..
5.6k executable if 32bit (i.e. -m32 )


If you ldd that, you'll see it dynamically links the C library. 
The downside of this is there's less binary compatibility 
across major versions; you are liable to need to recompile from 
source to deal with different libc versions on the system, 
whereas the Windows builds are more likely to just work.


There is system-wide C library. It is named msvc.dll.
TCC uses it producing very small executables.


Re: minElement on array of const objects

2017-11-13 Thread Temtaime via Digitalmars-d-learn
On Monday, 13 November 2017 at 10:20:51 UTC, Aurelien Fredouelle 
wrote:

Hi all,

It seems that it is not possible to use minElement on an array 
of const objects:


class A
{
  int val;
}

const(A) doStuff(const(A)[] v)
{
  import std.algorithm.searching : minElement;
  return v.minElement!"a.val";
}

This gets the following compiler error:

std/algorithm/searching.d(1256,28): Error: cannot implicitly 
convert expression (front(r)) of type const(A) to app.A
std/algorithm/searching.d(1286,35): Error: cannot implicitly 
convert expression (r[i]) of type const(A) to app.A
std/algorithm/searching.d(1258,36): Error: template instance 
std.algorithm.searching.extremum!("a.val", "a < b", const(A)[], 
A) error instantiating
std/algorithm/searching.d(3345,24):instantiated from 
here: extremum!("a.val", "a < b", const(A)[])
source/app.d(11,11):instantiated from here: 
minElement!("a.val", const(A)[])


Is there a reason why this is not allowed? Shouldn't minElement 
be able to return a const(A) in this situation?


Thanks,
Aurelien


It should not until it uses recursion to find min element.

const(Class) res = ...;
...
return res;

Algorithm tries to assign to res variable and fails because in D 
const(Class) means both const object and const reference to it. 
So we cannot assign another reference to const(Class) variable.


Re: Deprecate implicit `int` to `bool` conversion for integer literals

2017-11-12 Thread Temtaime via Digitalmars-d
On Sunday, 12 November 2017 at 16:00:28 UTC, Ola Fosheim Grøstad 
wrote:
On Sunday, 12 November 2017 at 13:34:50 UTC, Dmitry Olshansky 
wrote:

if (a & (flag1 | flag2))

to

if ((a & (flag1 | flag2)) != 0)

When the first is quite obvious.


Just change the typing of the if-conditional to:

if (boolean|integral) {…}


There's no force change.
if explicitly converts cond to bool.


Re: Bug or "hidden" feature?

2017-11-06 Thread Temtaime via Digitalmars-d

On Monday, 6 November 2017 at 09:44:24 UTC, bauss wrote:
If a function has an UDA you don't need to give the function a 
return type.


Is that a bug or a hidden feature?

Example:

```
import std.stdio;

struct A { }

@A test()
{
writeln("Called test()");
}

@A test2()
{
return true;
}

void main()
{
test();
writeln(test2());
}
```


Feature as return type is not necessary and considered auto when 
some qualifiers are added


const foo() {}

@property foo() {}

etc


Re: SublimeLinter-contrib-dmd: dmd feedback as you type

2017-11-02 Thread Temtaime via Digitalmars-d-announce
On Thursday, 2 November 2017 at 09:43:11 UTC, Bastiaan Veelo 
wrote:
On Thursday, 2 November 2017 at 09:26:48 UTC, Bastiaan Veelo 
wrote:
Does dmd give the error message you expect when you call dmd 
on that particular file by hand? The linter uses these command 
line switches: -o- -w -wi -vcolumns.


How long does that take? Could be timeout...


Takes about 3s to compile single file.

Sorry, figured out an error : missed some include path for dub 
package.

Support for dub will be great :)

Now all works
Thanks !


Re: SublimeLinter-contrib-dmd: dmd feedback as you type

2017-11-02 Thread Temtaime via Digitalmars-d-announce
On Thursday, 2 November 2017 at 06:43:36 UTC, Bastiaan Veelo 
wrote:

On Wednesday, 1 November 2017 at 20:09:02 UTC, Temtaime wrote:

Works too strange.
Seems it checks only syntax and doesn't display non-syntax 
related errors.


Also, what is your compiler version, OS, and do you have other 
plugins active?


No way to post a reduced example.
I tried it with one-file test example and it displays all the 
errors correctly, but in my projects with 30 KLOCS it displays 
only syntax erorrs.


DMD from git master branch, windows, no other plugins.


Re: SublimeLinter-contrib-dmd: dmd feedback as you type

2017-11-01 Thread Temtaime via Digitalmars-d-announce

Works too strange.
Seems it checks only syntax and doesn't display non-syntax 
related errors.


Re: Temporary objects as function parameters or when-is-this-shit-going-to-end?

2017-10-13 Thread Temtaime via Digitalmars-d-learn

On Friday, 13 October 2017 at 11:21:48 UTC, Biotronic wrote:
On Friday, 13 October 2017 at 10:35:56 UTC, Jack Applegame 
wrote:
Compiler creates struct on the stack and silently (without 
postblitting and destruction old object) moves it to another 
address. Is it normal? I don't think so.


It is. Structs have no identity, and the compiler/GC/whatever 
is free to copy and/or move them about as it sees fit (as long 
as there is ostensibly only one - no duplicate 
constructor/destructor calls, no desynching of state). That's 
why the documentation[1] says not to have internal pointers in 
structs.


WAT??? Compiler creates struct on the stack copies it without 
postblitting and destructs both objects.


Now this looks like a real bug. There should be a this(this) 
call in there.


Can I donate to the D Foundation and that my donations would 
be aimed at fixing exactly these bugs?


BountySource[2] lets you do basically exactly that.

[1]: https://dlang.org/spec/garbage.html, "Do not have pointers 
in a struct instance that point back to the same instance."


[2]: https://www.bountysource.com/


What are the advantages of this weird behavior ?
Also if the object is finally moved then why to call ctor not on 
the moved object ?
[1] states that i cannot save the pointer inside the struct on 
the same struct(because GC can move objects in the memory, but in 
the example there's no gc as objects are on the stack), but what 
if i put  to some global variable ? It should work as 
expected, not being partly moved. Postblit should be called as 
well as dtor of original object.


1 is a definitely a bug.



Re: in for testing

2017-08-26 Thread Temtaime via Digitalmars-d

On Saturday, 26 August 2017 at 21:50:14 UTC, Johnson wrote:

while(str[i] in [' ', '\r', ...])

rather than having to do each test individually.


while(str[i].among(' ', '\r', ...))


Re: Dynamic array leak?

2017-08-12 Thread Temtaime via Digitalmars-d

On Friday, 11 August 2017 at 22:36:27 UTC, bitwise wrote:

On Friday, 11 August 2017 at 19:01:44 UTC, Yuxuan Shui wrote:

On Friday, 11 August 2017 at 18:44:56 UTC, bitwise wrote:
[...]

My guess is a pointer to the array still lives somewhere on 
the stack. This gives the expected output:


void f()
{
S[] x = [S(1), S(1)];
writeln("GC allocated: ", (GC.addrOf(x.ptr) !is null));
x = null;
}

int main(string[] argv)
{
f();
GC.collect();
writeln("live objects: ", S.count);
return 0;
}


Makes sense. I was uncommenting unit tests one-by-one after 
making some changes when I triggered this. I guess they were 
passing before because subsequent unit tests cleared the 
pointers off the stack. I guess I can just call a function that 
allocates a large zeroed-out array on the stack in the last 
unit test before checking the count if this happens again.


  Thanks


Collect - is a hit to the GC, not an order. It can ignore this 
request.
Also do not rely on the gc calling a dtor - it is not safe and 
can be called totally randomed, so use RC instead or expicit 
destroy()


Re: Format g bug ?

2017-08-09 Thread Temtaime via Digitalmars-d-learn

Sorry, messed up numbers

Expected:

3.11
3.11
3.1
3.1

Seems g outputs one digit less


Format g bug ?

2017-08-09 Thread Temtaime via Digitalmars-d-learn

import std.stdio;

void main()
{
writefln(`%.2g`, 3.11);
writefln(`%.2f`, 3.11);

writefln(`%.1g`, 3.11);
writefln(`%.1f`, 3.11);
}


3.1
3.11
3
3.1

But expected

3.1
3.11
3.1
3.11


Re: lambda function with "capture by value"

2017-08-05 Thread Temtaime via Digitalmars-d-learn

On Saturday, 5 August 2017 at 19:19:06 UTC, Simon Bürger wrote:

On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote:

Maybe std.functional.partial can help you.


Nope.

int i = 1;
alias dg = partial!(writeln, i);
i = 2;
dg();

still prints '2' as it should because 'partial' takes 'i' as a 
symbol, which is - for this purpose - kinda like "by reference".


Anyway, I solved my problem already a while ago by replacing 
delegates with custom struct's that implement the 
call-operator. I started this thread just out of curiosity, 
because as I see it, the purpose of lambdas is pretty much to 
remove the need for such custom constructions.


This one works

void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
{
(k){ dgs[k] = {writefln("%s", k); }; }(i);
}

dgs.each!(a => a());


Re: Getting enum from value

2017-08-05 Thread Temtaime via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel 
wrote:

Any ideas?


You can use to! in std.conv:


import std.stdio;
import std.conv;

enum Foo
{
A = "A",
B = "B"
}

void main()
{
writeln("A".to!Foo);  
}


Are you fools ?
Did you ever read the post ?

I think this is a minimal solution:

enum Foo
{
A = "AV",
B = "BV",
C = "CV",
}

Foo K = [ EnumMembers!Foo ].find!(a => a == `BV`)[0];


Re: Why free and realloc seem to include .

2017-08-03 Thread Temtaime via Digitalmars-d-learn

On Thursday, 3 August 2017 at 14:03:56 UTC, Michael wrote:
So this might be a bit of a stupid question, but looking at the 
DMD source code (dmodule.d in particular) I see the following 
code:



if (srcfile._ref == 0)
   .free(srcfile.buffer);
srcfile.buffer = null;
srcfile.len = 0;


and I was just wondering why certain functions seem to be 
called using the dot operator on its own, unattached to some 
object. This is probably a naive question but I haven't seen 
this in my limited experience using D and I was just wondering 
why this is. I have only really seen this relating to D's 
manual memory management. But in the same file, I see examples 
like this:



FileName.free(n);


so what is the case when you should use .free() and why not 
just free()? Thanks.


Dot is equal to C++'s :: operator to access a global namespace.
Aka ::free(ptr);


Re: dlang-requetst: openssl 1.1 compatible release

2017-08-03 Thread Temtaime via Digitalmars-d-announce

On Thursday, 3 August 2017 at 09:57:11 UTC, Suliman wrote:

On Thursday, 3 August 2017 at 06:33:38 UTC, ikod wrote:

Hello,

Since version 0.5.0 dlang-requests has become compatible with 
both 1.0.x and 1.1.x versions of openssl library.


Please try and report any issues on github.
Thanks!

dlang-requests is HTTP/FTP client library, inspired by 
python-requests with goals:


small memory footprint
performance
simple, high level API
native D implementation

https://code.dlang.org/packages/requests
https://github.com/ikod/dlang-requests


Vote for including it in Phobos instead curl!


Curl is well-tested and has a great number of features.


Re: newCTFE Status July 2017

2017-07-31 Thread Temtaime via Digitalmars-d

On Sunday, 30 July 2017 at 20:40:24 UTC, Stefan Koch wrote:

On Thursday, 13 July 2017 at 12:45:19 UTC, Stefan Koch wrote:

[...]


Hello Guys,

The bug preventing newCTFE from executing bf_ctfe[1] correctly  
(a peculiarity in which for for and if statement-conditions  
other then 32bit integers where ignored) is now fixed.


[...]


Aren't you disabling codegen by passing a -o- to your engine, so 
it starts to compile faster?


Re: Static array * scalar is not working for me

2017-07-30 Thread Temtaime via Digitalmars-d-learn

On Sunday, 30 July 2017 at 08:18:07 UTC, Danni Coy wrote:

The following code is not working for me

float[3] f;
f[] = abs(f)[] * -1.0f;
where abs is a function that returns a float[3];

it complains that f should be attached to some memory.

Is it a bug or am I missing something?


This is unimplemented currently and no one cares about it.

You can do:

f[] = abs(f)[];
f[] *= -1;


Re: Accessing memory after destroy

2017-07-30 Thread Temtaime via Digitalmars-d

On Sunday, 30 July 2017 at 07:58:19 UTC, ketmar wrote:

Johan Engelen wrote:


[...]


afair, somewhere in the spec there is a mention that dtor will 
be called at most once for each initialized object. and object 
state doesn't have any sense after calling dtor, but D still 
has to put something there, so `.init` looks like a reasonable 
choice. althru i'm not sure that anything in specs says that 
runtime *must* clear destroyed objects (they aren't really 
usable after calling dtor anyway, it is at least a logical bug 
to use object after destroying it).


Seems that zeroing it out is better choice, maybe.


Re: Profiling after exit()

2017-07-28 Thread Temtaime via Digitalmars-d-learn

On Friday, 28 July 2017 at 08:06:33 UTC, Eugene Wissner wrote:

On Friday, 28 July 2017 at 06:32:59 UTC, Jacob Carlborg wrote:

On 2017-07-27 16:30, Eugene Wissner wrote:
I have a multi-threaded application, whose threads normally 
run forever. But I need to profile this program, so I compile 
the code with -profile, send a SIGTERM and call exit(0) from 
my signal handler to exit the program. The problem is that I 
get the profiling information only from the main thread, but 
not from the other ones.


Is there a way to get the profiling information from all 
threads before terminating the program? Maybe some way to 
finish the threads gracefully? or manully call "write 
trace.log"-function for a thread?


As others have mentioned, you should in general avoid calling 
"exit" in a D program. There's a C function called "atexit" 
that allows to register a callback that is called after 
calling "exit". You could perhaps join the threads there. I 
don't know if that helps with the profiling though.


Unfortunately I can't join threads, because the program 
wouldn't exit then, the threads run forever normally. I thought 
maybe there is some way to kill a thread gracefully in linux, 
so it can write its profiling information; or another way to 
get profiling.

Thanks anyway.


There's no "gracefully" way to kill a thread.
If your thread cannot join, then you're doing something wrong


Re: Profiling after exit()

2017-07-27 Thread Temtaime via Digitalmars-d-learn
Also there was an issue that profiling doesn't work with 
multi-threaded apps and leads to a crash.

Don't know if it is fixed.


Re: Profiling after exit()

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

Exit is not "normal exit" for D programs so, do not use it.
Your threads should stop at some point to make able the app exit 
successfully.

There's a "join" method. You can use it with your "done" variable.


Re: Why can't typeof() be used in member method?

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

On Wednesday, 26 July 2017 at 19:06:24 UTC, Andre Pany wrote:

On Wednesday, 26 July 2017 at 17:04:59 UTC, Adam D. Ruppe wrote:

On Wednesday, 26 July 2017 at 16:50:35 UTC, Andre Pany wrote:

[...]


FYI, you shouldn't use .stringof here. Just use `T` instead of 
`T.stringof`.


[...]


Thank you so much!

Kind regards
André


There's another method for such a check.

mixin(`static if (!is(typeof(T.`~p.name~`



Re: How can I serialize a struct into a file in the style of C?

2017-07-23 Thread Temtaime via Digitalmars-d-learn

Hi !
I have a dub package that doing this.

https://github.com/Temtaime/tt-utils/blob/master/source/tt/binary/tests.d

Have a look at the tests.
Currently it has no documentation, but feel free to ask questions


Re: New Garbage Collector?

2017-07-23 Thread Temtaime via Digitalmars-d

On Saturday, 22 July 2017 at 16:35:03 UTC, Igor Shirkalin wrote:

On Saturday, 22 July 2017 at 10:17:49 UTC, Temtaime wrote:

On Saturday, 22 July 2017 at 04:53:17 UTC, aedt wrote:
In the forum, I saw a thread about someone working on a new 
GC. Just wanted to know if there's any updates on that. And 
what issues is it going to fix..


Personally, I would be greatly delighted if it acknowledges 
the Stop-The-World problem[1]. Going around it is shown not 
to be impossible[2]. I do understand it's not trivial task 
but how is the community/core devs supporting this?


[1] https://dlang.org/spec/garbage.html
[2] https://hub.docker.com/r/nimlang/nim/


The new precise GC will be never added to druntime.
It is dead, man.


Are you real developer of new GC?


I am that who sees _no progress_ for many years. Current 
implementation does memory leaks, works slow and has some other 
disadvantages.
But no one of the « real » developers sees reason to rewrite the 
gc, because they want to play with theirs toys bringing new not 
so essential stuff to the d.

And we will suffer from this many years.


Re: New Garbage Collector?

2017-07-22 Thread Temtaime via Digitalmars-d

On Saturday, 22 July 2017 at 04:53:17 UTC, aedt wrote:
In the forum, I saw a thread about someone working on a new GC. 
Just wanted to know if there's any updates on that. And what 
issues is it going to fix..


Personally, I would be greatly delighted if it acknowledges the 
Stop-The-World problem[1]. Going around it is shown not to be 
impossible[2]. I do understand it's not trivial task but how is 
the community/core devs supporting this?


[1] https://dlang.org/spec/garbage.html
[2] https://hub.docker.com/r/nimlang/nim/


The new precise GC will be never added to druntime.
It is dead, man.


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

2017-07-18 Thread Temtaime via Digitalmars-d

On Tuesday, 18 July 2017 at 16:34:39 UTC, unDEFER wrote:

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.


The forum is not a bugtracker



Re: Optilink bugs(or DMD)

2017-04-19 Thread Temtaime via Digitalmars-d

On Wednesday, 19 April 2017 at 15:15:21 UTC, Nierjerson wrote:

On Wednesday, 19 April 2017 at 04:25:40 UTC, Stefan Koch wrote:

On Wednesday, 19 April 2017 at 03:52:54 UTC, Nierjerson wrote:
Major optilink bugs, blocker. Code is long but demonstrates 
the issue. Compiles with ldc.


[...]


There are two instances of void ForegroundColor(cSolidColor 
rhs)


Well, that could be a problem with the code, but it does 
compile with LDC so LDC then has an issue or dmd/optilink has 
the issue. Something is wrong. But, I guess removing the 
duplicates should at least allow dmd to compile the code.


DMD compiles the code too. The code doesn't link.
Optlink forbids duplicates, but ldc uses msvc link and it allows 
them(as i remember, it shows a warning).


Re: Duplicated functions not reported?

2017-04-16 Thread Temtaime via Digitalmars-d-learn

On Sunday, 16 April 2017 at 15:54:16 UTC, Stefan Koch wrote:

On Sunday, 16 April 2017 at 10:56:37 UTC, Era Scarecrow wrote:

On Saturday, 15 April 2017 at 11:10:01 UTC, Stefan Koch wrote:

It would requires an O(n^2) check per declaration.
Even it is never used.
which would make imports that much more expensive.


 Seems wrong to me...

 If you made a list/array of all the functions (based purely 
on signatures) then sorted them, then any duplicates would be 
adjacent. Scanning that list would be O(n-1).


 This assumes it's done after all functions are scanned and 
identified, doing it earlier is a waste of time and energy.



sorting has O(n^2) worst case complexity.
Therefore totaling to O(n^2) worst case again.


Why this difficulty ?
Function[args][name] funcs;

AA lookup is O(1).


Re: Phobos and LTO

2017-03-07 Thread Temtaime via Digitalmars-d

On Sunday, 5 March 2017 at 19:52:12 UTC, Daniel Kozak wrote:

Dne 5.3.2017 v 20:31 Temtaime via Digitalmars-d napsal(a):


On Sunday, 5 March 2017 at 17:17:13 UTC, Las wrote:

Is Phobos compiled with LTO enabled?


There is no LTO with D.

Yes it is
https://johanengelen.github.io/ldc/2016/11/10/Link-Time-Optimization-LDC.html


Being specific only for LDC and only on linux - it's a lie to say 
simple « yes ».


Re: Phobos and LTO

2017-03-05 Thread Temtaime via Digitalmars-d

On Sunday, 5 March 2017 at 17:17:13 UTC, Las wrote:

Is Phobos compiled with LTO enabled?


There is no LTO with D.


Re: CTFE Status 2

2017-02-17 Thread Temtaime via Digitalmars-d

On Thursday, 16 February 2017 at 21:05:51 UTC, Stefan Koch wrote:
Hi Guys, due to the old CTFE status thread getting to page 30, 
I am now starting a new one.


First let me summerize which features are currently working:
In order of date, the latest features come first.

- fixed continue and break for DoWhileStatements
- non-toplevel Function Pointers as arguments
- basic function pointers
--- phobos, druntime & dmd unit-tests pass 
- Method Calls (now range foreach will work)
- 1-level Pointers
- recursive function calls
- fixed continue and break for ForStatements (includes foreach 
which is lowered)

- basic Function Calls
- static immutable globals
- fixed continue & break for WhileStatemens
- 1d array literals
- ternary expressions ? :
- struct literals.
- basic struct support.
- Slice and Array boundschecks
- 1d array and slice indexing
- do while statements
- break and continue support
- gotos and labels
- foreach over arrays
- for statements
- integer math
 (and I few a forgot to list)

unsupported features are
- anything with strings (due to missing unicode handling)
- slicing & concat (due to missing memeory-manager)
- floating point math
- classes (due to missing vtbl and ref support)
- exceptions (due to missing stack-unwinding support and 
side-band channels)
- more complex structs i.e. with struct-members (due to 
incomplete type-handling)

---

Currently I am having trouble caused by a bug in dmds inliner 
that only happens on when dmd is compiled as a 32bit executable 
until I have  isolated / fixed this development is slowed down.


--
I hope this thread is informative and will continue to be that 
way.


Cheers,
Stefan (aka UplinkCoder)


Just get LDC.
Make it use JIT.
And you'll get all the features working.
Writing slow interpreter is ... wasting efforts.


Re: A betterC modular standard library?

2016-12-18 Thread Temtaime via Digitalmars-d
On Sunday, 18 December 2016 at 09:26:09 UTC, Ilya Yaroshenko 
wrote:

Hi,

Who is interested in betterC _modular_* standard library?
I am planing to make libmir org a community for it.
Thought and concerns?

We already have better `cpuid` and better `random` packages. 
The betterC std.range and std.algorithm analogs would be 
released with new ndslice implementation. Mir's algorithm would 
be faster then Phobos and will generate less template bloat. 
Then lightweight threads, multithread GLAS, matrix inversion. 
Fastest I/O and http2 ...


(they all are betterC modular libraries)

Andrei and probably 90% of existing D users don't want Phobos 
to move this direction.


In other hand I need a commercial attractive D infrastructure 
for large and heavy system projects. There is no commercial 
perspective for me to contribute to Phobos because:


1. Phobos version depends on compiler version. Delay with LDC 
release is too large. It should / can be one day.


2. We can not do hot fixes in Phobos without compiling and 
deploying patched libphobos. Mir's DUB package are much more 
flexible.


3. Dependencies should be clear. Modularity is a proper way for 
large std library. In phobos everything integrated with 
everything. DRuntime -> Phobos abstraction is weird for betterC 
because system modules can depends universal algorithms, but 
universal algorithm are more portable if they have not system 
dependencies.


4. Phobos does not provide and will not provide betterC 
guaranties. If something works for betterC mode now it may not 
work in the future release.


[1] https://github.com/libmir/
* - separate github/DUB libraries with clear dependencies.

Best regards,
Ilya


Let's write a D, phobos.
Then we drop all the features and use a BetterC mode.
Then we write all modules against betterC mode.


Re: UFCS for arguments other than first?

2016-11-11 Thread Temtaime via Digitalmars-d

On Friday, 11 November 2016 at 16:39:26 UTC, Heisenberg wrote:
What would it take to implement the Uniform Function Call 
Syntax for a function's argument which is not the first?


Right now it is possible to do the following:


int someNumber(int a, int b)
{
return a + b;
}

void main()
{
int n1 = 5;
int n2 = n1.someNumber(n1 + 1); // Here the `n1` is `a`
}


But it's not possible to use the `n1' as `b`, for UFCS only 
substitutes the expression before the `.` for the first 
argument. This limits a little bit the flexibility of UFCS. 
What would it take to specify the argument in which UFCS is 
going to put the expression before the `.`? This would make it 
even more useful.


For instance:


string someStr = "Yohoho!";
// To format and print it, one could use `printf':
writefln("The string is \"%s\".", someStr);
// But since it is not in the first place,
// it is not possible to use UFCS for it:
someStr.writefln("The string is \"%s\"."); // ^ Prints 
`Yohoho!'

// One could use tuples to pass
// the expanded list of strings:
tuple("The string is \"%s\".", someStr)[].writefln();
// But it would be much easier if there was
// some way to tell the compiler
// to position the argument,
// for example:
someStr&1.writefln("The string is \"%s\".");
// ^^ argument at the position [0]
// ^ argument to be put at the position [1]
// This could even allow to insert the argument
// at more than one position at once:
someStr&1&3&4.writefln("Say it, lass!\n" ~
   "%s\nI'm a pirate!\n" ~  // someStr 
goes here (1)

   "%s\nHe's a pirate!\n" ~ // not here (2)
   "She's a pirate!\n%s" ~  // here (3)
   "Ale! Rum! %s\n" ~   // and here (4)
   "Wait.. Why is the rum gone?",
   "You are a pirate!");// gets shifted
// to position 
(2)


You are wrong. We can use n1 for the second parameter.

int someNumber(int a, int b)
 {
 return a + b;
 }

int main()
{
 int n1 = 5;
 return (n1.someNumber = n1); // 10
 }


Re: newbie problem with nothrow

2016-10-31 Thread Temtaime via Digitalmars-d-learn

On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote:


Is there a way to turn off nothrow or work around it? Because 
to me it looks like nothrow prevents me from doing anything 
useful.


extern(C) void onKeyEvent(GLFWwindow* window, int key, int 
scancode, int action, int modifier) nothrow

{
if(queue.roomInQueue())
{
auto event = new Event;
event.type = EventType.keyboard;
event.keyboard.key = cast(Key) key;

// etc.
}

Error: function 'event_handler.CircularQueue.roomInQueue' is 
not nothrow
Error: function 'event_handler.onKeyEvent' is nothrow yet may 
throw



The compiler wouldn't let me just remove "nothrow" from the 
function. I tried a kludge where I had this function just pass 
all its parameters to another throwable function, but this 
caused errors as well.


So I'm stuck.  Anyone know how to proceed.
Thanks.


Wrap a body of the function to try {} catch {} and it'll work.


Strange bug when doing a custom build of druntime

2016-10-29 Thread Temtaime via Digitalmars-d

Hi !
I'm trying to figure out what happens.

http://pastebin.com/e6HPvjJ4
There's a full command line.

It builds OK and works too.
But there's some strange bug with bounds check.

The code of _d_arraybounds is just:

.text:000140014210 _d_arraybounds proc near; 
CODE XREF: j__d_arrayboundsj

.text:000140014210 pushrbp
.text:000140014211 mov rbp, rsp
.text:000140014214 pop rbp
.text:000140014215 retn

I don't know why dmd ommits _d_arraybounds body. So if app built 
with that druntime tries to access out of bounds element it just 
crashes instead of throwing oob error.
If i remove -release from command line when building druntime all 
seems to be OK.

But i had seen that in win64.mak there's a release switch.

Where can be a problem?
Thanks for a help.


Re: Is there Typeof template ?

2016-10-28 Thread Temtaime via Digitalmars-d-learn

On Friday, 28 October 2016 at 18:39:36 UTC, Ali Çehreli wrote:
On 10/28/2016 11:25 AM, Jonathan M Davis via 
Digitalmars-d-learn wrote:


>> void main() {
>>  @(`str`, 123) uint k;
>>  foreach (a; __traits(getAttributes, k)) {
>>  pragma(msg, typeof(a));
>>  }
>> }

> I don't know if Typeof is actually needed for what the OP is
trying to do,
> but if you wanted to apply typeof using something like
std.meta.staticMap,
> then you'd need something like Typeof.

I see.

Just to add something that I've just remembered, it is possible 
to apply typeof to __traits(getAttributes) as well:


foreach (T; typeof(__traits(getAttributes, k))) {
pragma(msg, T);
}

Now we get a list of types:

string
int

Ali


I wanna use it with staticMap.


Re: Is there Typeof template ?

2016-10-28 Thread Temtaime via Digitalmars-d-learn

On Friday, 28 October 2016 at 12:44:20 UTC, Adam D. Ruppe wrote:

On Friday, 28 October 2016 at 10:52:05 UTC, Temtaime wrote:

Are there something or should I create a PR to phobos?


Why would you want that?


I have UDAs with values à la @(`str`, 123) uint k;

And i want to know a type of a value.


Re: Default struct member initializer ?

2016-10-28 Thread Temtaime via Digitalmars-d

But what about the case when default ctor is disabled ?


Re: Default struct member initializer ?

2016-10-28 Thread Temtaime via Digitalmars-d

On Friday, 28 October 2016 at 11:23:47 UTC, John Colvin wrote:

On Friday, 28 October 2016 at 11:20:50 UTC, Temtaime wrote:

Hi !

Is there such a magic ?

struct S { uint k = 2; }

enum Value = Foo!(S.k); // Value == 2

Thanks.


struct S { int k = 2; }

enum Value = S.init.k;

static assert (Value == 2);


Oh i see, thanks


Default struct member initializer ?

2016-10-28 Thread Temtaime via Digitalmars-d

Hi !

Is there such a magic ?

struct S { uint k = 2; }

enum Value = Foo!(S.k); // Value == 2

Thanks.


Is there Typeof template ?

2016-10-28 Thread Temtaime via Digitalmars-d-learn

Hi !
Tried to find
alias Typeof(alias A) = typeof(A);
or something, but failed.

Are there something or should I create a PR to phobos?
Thanks


Re: Fun: Shooting yourself in the foot in D

2016-10-27 Thread Temtaime via Digitalmars-d

On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:


  
http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html


Some entries for reference:

C
- You shoot yourself in the foot.
- You shoot yourself in the foot and then nobody else can 
figure out what you did.


C++
- You accidentally create a dozen instances of yourself and 
shoot them all in the foot. Providing emergency medical 
assistance is impossible since you can't tell which are bitwise 
copies and which are just pointing at others and saying, 
"That's me, over there."


Python
- You shoot yourself in the foot and then brag for hours about 
how much more elegantly you did it than if you had been using C 
or (God forbid) Perl.


What would the entry for D be? :)

Ali


You create some complicated template function and then compiler 
show you an ICE.


Re: "for" statement issue

2016-10-21 Thread Temtaime via Digitalmars-d

On Friday, 21 October 2016 at 13:42:49 UTC, Adam D. Ruppe wrote:

On Friday, 21 October 2016 at 13:33:26 UTC, Stefan Koch wrote:

[...]


Eh, that's exactly what the language rules say should happen, 
and it actually does make sense to me... you might even want to 
use an immediately-called lambda to group several statements 
together into one expression.


[...]


Please, no.
It's fully clear that { stmts } createa a lambda, just () is 
ommited.


foo({ code; }); is always OK and we shouldn't deprecate it.


Re: Tuple enhancement

2016-10-16 Thread Temtaime via Digitalmars-d

On Sunday, 16 October 2016 at 20:11:01 UTC, Chris Wright wrote:

On Sun, 16 Oct 2016 18:51:06 +, Sebastiaan Koppe wrote:

On Sunday, 16 October 2016 at 13:58:51 UTC, Andrei 
Alexandrescu wrote:
I was thinking it would be handy if tuples had a way to 
access a field by name at runtime. E.g.:


Tuple!(int, "a", double, "b") t;
string x = condition ? "a" : "b";
double v = t.get!string(x, 3.14);


That would mean that tuple then needs to keep the strings 
around - taking up space.


It doesn't change Tuple.sizeof.


That plus the fact that the following code is
equivalent (obviously):

Tuple!(int, "a", double, "b") t;
double v = condition ? t.a : t.b;

Why this addition? What does it enable?


It's a little bit of runtime reflection, which people sometimes 
find handy. There's nothing stopping you from writing it 
manually or with metaprogramming, granted. And if it's just 
tuples, it doesn't seem like much of an advantage.


Please, not. We already have great compile time reflection.


Re: Can you shrink it further?

2016-10-11 Thread Temtaime via Digitalmars-d

On Tuesday, 11 October 2016 at 09:13:10 UTC, Stefan Koch wrote:

On Tuesday, 11 October 2016 at 08:57:46 UTC, Stefan Koch wrote:

On Tuesday, 11 October 2016 at 08:44:04 UTC, Temtaime wrote:


void popFront1(ref char[] s) @trusted pure nothrow
{
  import core.bitop, std.algorithm;
  auto v = bsr(~s[0] | 1);
  s = s[clamp(v, 1, v > 6 ? 1 : $)..$];
}

Seems to be less if i'm not wrong.



Yours runs with 790 us best time.
bsr is a real timetaker :)


CORRECTION this is not bsr's fault.
It's most likely clamp.
I am compiling with dmd and dmd is not as good in optimizing 
when templates are in the mix.


Sorry this was also a type in the code.

void popFront7(ref char[] s) @trusted pure nothrow
{
  import core.bitop;
  auto v = 7 - bsr(~s[0] | 1);
  s = s[v > 6 ? 1 : (v ? (v > s.length ? s.length : v) : 1)..$];
}

Please check this.


Re: Can you shrink it further?

2016-10-11 Thread Temtaime via Digitalmars-d

On Tuesday, 11 October 2016 at 08:17:52 UTC, Stefan Koch wrote:

On Tuesday, 11 October 2016 at 08:03:40 UTC, Stefan Koch wrote:
On Tuesday, 11 October 2016 at 07:30:26 UTC, Matthias Bentrup 
wrote:


A branch-free version:

void popFront4(ref char[] s) @trusted pure nothrow {
  immutable c = s[0];
  uint char_length = 1 + (c >= 192) + (c >= 240) + (c >= 248);
  s = s.ptr[char_length .. s.length];
}

Theoretically the char_length could be computed with three 
sub and addc instructions, but no compiler is smart enough to 
detect that.


You still need to special case c < 128
as well as the follow chars.

also smaller c's are more common the bigger ones making the 
branching version faster on average.


Also the code produces conditional set instructions which have 
a higher latency.

And worse throughput.


void popFront1(ref char[] s) @trusted pure nothrow
{
  import core.bitop, std.algorithm;
  auto v = bsr(~s[0] | 1);
  s = s[clamp(v, 1, v > 6 ? 1 : $)..$];
}

Seems to be less if i'm not wrong.


Re: uuid.d

2016-10-05 Thread Temtaime via Digitalmars-d

On Wednesday, 5 October 2016 at 10:37:20 UTC, Walter Bright wrote:

On 10/5/2016 12:56 AM, Manu via Digitalmars-d wrote:
I do wonder why these uuid's should be in druntime though? The 
suite

present is far from complete, and there are already libs in the
windows ecosystem that have these symbols, so is it really 
useful to

define them in druntime?


I don't know, I didn't write that module.


Please, remove that ugly module.
As was said there's already necessary libraries on windows with 
needed uuids.


Re: Challenge

2016-10-03 Thread Temtaime via Digitalmars-d

On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:

Fill in the blank...
I'm having a really hard time with this. I've made it work with 
a

mountain of code, and I want to see what others come up with...

[...]


Dere's a typo

static assert( isStaticMember!(S, "iosm"), "!");

Should be iosf

Easy:

template isStaticMember(T, string member)
{
static if(__traits(compiles, &__traits(getMember, T, member)))
{
		static if(is(FunctionTypeOf!(__traits(getMember, T, member)) == 
function))

{
			enum isStaticMember = isFunctionPointer!(__traits(getMember, 
T, member)) || isDelegate!(__traits(getMember, T, member)) || 
__traits(isStaticFunction, __traits(getMember, T, member));

}
else
{
			enum isStaticMember = true;//!is(typeof(__traits(getMember, T, 
member).offsetof));

}
}
else
{
enum isStaticMember = false;
}
}


Re: FreeTree posible memory corruption ?

2016-09-28 Thread Temtaime via Digitalmars-d

On Wednesday, 28 September 2016 at 19:55:35 UTC, ag0aep6g wrote:

On Wednesday, 28 September 2016 at 19:39:14 UTC, Temtaime wrote:

[...]


That's not phobos's source. You can find it at 
.



[...]


I've recently fixed two issues in FreeTree's code. I think the 
one you've spotted was one of them. See 
.


Sorry, it was first link from a google :(
Yes, your PR is addressed to this issue.
Thanks!


FreeTree posible memory corruption ?

2016-09-28 Thread Temtaime via Digitalmars-d

Look here :
https://github.com/Hackerpilot/experimental_allocator/blob/master/src/std/experimental/allocator/building_blocks/free_tree.d#L297

It tries to find a block inside the tree. If it fails, it 
allocates n bytes passed to the function.


Look a little down and you see a deallocate method.
It casts previousli allocated block to internal Node struct and 
then tries to set some fields in it.


Suppose we called allocate(1) and it'll call parent allocator 
with size 1. So size of returned block will be 1. Then we 
deallocate such a block, and FreeTree corrupts memory.


Am-I wrong and missed something ?


Re: Required DMD changes for Mir and few thoughts about D future

2016-09-27 Thread Temtaime via Digitalmars-d

On Tuesday, 27 September 2016 at 08:40:38 UTC, Temtaime wrote:
On Tuesday, 27 September 2016 at 01:17:16 UTC, Andrei 
Alexandrescu wrote:

On 9/27/16 2:52 AM, Joakim wrote:
Why not?  I think people will understand that ldc is meant 
for higher

performance, which you want from such code anyway.


I'm not going to argue this much further. Essentially Mir is 
touted as a highly generic and portable library. Having it 
only work on one language implementation works against that 
statement, the credibility of Mir, and the credibility of D as 
an universal platform for creating fast code.


Just let dmd die.


This so-called "reference implementation" makes people suffer 
because of code portability and another differences between the 
compilers (e.g. compiler building, compiler's command line 
arguments, compiler's extensions).


Re: Required DMD changes for Mir and few thoughts about D future

2016-09-27 Thread Temtaime via Digitalmars-d
On Tuesday, 27 September 2016 at 01:17:16 UTC, Andrei 
Alexandrescu wrote:

On 9/27/16 2:52 AM, Joakim wrote:
Why not?  I think people will understand that ldc is meant for 
higher

performance, which you want from such code anyway.


I'm not going to argue this much further. Essentially Mir is 
touted as a highly generic and portable library. Having it only 
work on one language implementation works against that 
statement, the credibility of Mir, and the credibility of D as 
an universal platform for creating fast code.


Just let dmd die.


Anybody fix Issue 15938

2016-09-21 Thread Temtaime via Digitalmars-d

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

It's very annoying.
It forces me to create a shared static ctor's and then i get 
cyclic dependency runtime errors.


Thanks if anybody can make something with it.


Re: LDC 1.1.0-beta2 has been released!

2016-08-05 Thread Temtaime via Digitalmars-d-announce

On Friday, 5 August 2016 at 06:13:54 UTC, Rory McGuire wrote:
On Fri, Aug 5, 2016 at 3:28 AM, Emre Temelkuran via 
Digitalmars-d-announce < digitalmars-d-announce@puremagic.com> 
wrote:



On Wednesday, 3 August 2016 at 20:12:59 UTC, Kai Nacke wrote:


Hi everyone,

LDC 1.1.0-beta2, the LLVM-based D compiler, is available for 
download! This BETA release is based on the 2.071.1 frontend 
and standard library and supports LLVM 3.5-3.9.


We provide binaries for Linux, OX X, FreeBSD, Win32 & Win64, 
Linux/ARM

(armv7hf), now bundled with DUB. :-)

As usual, you can find links to the changelog and the binary 
packages over at digitalmars.D.ldc: 
http://forum.dlang.org/post/nskepdckljprrxsjb...@forum.dlang.org


Regards,
Kai



It should definitely be the reference compiler. Why they're 
wasting power with parallel compilers. :(




Its not wasting, diversity is important. The fact that the 
three "real" D compilers have pretty much the same language 
implementation is an important message to the world about our 
language. GDC is lagging because of man-power yes, but that 
does not mean we're wasting, it just means Ian could do with 
some more help :).


R


Definitely wasting. Have Rust and Go multiple compilers ?


[Phobos request] Op template

2016-07-06 Thread Temtaime via Digitalmars-d

Hi !
I've found that next template will be convenient for use in 
chains and cetera.


Op!`+` == (a, b) => a + b

For example: auto sum = arr.fold!(Op!`+`).

Suggests ?


Re: Looking for D developers, Saint-Petersburg

2016-05-10 Thread Temtaime via Digitalmars-d-announce

On Tuesday, 10 May 2016 at 14:39:27 UTC, drug wrote:
I'm curious are there D developers in Saint Petersburg who 
doesn't mind to make some money?


Я использую D для внутренних инструментов в компании. Сейчас 
масштабы увеличиваются и нужен помощник. Есть согласие 
руководства на использование D и позиция разработчика с вилкой 
40-60 т.р. на руки, трудоустройство в белую, полная/частичная 
занятость, гибкий график, возможна удаленка, но с ней могут 
быть нюансы. Требование высшее техническое (для студентов можно 
и неоконченное, но в первую очередь нужен помощник, а не 
ученик), на удаленке все равно нужна будет возможность 
приезжать в офис.
Помимо D нужно знание opengl 3+ (простая промышленная графика, 
не гейм-индустрия), способности/склонность к 
метапрограммированию (здесь D очень себя проявляет по сравнению 
с C++). Знание теории вероятности и матстатистики будет плюсом. 
Работать c C++ тоже нужно будет.


Если кто подскажет как и где найти людей, буду признателен.



Готов откликнуться, куда можно написать, чтобы узнать подробности?


Re: Always false float comparisons

2016-05-09 Thread Temtaime via Digitalmars-d

On Monday, 9 May 2016 at 12:28:04 UTC, Walter Bright wrote:

On 5/9/2016 4:38 AM, Nordlöw wrote:

Would that include comparison of variables only aswell?

float f = 1.3;
double d = 1.3;
assert(f == d); // compiler warning


No.


Just get rid of the problem : remove == and != from floats.


Re: Checking if an Integer is an Exact Binary Power

2016-04-26 Thread Temtaime via Digitalmars-d

On Tuesday, 26 April 2016 at 16:53:00 UTC, tsbockman wrote:

On Tuesday, 26 April 2016 at 14:37:46 UTC, Marco Leise wrote:

Can we just use __traits(hasTargetFeature, "popcnt") already
and get rid of _popcnt?


No, because DMD does not currently support setting SSE4 as the 
minimum target. Thus, `__traits(hasTargetFeature, "popcnt")` 
must always return `false` at compile time.


As for LDC and GDC - both already treat `popcnt()` as an 
intrinsic, and don't need your proposed change.


It's strange why it emits an branch.

http://goo.gl/jJbSYd
Det version doesn't use cmp and should be fast.


  1   2   >