Re: "is not an lvalue" when passing template function to spawn function

2023-11-09 Thread Bienlein via Digitalmars-d-learn
On Thursday, 9 November 2023 at 10:14:46 UTC, Bienlein wrote: On Thursday, 9 November 2023 at 09:40:47 UTC, Bienlein wrote: On Wednesday, 8 November 2023 at 16:47:02 UTC, Paul Backus wrote: On Wednesday, 8 November 2023 at 16:30:49 UTC, Bienlein wrote: ... The actual problem here is that you

Re: "is not an lvalue" when passing template function to spawn function

2023-11-09 Thread Bienlein via Digitalmars-d-learn
On Thursday, 9 November 2023 at 09:40:47 UTC, Bienlein wrote: On Wednesday, 8 November 2023 at 16:47:02 UTC, Paul Backus wrote: On Wednesday, 8 November 2023 at 16:30:49 UTC, Bienlein wrote: ... The actual problem here is that you can't take the address of a template without instantiating it

Re: "is not an lvalue" when passing template function to spawn function

2023-11-09 Thread Bienlein via Digitalmars-d-learn
On Wednesday, 8 November 2023 at 16:47:02 UTC, Paul Backus wrote: On Wednesday, 8 November 2023 at 16:30:49 UTC, Bienlein wrote: ... The actual problem here is that you can't take the address of a template without instantiating it first. To make your example work, replace `` with `!int`, like

"is not an lvalue" when passing template function to spawn function

2023-11-08 Thread Bienlein via Digitalmars-d-learn
Hello, I get the error "`addToBiz(T)(Biz!T biz)` is not an lvalue and cannot be modified" when compiling the code below. Can't find a way how to do it right. Am a D newbie and would appreciate some help. Thank you, Bienlein class Biz(T) { private T value; this(T value)

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

