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

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

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].

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

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

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(),

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

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

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

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() {

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

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

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

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

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

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)

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

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

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

Address of an element of AA

2016-04-02 Thread Temtaime via Digitalmars-d-learn
Hi ! I can't find this in specs. If i add an element to AA: aa[10] = 123; Will [10] be always the same (of course i don't remove that key) ? Thanks for a reply. I think specs should be enhanced.

Destructor order

2016-03-19 Thread Temtaime via Digitalmars-d-learn
Hi ! I wonder if i can rely on this code : http://dpaste.dzfl.pl/745cc5b1cdfb There's two questions: 1) Is dtors always called in reverse order ? 2) Is all the dtors always called when i call destroy ? Thanks for a reply !

Re: Maximum number of threads

2015-09-24 Thread Temtaime via Digitalmars-d-learn
Offtop: i think if number of threads > number of real cores, than there's something wrong with your design. Maybe fibers suit better ?

Re: using memset withing a pure function

2015-08-15 Thread Temtaime via Digitalmars-d-learn
There's a problem with « dst[0 .. n] = val; ». It should be « dst[0 .. n][] = val; »

Re: Associative array literal. Why doesn't it compile?

2015-08-14 Thread Temtaime via Digitalmars-d-learn
It's because it's implemented in DMD only partly. There's a bug report associated with it.

Re: How disruptive is the GC?

2015-08-02 Thread Temtaime via Digitalmars-d-learn
I'm writing a game engine in D. Try to minimize allocations and that's will be OK. I'm using delegates and all the phobos stuff. I allocate only in few places at every frame. So i can reach 1K fps on a complicated scene. GC is not a problem. DMD optimizes so ugly that all the math is very,

Re: Converting uint[] slice to string for the purpose of hashing?

2015-07-23 Thread Temtaime via Digitalmars-d-learn
All types are hashable and for your own structs and classes you can redefine opHash

Re: Escape a string ?

2015-04-09 Thread Temtaime via Digitalmars-d-learn
Sorry, i meant it gives b == fooo\\nbar I'm writing an interpreter and it should dump original string from memory. Also i wonder if there's a function to convert aaa\\nbb to aaa\nbb (i.e. to unescape)

Escape a string ?

2015-04-09 Thread Temtaime via Digitalmars-d-learn
Hi ! I wonder how to escape a string in phobos ? For example auto a = [ fooo\nbar ]; auto b = format(%(%s%), a); gives b: fooo\nbar Is there any other function to escape string? I'm looking for something that doesn't require to make an array at first. For example is there string

Re: Why the DMD Backend?

2014-12-02 Thread Temtaime via Digitalmars-d-learn
It's only words. If we speak about LDC it can compile fast in debug mode with performance average to DMD's backend but with much great performance in release mode thanks to vectorization and other techniques. Also LDC thanks to LLVM supports X86, X86-64, PowerPC, PowerPC-64, ARM, Thumb,

Re: Why the DMD Backend?

2014-12-02 Thread Temtaime via Digitalmars-d-learn
Setting up LLVM infrastructure is only needed when you is a LDC developer. I think for ordinary users it's not their business.

Re: static array alignment

2014-11-30 Thread Temtaime via Digitalmars-d-learn
align doesn't work in DMD. There's bugreport for a long time.

Re: D1: Windows DWORD conversion in D

2014-09-08 Thread Temtaime via Digitalmars-d-learn
DWORD is an uint.

Re: Appender.put return value

2014-07-24 Thread Temtaime via Digitalmars-d-learn
Offtop It's better to return this and have return type ref auto i think.

Re: Test if member is static variable

2014-06-02 Thread Temtaime via Digitalmars-d-learn
Also second question is what are better to use, current template recursion-based code or rewrite it to CTFE ?

Test if member is static variable

2014-06-01 Thread Temtaime via Digitalmars-d-learn
Hi ! http://dpaste.dzfl.pl/e21082716396 Is there a way to optimize static if(is(typeof(__traits(getMember, T, name).offsetof)) == false is(FunctionTypeOf!(__traits(getMember, T, name)) == function) == false __traits(compiles, __traits(getMember, T, name))) ? I think there shoult be

Inherit of attributes

2014-04-25 Thread Temtaime via Digitalmars-d-learn
Hi ! http://dpaste.dzfl.pl/2fa3dd2ea834 Why S.init not pure ? Is it expected behavior or bug ? Thanks!

Re: Inherit of attributes

2014-04-25 Thread Temtaime via Digitalmars-d-learn
Hi, MrSmith ! Yes, i know that, but my question isn't about it. I want to type `pure:` at module's beginning and have all function(in classes, too) declared as pure. I think `pure:` should do it. But it doesn't.

Re: Inherit of attributes

2014-04-25 Thread Temtaime via Digitalmars-d-learn
Hi ! Thanks for reply. Why so ? And why @nogc not transitive too ?