Re: How can I put the current value of a variable into a delegate?

2024-05-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 May 2024 at 16:41:38 UTC, Steven Schveighoffer wrote: This is a very old issue: https://issues.dlang.org/show_bug.cgi?id=2043 since "moved" to https://issues.dlang.org/show_bug.cgi?id=23136 I would love to see a solution, but the workaround at least exists! -Steve

Re: how can I load html files and not .dt or diet files in vibe.d

2024-02-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 1 February 2024 at 03:20:31 UTC, dunkelheit wrote: this is my code, I'm a begginer on vibe, and I want to use html and not diet files Take a look at the static file example, I think that's close to what you're looking for.

Re: Error: none of the overloads of template `once.main.each!((l)

2023-10-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 4 October 2023 at 08:11:12 UTC, Joel wrote: What am I missing? Splitter returns a forward range so you can't slice the result. You can use take() and drop() instead. Also, converting a string range to int[] doesn't seem to work, but I don't know if it should. Here is a version

Re: Inheritance and arrays

2023-07-03 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 3 July 2023 at 09:50:20 UTC, Arafel wrote: Is this a conscious design decision (if so, why?), or just a leak of some implementation detail, but that could eventually be made to work? Besides the pointer adjustment problem mentioned by FeepingCreature, it's an unsound conversion

Re: Union with bits ?

2023-06-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 00:59:30 UTC, Paul wrote: I would like to have labeled bits in a union with a ubyte. Something like this: ```d struct MyStruct { union { ubyte status; bit A, B, C…etc } } ``` Is something like this possible? Thanks You can do something

Re: iota where step is a function

2023-05-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 24 May 2023 at 16:39:36 UTC, Ben Jones wrote: Is there a range like iota in phobos where step is a function? I want to specify begin/end and have the "step" be next = fun(prev). Should be easy to write, but don't want to reinvent the wheel. I think you’re looking for either

Re: How to workaround assignment not allowed in a condition?

2022-10-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 October 2022 at 02:15:55 UTC, Steven Schveighoffer wrote: Am I missing something? Perhaps I am, but why not turn it into a numeric comparison, like: ``` while((i = 5) == 0) ```

Re: Way to pass params to a function passed to a fiber?

2022-10-03 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 3 October 2022 at 08:10:43 UTC, Bienlein wrote: My question is whether someone has an idea for a better solution. You can pass a lambda to the fiber constructor. For example: ``` void fiberFunc(int i) { writeln(i); } void main() { auto fiber = new Fiber(() =>

Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 11:36:42 UTC, Marcone wrote: I want to use isDaemon to automatic stop worker thread if ownner thread is finished Terminating threads without properly unwinding the stack is generally a very bad idea. Most importantly the destructors of stucts on the stack won't

Re: How is this an "Access Violation"

2020-10-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 02:05:37 UTC, Ruby The Roobster wrote: void construct(string type,atom base,atom bonded) { base = new atom(base.name.idup,base.mass,base.electro_negativity,base.valence_electrons,base.electrons,base.protons,base.neutrons,base.pos);

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

2019-05-09 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 9 May 2019 at 12:33:37 UTC, Cym13 wrote: On Thursday, 9 May 2019 at 11:31:20 UTC, Cym13 wrote: ... To dismiss any doubt about AV or other processes coming into play I took the binary and ran it with wine on linux with the exact same end result. For reference my windows system

Re: Memory reference that does not stop garbage collection.

2019-02-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 8 February 2019 at 15:42:13 UTC, Jonathan Levi wrote: I should be able to use `core.memory.GC.removeRange` right? That would leave dangling references in the array. You may be interested in this, but I have not used it myself: https://repo.or.cz/w/iv.d.git/blob/HEAD:/weakref.d

Re: cas and interfaces

2018-12-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 25 December 2018 at 22:07:07 UTC, Johannes Loher wrote: Thanks a lot for the info, that clarifies things a bit. But it still leaves the question, why it works correctly when inheriting from an abstract class instead of implementing an interface... Any idea about why that? Unlike

Re: How does calling function pointers work?

2018-11-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 12 November 2018 at 16:29:24 UTC, helxi wrote: On Monday, 12 November 2018 at 16:25:13 UTC, Rene Zwanenburg wrote: Idk where you got that syntax from, but there's no syntactic difference between calling normal functions and function pointers: import std.stdio; import

Re: How does calling function pointers work?

2018-11-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 12 November 2018 at 16:08:28 UTC, helxi wrote: As far as I understand, calling a function pointer with an argument in D looks like: call(, argTofn0, argTofn1, argTofn3); Idk where you got that syntax from, but there's no syntactic difference between calling normal functions

Re: Test if variable has void value

2018-08-22 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 22 August 2018 at 13:50:07 UTC, Andrey wrote: Hello, How to test if variable has void value? string text = void; if(text == void) { writeln("Is void"); } Tried this: if(is(text == void)) but doesn't work. You can't. When using a void initializer the actual value is

Re: Coreect way to create delegate for struct method.

2018-08-22 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 21:29:38 UTC, Andrey wrote: Hello, This is a code: (...) test.handler = That's an internal pointer, and internal pointers are not allowed in structs precisely because of the issues you're running into: the pointer will be invalid after a move.

Memory corruption with COM object

2018-07-06 Thread Rene Zwanenburg via Digitalmars-d-learn
I've been staring at this problem the past few hours without making any progress. But I feel like I'm overlooking something obvious.. Using Adam's comhelpers, I've made a JSON plugin for LogParser. However after running for a bit it'll crash with signs of memory corruption. My guess was

Re: Configuring DerelictGL3

2018-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 23:26:23 UTC, Entity325 wrote: I can't imagine things like "glEnable/DisableClientState" are deprecated. They are. All the missing symbols are indeed deprecated. attempting to load the deprecated functions according to the documentation page did a whole lot of

Re: Aggressive conditional inlining with ldc only, not dmd

2018-03-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 25 March 2018 at 22:09:43 UTC, Nordlöw wrote: eventhough I compile with -release -inline -nobounds flags. Just to make sure: are you passing -O as well?

Re: How to make AA key a pointer

2018-02-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 19 February 2018 at 14:57:47 UTC, Clinton wrote: On Monday, 19 February 2018 at 14:55:01 UTC, Clinton wrote: Hi all, I need advice from better developers on this concern. I'm using an AA to reference another array for quicker access: [...] Sorry, on second look my explanation

Re: Debugging on Windows

2018-02-09 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 8 February 2018 at 21:09:33 UTC, JN wrote: Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a call to a C library, I get a crash and that's it. I am using VSCode

Re: SegFault with HibernateD

2018-01-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 12 January 2018 at 07:33:37 UTC, Mike Parker wrote: On Friday, 12 January 2018 at 05:24:52 UTC, Venkat wrote: I get a SegFault with the main method below which uses HibernateD . The second main method which uses ddbc just works fine. What is wrong with the first main method ? I have

Re: High-resolution thread sleep

2017-12-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 15 December 2017 at 01:49:56 UTC, Steven Schveighoffer wrote: So... you plan on rendering more than 1000 frames per second? I think in any case, even if the API allows it, you are probably not getting much better resolution on your non-windows systems. Have you tried it anyway

Re: High-resolution thread sleep

2017-12-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 14 December 2017 at 23:45:18 UTC, Ivan Trombley wrote: Something along the lines of this: while (render) { immutable auto startTime = MonoTime.currTime; // Render the frame... immutable auto remain = m_frameDuration - (startTime - MonoTime.currTime); if (remain >

Re: High-resolution thread sleep

2017-12-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 14 December 2017 at 21:11:34 UTC, Ivan Trombley wrote: I need to be able to put a thread to sleep for some amount of time. I was looking at using Thread.sleep but it appears that on Windows, it's limited to millisecond resolution. Is there a way to do this in a cross-platform way

Re: Email validation

2017-11-28 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote: Hi All, You can do this easily using the std.net.isemail module: https://dlang.org/phobos/std_net_isemail.html

Re: opAssign for most struct assignment calls not executed

2017-11-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 23 November 2017 at 15:26:03 UTC, Timoses wrote: A aaa = a; That's initialization, not assignment, which is subtly different. It will call the postblit on aaa instead of opAssign. A postblit can be defined this way: this(this) { } There is no way to access the original a

Re: DateTime trying to do it at compile time.

2017-10-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 26 October 2017 at 17:55:05 UTC, Mr. Jonse wrote: when calling Clock.currTime() in a this() in a class. I have no idea why it is trying to do it at compile time and failing. I thought if ctfe couldn't compile it would do it at run time anyways? Seems like a bug. I suspect you're

Re: How to modify process environment variables

2017-10-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 05:57:50 UTC, Ky-Anh Huynh wrote: On Tuesday, 17 October 2017 at 04:56:23 UTC, ketmar wrote: you can use libc's `putenv()` in D too, it is ok. just import `core.sys.posix.stdlib`, it is there. D is not antagonistic to C, and doesn't try to replace the whole

Re: Making a repo of downloaded dub package

2017-09-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 06:23:26 UTC, Dukc wrote: On Monday, 4 September 2017 at 20:31:35 UTC, Igor wrote: Search for word "local" here: https://code.dlang.org/docs/commandline. Maybe some of those can help you. If not you could make a pull request for dub that would support such a

Re: Remove all blank lines from a file

2017-08-31 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:44:07 UTC, vino wrote: Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B This one doesn't read the entire file into memory: import std.stdio; import std.array; import std.algorithm; import std.uni; void

Re: Getting enum from value

2017-08-05 Thread Rene Zwanenburg via Digitalmars-d-learn
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); }

Re: Function with static array as parameter

2017-07-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:57:19 UTC, Rene Zwanenburg wrote: On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Templatize the array length: void foo(size_t length)(int[length] arr) { }

Re: Function with static array as parameter

2017-07-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Templatize the array length: void foo(size_t length)(int[length] arr) { }

Re: D and memory mapped devices

2017-06-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 14 June 2017 at 08:10:57 UTC, Russel Winder wrote: but the bitfields mixin template appears to do more than add all the bit twiddling functions to emulate the bitfields. This would appear a priori to not allow for actual memory mapped devices using it, or am I missing something?

Re: purity question

2017-05-30 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 11:34:52 UTC, ketmar wrote: If malloc were marked as pure, wouldn't that mean it must return the same pointer every time you call it with the same size? of course. but D "pure" is not what other world knows as "pure". we love to mess with words. Well, there's the

Re: purity question

2017-05-30 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 29 May 2017 at 01:36:24 UTC, Jonathan M Davis wrote: A simple example: anything that has a malloc/free pair. Yeah, if you do it right, you should be fine, but you have to do it right, and it's very easy to miss some detail that makes it wrong to insist to the compiler that what

Re: Why map return [] ?

2017-04-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 14 April 2017 at 15:49:00 UTC, Suliman wrote: I found problem! ResultRange should be converted to array before it can be `map`ed That shouldn't be necessary. Can you post your complete code?

Re: Can't build simple project. Very strange errors

2017-04-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 14 April 2017 at 15:42:33 UTC, Suliman wrote: On Friday, 14 April 2017 at 15:40:18 UTC, Rene Zwanenburg wrote: On Friday, 14 April 2017 at 15:31:21 UTC, Suliman wrote: On Friday, 14 April 2017 at 15:22:49 UTC, Rene Zwanenburg wrote: On Friday, 14 April 2017 at 09:49:09 UTC, Suliman

Re: Can't build simple project. Very strange errors

2017-04-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 14 April 2017 at 15:31:21 UTC, Suliman wrote: On Friday, 14 April 2017 at 15:22:49 UTC, Rene Zwanenburg wrote: On Friday, 14 April 2017 at 09:49:09 UTC, Suliman wrote: on: dub build --compiler=ldc2 link OPTLINK (R) for Win32 Release 8.00.17 Optlink isn't able to link object

Re: Can't build simple project. Very strange errors

2017-04-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 14 April 2017 at 09:49:09 UTC, Suliman wrote: on: dub build --compiler=ldc2 link OPTLINK (R) for Win32 Release 8.00.17 Optlink isn't able to link object files produced by ldc. Could you try an x64_86 build? You'll need the Microsoft linker.

Re: DUB mismatch between project structure and dub.json contents

2017-04-10 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 10 April 2017 at 12:56:49 UTC, Nordlöw wrote: src/knet/traversal.d(20,8): Error: module factixs from file src/knet/factixs.d must be imported with 'import factixs;' What am I doing wrong? My first guess would be that the module declaration in that file is incorrect. Are you sure

Re: delegate with optional parameters

2017-04-03 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 3 April 2017 at 05:00:15 UTC, Inquie wrote: Yes, but they are really not any different. They only look different. A field can be a function just like a method because they look exactly the same except on is in a vtable and the other is in the fields memory. But both point functions.

Re: Why is [0] @safer than array.ptr?

2017-01-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 11:38:16 UTC, Jonathan M Davis wrote: Likely because it does bounds checking, so you at least know that it's not null. But I don't see why that would really improve much considering that the odds are that you're really going to be accessing far more than just the

Re: Strange Bug

2017-01-20 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 20 January 2017 at 08:19:57 UTC, Chris M. wrote: I have no idea if this is an issue with D, or OpenSSL, or if I'm just doing something completely wrong. I'm writing a program that will either encrypt or decrypt a string using AES in ECB mode (for a school assignment) and it's giving

Re: Phobos: Determining number of hours or minutes or seconds till now

2017-01-20 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 20 January 2017 at 03:48:14 UTC, rikki cattermole wrote: As per the documentation this is wrong for anything beyond a few weeks. Although I have no idea if that's the case implementation wise. I think the documentation is talking about the units used, not length of the duration.

Re: Phobos: Determining number of hours or minutes or seconds till now

2017-01-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 January 2017 at 14:04:36 UTC, aberba wrote: Using the standard library, how do a get number of hours or seconds or minutes or days or months or years till current time from a past timestamp (like "2 mins ago")? Not with manual calculations but from Phobos functions. You can

Re: Thread will get garbage collected?

2017-01-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 08:58:33 UTC, Arun Chandrasekaran wrote: Interesting. Why doesn't the thread get GC'd in this case even without any reference still active? There will be a reference to it in druntime itself: http://dlang.org/phobos/core_thread.html#.Thread.getThis

Re: Changing template parameters

2017-01-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 January 2017 at 15:56:16 UTC, Jack Stouffer wrote: Same way you use any template parameters, auto i = uniform!("(]")(0, 1000); Also, if the template parameter consists of a single token you can omit the parens: auto i = uniform!"(]"(0, 1000);

Re: Alias variable from another class

2016-12-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 19:13:24 UTC, Begah wrote: Any ideas? Closest you can get is wrapping it in a property. If you need to do this often you may be able to generate them, check the recent "Getters/Setters generator" thread in Announce for some inspiration.

Re: Updated D then undefined symbols in vibed

2016-11-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 24 November 2016 at 16:17:19 UTC, Jot wrote: Any more ideas? Obviously something isn't getting linked in in the VS project. This is definitely a stale object file problem. From that error message it appears to use the .dub directory to store object files of your dependencies.

Re: Updated D then undefined symbols in vibed

2016-11-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 24 November 2016 at 09:52:32 UTC, Jot wrote: Seems like someone decided to screw up a lot of people by removing a lot of stuff ;/ I guess I should learn my lesson about assuming a "stable" dmd release won't completely kill my project. There are still some old object files or

Re: Why don't Function Lambdas Cast to Delegate?

2016-11-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 21 November 2016 at 16:24:38 UTC, Q. Schroll wrote: Why don't lambdas cast to a delegate if they are of type R function(Args)? I don't see any reason to that; a lambda should be a delegate type by default, and a function only as a special guarantee/optimization. It just makes them

Re: [vibe.d] showing images

2016-10-26 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 12:42:09 UTC, Nicholas Wilson wrote: doctype html html body -foreach(s; images) // it doesn't seem to like #{s} or !{s} img(src=s) -- shared static this() { auto router = new URLRouter;

Re: File.write write extra CR character if a string has CRLF on windows

2016-10-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 6 October 2016 at 15:00:00 UTC, Pham wrote: string s is multi-lines (CRLF as line break) The write function will write extra CR character for each CRLF pair -> why (bug?) import std.file; import std.stdio; string s = ...; auto fHandle = File("f:\\text.txt", "w"); // open for

Re: Member not accessible in delegate body

2016-09-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 September 2016 at 07:54:15 UTC, John C wrote: How is it possible that "onTextChanged" isn't accessible but the private method "changeSize" *is*? Smells like an oversight. I guess the compiler doesn't see the delegate as a member of a Control subclass, so it can't access

Re: Vibe.d compilation error: backend/cgelem.c 5018 dmd failed with exit code 1.

2016-09-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 23 September 2016 at 08:39:44 UTC, llaine wrote: Okay I tried yesterday, after 4hours of process, I never went through the end of minification. At the beginning I enter YES should I enter NO instead? Hmm that's strange. I don't get any yes or no questions. What is the exact

Re: Vibe.d compilation error: backend/cgelem.c 5018 dmd failed with exit code 1.

2016-09-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 20:22:42 UTC, llaine wrote: The project is pretty big, DustMite would handle this? Yes, but it may take some time. For large projects, running it on a server is advisable. 3K LOC should be doable on a desktop machine. Dub has built-in support for running

Re: Copy a struct and its context

2016-09-11 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 11 September 2016 at 05:44:13 UTC, Yuxuan Shui wrote: I recently noticed nested struct capture its context by reference (which, BTW, is not mentioned at all here: https://dlang.org/spec/struct.html#nested). And bliting a struct obviously doesn't do a deep copy of its context. So

Re: Storing a reference

2016-09-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 1 September 2016 at 20:38:13 UTC, Yuxuan Shui wrote: I think my approach is probably better, because I believe (correct me if I'm wrong): 1) it will never refer to a null object. That's true, but you can ensure the same thing for the wrapper: struct Ref() { @disable this();

Re: Storing a reference

2016-09-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 1 September 2016 at 19:37:25 UTC, Yuxuan Shui wrote: I just figured out how to store a reference: @safe: auto x(ref int a) { struct A { ref int xa() { return a; } } return A(); } void main() { import std.stdio; int b = 10;

Re: Checking all elements are unique.

2016-08-31 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 08:38:11 UTC, Andrea Fontana wrote: Something like this: https://dpaste.dzfl.pl/9fa55b2a7927 ? Andrea Or use findAdjacent: auto idsAreUnique = ids.array.sort.findAdjacent.empty; http://dlang.org/phobos/std_algorithm_searching.html#.findAdjacent

Re: DerelictGL3.reload with specified path question.

2016-08-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry wrote: I want to store all my shared/dynamic libraries within a special directory relative to where the application directory is. All of the derelictXX.loads(path) compiles except DerelictGL3.reload(lib); which doesn't seem to be

Re: randomIO, std.file, core.stdc.stdio

2016-07-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 02:20:57 UTC, Charles Hixson wrote: O, dear. It was sounding like such an excellent approach until this last paragraph, but growing the file is going to be one of the common operations. (Certainly at first.) (...) So I'm probably better off sticking to using a

Re: Dynamic arrays, emplace and GC

2016-07-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 13:48:46 UTC, Claude wrote: Ah ok. I tried using void[size] static array and it seems to work without having to use GC.addRange(). Correct. void[] means the type of the data is unknown, so the GC has to assume it can contain pointers. This also means that

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 12:34:20 UTC, Johannes Loher wrote: I tried this, but it does not work correctly with slices. The length of a slice is a runtime value, which is why it can't be used to set static array size. What were you trying to achieve? Avoid copying the input arrays, or

Re: Initializing static array with contents of (static and dynamic) arrays

2016-07-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 4 July 2016 at 19:22:52 UTC, Johannes Loher wrote: This looks really nice, but I have several occurences of this, with different arrays (and lengths), so i would need to create several of those structs. But it looks really clean :) You can use a template to remove the boilerplate.

Re: Commit size and Page fault's very large for simple program

2016-07-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 4 July 2016 at 11:42:40 UTC, Rene Zwanenburg wrote: ... I forgot to mention: If you're on Windows compilation defaults to 32 bit, false pointers can be a problem with D's current GC in 32 bit applications. This isn't an issue for the sample application though, since you're not

Re: Commit size and Page fault's very large for simple program

2016-07-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 4 July 2016 at 01:57:19 UTC, Hiemlick Hiemlicker wrote: version(Windows) void main() { import std.random; while(getchar() != EOF) { auto x = new int[std.random.uniform(100, 1000)]; writeln("");

Re: Range non-emptyness assertions and opIndex

2016-07-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 1 July 2016 at 10:35:04 UTC, Nordlöw wrote: I think this is a important issue since asserts are not optimized away in release mode and D is very much about performance. Asserts are removed in release mode, enforce isn't. Here's an example: = void main(string[] args) {

Re: How to use a char[] buffer in D

2016-06-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 23 June 2016 at 05:59:10 UTC, Andrew Chapman wrote: Perfect, thank you! :-) Works like a charm. On Wednesday, 22 June 2016 at 22:41:24 UTC, H. S. Teoh wrote: On Wed, Jun 22, 2016 at 09:57:04PM +, Andrew Chapman via Digitalmars-d-learn wrote: Maybe try: if (buffer[]

Re: Templated class defaults and inheritence

2016-06-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 18 June 2016 at 17:48:47 UTC, Joerg Joergonson wrote: class foo(T) if (is(T : subfoo)) X; FYI this can also be done in the template parameter list: class foo(T : subfoo){}

Re: Out of order execution

2016-06-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 16 June 2016 at 01:57:19 UTC, Joerg Joergonson wrote: Is there an efficient lazy way to make this happen? No, I don't see how that would work. Suppose I can't run the loop twice for performance reasons(there is other stuff in it) and I don't want to store the state and call

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 10:31:18 UTC, TheDGuy wrote: Thanks a lot for your answer, getcwd() returns the path where coedit is located on my harddrive: C:\Program Files (x86)\Coedit_32\coedit.2update6.win32 How can i change that? I'm not familiar with Coedit, but the run options seem to

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 09:48:19 UTC, TheDGuy wrote: But if i execute the app my hand (in the windows command window or my double click) it works as expected (so no error)? Why is that? My first guess would be that Coedit does not use the directory where the executable is located as

Re: What's up with GDC?

2016-06-14 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 13 June 2016 at 20:21:28 UTC, Joerg Joergonson wrote: Are you running some other program that might be sending a lot of broadcast messages? Not that I know of. I haven't tried running it outside VS though so it might be doing something weird. I'll investigate further when I get

Re: Range and poolTask

2016-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 June 2016 at 10:26:11 UTC, moechofe wrote: The functions passed to map or amap take the type of the element of the range as argument, but not a range itself. Right. I don't think I understand what the semantics of your example would be though.. Could you elaborate a bit?

Re: Range and poolTask

2016-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:32:30 UTC, moechofe wrote: I wonder if it is possible to write something like this: --- // taskPool.distribute -- take a range and distribute entries to different threads. dirEntries().distribute(function(R1,R2)(R1 from,R2 to){ from .filter!xxx

Re: Creating a "fixed-range int" with opDispatch and/or alias this?

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 19:59:51 UTC, Mark Isaacson wrote: FWIW, the fixed range int part of this question is just an example, I'm mostly just interested in whether this idea is possible without a lot of bloat/duplication. I suspect not.. Here's how std.typecons.Proxy is doing it:

Re: Using referenceCounters

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 18:14:33 UTC, Begah wrote: I started using reference counters for my assets in my application : - Images - Models - For my resource manager I started out with something similar to what you're describing, but I eventually changed the design which turned

Re: Base64 of String without casting

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 09:31:51 UTC, tcak wrote: I understand that Base64 uses Ranges, and since String is seen and used as unicode by Ranges (please tell me if I am wrong). I am guessing, for this reason, auto btoa = std.base64.Base64.encode("Blah"); doesn't work. You need to be

Re: Preferred method of creating objects, structs, and arrays with deterministic memory management

2016-06-01 Thread Rene Zwanenburg via Digitalmars-d-learn
I was wondering: what's the preferred method for deterministic memory management? You may be interested in RefCounted. It only works for structs, not classes, but it's still useful. - Classes/Structs have constructors and destructors. I am unconfident with my knowledge as to how this works

Re: Benchmark Dlang vs Node vs Ruby

2016-05-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 27 May 2016 at 15:18:38 UTC, llaine wrote: - And how can I minimize allocations? My previous post still allocates though, through that call to array at the end. I'm not sure how to completely remove all allocations (I'm not that familiar with vibe.d), but I strongly suspect it's

Re: Benchmark Dlang vs Node vs Ruby

2016-05-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 27 May 2016 at 15:04:31 UTC, llaine wrote: My level of D is really slow, so can you help me to improve this? :) Here's an alternative getCompanies. Untested so it may contain some mistakes. Company[] getCompanies() { auto conn = client.lockConnection(); immutable result =

Re: Benchmark Dlang vs Node vs Ruby

2016-05-27 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 27 May 2016 at 13:45:23 UTC, llaine wrote: Hi guys, In my journey of learning about D I tried to benchmark D with Vibe.d vs node with express and Ruby with Sinatra. And the results are pretty surprising. I have to admit that I though D was more faster than that. How is this even

Re: Introspect alias name of an aliased type

2016-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 23 May 2016 at 10:45:49 UTC, ParticlePeter wrote: Is there a way to get the alias uint32_t instead ? Nope. For the compiler uint32_t and uint are the same thing, this is by design. Typedef can be used to create a separate type with the same semantics as the type it's based upon:

Re: How to share an appender!string?

2016-05-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 May 2016 at 10:58:42 UTC, Rene Zwanenburg wrote: Calling task() only creates a Task, you also have to start it somehow. The documentation contains an example: https://dlang.org/phobos/std_parallelism.html#.task I should add that a single shared array will cause contention if

Re: How to share an appender!string?

2016-05-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 May 2016 at 10:41:14 UTC, Thorsten Sommer wrote: On Thursday, 19 May 2016 at 10:13:21 UTC, rikki cattermole wrote: At this point I'd recommend you to just ignore Appender. Write your own. Dear rikki, Thanks for the proposal :) Here is the new attempt #4 as simple test

Re: Does DUB create .dll files?

2016-05-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 17 May 2016 at 05:30:33 UTC, WhatMeWorry wrote: Am I supposed to get ALURE32.DLL from somewhere outside of DUB, or did I miss a step or command when I built derelict-alure-master? thanks. You'll need to get the dll somewhere else and set up DUB to copy it to your output

Re: DMD flag -gs and -gx

2016-05-13 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 13 May 2016 at 10:19:04 UTC, Nordlöw wrote: -gsalways emit stack frame IIRC, not emitting a stack frame is an optimization which confuses debuggers. So I think this can be used to make optimized builds a bit easier to debug. -gxadd stack stomp code

Re: Accepting function or delegate as function argument

2016-05-04 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 14:54:39 UTC, chmike wrote: Two constructors, one accepting a function and the other one accepting a delegate would do the job for the API. Is there a simple method to convert a function pointer into a delegate pointer that is also efficient ?

Static introspection in a class hierarchy

2016-05-02 Thread Rene Zwanenburg via Digitalmars-d-learn
I'm in the process of making my code compile with DMD 2.071. There's a construction I've been using which now results in a deprecation message, and I'm not sure how to properly fix it. It's a bit like design by introspection within a class hierarchy. For example: abstract class Base {

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote: - What happens when you compile a binary without phobos and druntime, and with a custom entry point? I've never done that myself and don't remember how to do that off the top of my head, but the info should be somewhere on dlang.org.

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 21 April 2016 at 11:54:27 UTC, rcorre wrote: Thanks for the tip. Here's the linking code it shows: cc d.o -o d -m64 -L/usr/lib -L/usr/lib32 -Xlinker --export-dynamic -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lrt -ldl /usr/bin/ld: d.o: relocation R_X86_64_32

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 21 April 2016 at 01:20:27 UTC, rcorre wrote: s/compile/link I _can_ compile a D library, but as soon as I try to link anything compiled with DMD it falls over. What is dmd's verbose output? (add -v switch) Some of the things it outputs are the location of the config file it

Re: Shallow copy object when type is know

2016-04-21 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 20 April 2016 at 19:58:15 UTC, Tofu Ninja wrote: To implement a copy/paste/duplicate functionality in a game editor. I have an entity-component system, to duplicate an entity, all it's components need to be duplicated. I have many many components, I don't want to rely on manually

Re: @nogc inconsistent for array comparison depending on mutability of elements

2016-04-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 8 April 2016 at 09:56:41 UTC, Nick Treleaven wrote: If the comparison with b shouldn't be allowed, I suggest we add opEquals to std.range.only. This removes a need to import std.algorithm.equal and reduces bracket nesting: assert(b == only(1, 2)); equal[1] can compare ranges of

Re: Issue with 2.071: Regression or valid error?

2016-04-08 Thread Rene Zwanenburg via Digitalmars-d-learn
On Friday, 8 April 2016 at 08:26:11 UTC, Daniel Kozak wrote: On Friday, 8 April 2016 at 06:08:38 UTC, 9il wrote: On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote: Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) {

Re: VibeCustomMain not working

2016-04-07 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 7 April 2016 at 13:40:17 UTC, Rene Zwanenburg wrote: That's possible of course, but I'd expect something so fundamental breaking to be noticed sooner. Just to make sure, could you run dub with --force to rule out that it's picking up some stale object files from somewhere? And

  1   2   >