2022-10-03 Thread Bienlein via Digitalmars-d-learn
On Monday, 3 October 2022 at 10:13:09 UTC, Rene Zwanenburg wrote: 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) {

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

2022-10-03 Thread Bienlein via Digitalmars-d-learn
Hello, I'm looking for a way to pass parameters to a function called by a fiber. Starting a fiber works like this: int main() { auto fiber = new Fiber(); fiber.call(); fiber.call(); return 0; } void myFunc() { writeln("Fiber called"); Fiber.yield(); writeln("Fiber

Re: null == "" is true?

2022-07-19 Thread Bienlein via Digitalmars-d-learn
why? Because an empty string is, by default, represented by an empty slice of the null pointer. I don't program in D. I just read from time to time posts in the D forum because of the good quality of what people write. So, I'm not proficient in D, but in general internals should not boil

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
This works, vit. Thanks! I thought it wouldn't, because your code still makes use of embrace. But it somehow worked, although I don't understand why ... ;-). I also added a constructor using the same approach as your destructor and this also worked: this(int otherNum) @nogc {

Re: How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
On Thursday, 19 August 2021 at 07:30:38 UTC, Bienlein wrote: Hello, I allocate some instance of class C manually and then free the memory again: class C { int num; ~this() { writeln("~this"); } } void foo() // @nogc { auto mem =

How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
Hello, I allocate some instance of class C manually and then free the memory again: class C { int num; ~this() { writeln("~this"); } } void foo() // @nogc { auto mem = cast(C)malloc(__traits(classInstanceSize, C)); auto c =

Re: What's the best way to find out which exceptions may be thrown ?

2020-06-02 Thread Bienlein via Digitalmars-d-learn
On Wednesday, 27 May 2020 at 11:40:00 UTC, Mike Parker wrote: On Wednesday, 27 May 2020 at 10:30:36 UTC, wjoe wrote: On Wednesday, 27 May 2020 at 10:01:33 UTC, Mike Parker wrote: Could you please elaborate why checked exceptions are more annoying? For me, it's because they require all

Re: Alternative to friend functions?

2020-02-20 Thread Bienlein via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:43:22 UTC, Adnan wrote: What is the alternative to C++'s friend functions in D? module stable_matching; alias FemaleID = int; alias MaleID = int; class Person { string name; int id; } class Male : Person { this(string name = "Unnamed Male") {

Re: Functional Programming in D

2019-10-11 Thread Bienlein via Digitalmars-d-learn
On Thursday, 10 October 2019 at 16:05:13 UTC, bachmeier wrote: On Thursday, 10 October 2019 at 08:59:49 UTC, Russel Winder wrote: My impressions is that the complaints about Scala are similar to C++: too many features that clash with one another and make the language complicated, plus

Re: Functional Programming in D

2019-10-10 Thread Bienlein via Digitalmars-d-learn
On Thursday, 10 October 2019 at 10:08:14 UTC, H. S. Teoh wrote: On Thu, Oct 10, 2019 at 09:59:49AM +0100, Russel Winder via Digitalmars-d-learn wrote: On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via Digitalmars-d-learn wrote: […] > Actually, std.functional is somewhat of a misnomer. It >

Re: Writing Postgresql extension in D

2018-11-16 Thread Bienlein via Digitalmars-d-learn
On Friday, 16 November 2018 at 02:18:11 UTC, Ranjan wrote: On Thursday, 15 November 2018 at 17:03:55 UTC, Andrea Fontana wrote: On Thursday, 15 November 2018 at 13:05:59 UTC, Ranjan wrote: This is my first time on the Dlang forum. I like the language but my usecase is a bit different. I want

Re: Inherit from class based on bool value

2018-11-15 Thread Bienlein via Digitalmars-d-learn
On Tuesday, 13 November 2018 at 07:10:26 UTC, Jamie wrote: I would like my class to inherit from one of two classes based on a boolean value known at compile time. Something like this: void main() { Top!(OPTION.FALSE) top = new Top!(OPTION.FALSE); } enum OPTION { FALSE = 0., TRUE

Re: Don't expect class destructors to be called at all by the GC

2018-01-31 Thread Bienlein via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:45:27 UTC, Adam D. Ruppe wrote: On Thursday, 21 December 2017 at 18:20:19 UTC, H. S. Teoh wrote: When the scoped destruction of structs isn't an option, RefCounted!T seems to be a less evil alternative than an unreliable class dtor. :-/ Alas, RefCounted

Re: Is there any threadsafe queue?

2017-09-14 Thread Bienlein via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 07:51:19 UTC, John Burton wrote: Is there any threadsafe queue in the standard library? I've not been able to find anything but thought I'd check before making my own. I want to be able to assemble messages (Which are just streams of bytes) in one thread

Re: Getting RefCounted to work with classes

2014-08-26 Thread Bienlein via Digitalmars-d-learn
On Tuesday, 26 August 2014 at 06:01:25 UTC, uri wrote: RefCounted does not work with classes. Classes are reference types already. Yep, that's the problem. I also got some suspicion, then surfed the Internet and found the information about it. Thanks for explaining the error message to me.

Non-GC based List/Set/Map implementation?

2014-08-26 Thread Bienlein via Digitalmars-d-learn
Hello, does anyone know of a List/Set/Map implementation that does not rely on the GC? The would be the last thing I need for D to be really happy with it ;-) Thanks, Bienlein

Re: Non-GC based List/Set/Map implementation?

2014-08-26 Thread Bienlein via Digitalmars-d-learn
Thanks for the replies. This looks good. I meanwhile found http://dsource.org/projects/dcollections But it seems to be GC-based just like Tango ... ;-(.

Getting RefCounted to work with classes

2014-08-25 Thread Bienlein via Digitalmars-d-learn
Hello, the code below compiles and runs fine. However, when I change Payload from struct to class I get compiler errors: Error 1 Error: template instance std.typecons.RefCounted!(Payload, cast(RefCountedAutoInitialize)1) does not match template declaration RefCounted(T,

How to get nogc to work with manual memory allocation

2014-08-24 Thread Bienlein via Digitalmars-d-learn
Hello, I was having a look at the new nogc annotation and therefore wrote some code that creates an instance on the heap bypassing the GC (code adapted from http://dpaste.dzfl.pl/2377217c7870). Problem is that calls to call the class' constructor, destructor and others can't be called

Re: How to get nogc to work with manual memory allocation

2014-08-24 Thread Bienlein via Digitalmars-d-learn
On Sunday, 24 August 2014 at 08:48:03 UTC, bearophile wrote: Perhaps there are ways, but note that @nogc is meant mostly for stack-allocation. Ah, I missed that. Thanks for telling me. I changed nogcDel now to null out the deallocated object: void nogcDel(T)(ref T obj) { import

Re: spawn and wait

2014-07-03 Thread Bienlein via Digitalmars-d-learn
There is also a Semaphore and Barrier class: http://dlang.org/phobos/core_sync_barrier.html http://dlang.org/phobos/core_sync_semaphore.html

Re: Passing around a list of differently typed functions

2014-06-23 Thread Bienlein via Digitalmars-d-learn
On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int b); bool bar(bool a, bool b); into

Re: Some kind of RPC exists for D?

2014-06-22 Thread Bienlein via Digitalmars-d-learn
On Saturday, 21 June 2014 at 18:22:54 UTC, Paul wrote: I wrote some (JSONRPC and TXTRPC) and used them with vibe. I can send you via email Hi Paul, alternatively you could upload your code to GitHub or some similar place and place the link here. Then you also have a means to proof that the

Re: Some kind of RPC exists for D?

2014-06-20 Thread Bienlein via Digitalmars-d-learn
What data load profile do you expect? Vibe is tuned to handle thousands simultaneous incoming light requests (milliseconds), while distributed computing works better with exclusive heavy requests, at least minutes of work worth, BOINC uses hours worth work items. Communication will be

Re: Some kind of RPC exists for D?

2014-06-19 Thread Bienlein via Digitalmars-d-learn
What I want to do is some little framework that allows Julia-style (julialang.org) distributed computation: send some function invocation to some other machine along with the numbers to be crunched and get the result back. vibe.web.rest server/client combo is effectively RPC over HTTP/json

Some kind of RPC exists for D?

2014-06-18 Thread Bienlein via Digitalmars-d-learn
Hello, I'm looking for a way to do some kind of RPC in D. Some way of being able to say aFoo.bar(int i, ...) with receiver object and method being marshalled at the sender's site and being unmarshalled and invoked at the receiver's site. Any hints appreciated. Thanks, Bienlein

Re: On Concurrency

2014-04-24 Thread Bienlein via Digitalmars-d-learn
One key difference is that coroutines won't make your programs run faster. It is a modelling mechanism that can simplify your programs where you otherwise would have to implement a state machine. This is also my impression when I look at this code (see