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 instantiati

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 `&addTo

"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;

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

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

2022-10-03 Thread Bienlein via Digitalmars-d-learn
oo.i++; Fiber.yield(); writeln("foo: ", foo.i); } But this solution is a bit clumsy. It's kind of programming with global variables. My question is whether someone has an idea for a better solution. Thank you, Bienlein

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 up

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 { t

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

How to call destructor before free without dropping @nogc?

2021-08-19 Thread Bienlein via Digitalmars-d-learn
that I can create some generic function that calls the destructor and then free for any kind of class? Thanks, Bienlein

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 funct

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 extreme

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

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 doe

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 int

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 ... ;-(.

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: Getting RefCounted to work with classes

2014-08-25 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. N

Getting RefCounted to work with classes

2014-08-25 Thread Bienlein via Digitalmars-d-learn
, RefCountedAutoInitialize autoInit = RefCountedAutoInitialize.yes) if (!is(T == class)) C:\Users\Nutzer\Windows Ordner\Documents\Visual Studio 2013\Projects\RefCountedScratch\RefCountedScratch\main.d 26 I tried many things, but nothing did it. Any help appreciated :-). Thanks, Bienlein import std.stdio; import

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 core.std

How to get nogc to work with manual memory allocation

2014-08-24 Thread Bienlein via Digitalmars-d-learn
this? Then the test.x = 456; did not cause a protection violation although the instance was deallocated before calling nogcDel. Something with the deallocation in nogcDel seems not to work. Some hint appreciated on this. When calling delete t the protection violation happens on the next line as expected. Thanks a lot, Bienlein

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 one

Re: Some kind of RPC exists for D?

2014-06-22 Thread Bienlein via Digitalmars-d-learn
quot; that the code is your work along with the date of publication. -- Bienlein

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 bi-di

Re: Some kind of RPC exists for D?

2014-06-19 Thread Bienlein via Digitalmars-d-learn
being a Smalltalk/Java developer (only played with C++ when studying) I have to stick to what is easier to use. It would be a fun & leisure & learning project anyway... Regards, Bienlein

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 http://www.99-bottles-of-beer.net/lang

Re: How to hand in a closure variable

2014-04-07 Thread Bienlein
On Friday, 4 April 2014 at 19:56:14 UTC, Jesse Phillips wrote: On Friday, 4 April 2014 at 15:13:25 UTC, Bienlein wrote: What I was actually looking for was how to get this to work: immutable int b = if(1 == 1) { return 123; } else { return 456; }; But I'm happy enough with the sol

Re: How to hand in a closure variable

2014-04-04 Thread Bienlein
On Friday, 4 April 2014 at 13:53:33 UTC, bearophile wrote: If your D function has one argument, you have to give it one argument, even if it doesn't have a visible name and it's unused. Ah! Admittedly, I though it's the return type .. So this works now: immutable int b = () { if(1 ==

Re: How to hand in a closure variable

2014-04-04 Thread Bienlein
Thanks so far. I have another one, though. Not trying to tease people, I really don't know ;-). This compiles and runs: immutable int a = (int val) { if(1 == 1) { return val; } else { return 456; } }(123); writeln(a); Whereas th

Re: Why defining alias and not auto when using a template?

2014-04-04 Thread Bienlein
"auto" is used to declare an instance, or an object. "alias" is used to declare a name. What you are currently doing is saying "the function TCopy!(int, int) can now be refered to as myCopy". You aren't actually creating any data. All right, thanks. Then I create an instance: auto myCopy =

Why defining alias and not auto when using a template?

2014-04-04 Thread Bienlein
t compile. My question is why defining auto does not work. I would consider this more intuitive. Thanks, Bienlein

How to hand in a closure variable

2014-03-24 Thread Bienlein
; int delegate(int) dg = { value => return value + a + 3; }; auto result = dg(123); Unhappily, the code above doesn't compile. Tried various things, looked for samples on the D hompepage and in the book by Çehreli, but had no luck. Some hints appreciated. Thanks, Bienlein

Re: getTid wrapper

2014-03-03 Thread Bienlein
On Tuesday, 4 March 2014 at 06:31:24 UTC, Timothee Cour wrote: that gives tid of spawned thread, not 'self'. The link you mentioned says it is stored in the special variable thisTid.

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-28 Thread Bienlein
't have (except implicits, which is a good thing not to have). On the contrary D has immutable types and pure functions. Things that aren't possible in Scala due to limitations of the JVM or need for interoperability. -- Bienlein

Re: custom memory management

2014-02-28 Thread Bienlein
I asked something similar some days ago. Maybe this provides some information tat is helpful to you: http://forum.dlang.org/thread/mekdjoyejtfpafpcd...@forum.dlang.org

Allocating and freeing memory like this?

2014-02-26 Thread Bienlein
or am I messing something up? Thanks for shedding any light on this for me ;-). Regards, Bienlein

Re: Possible to do receive on a delegate?

2014-02-19 Thread Bienlein
27;t compile. I guess it is because it could reference data outside the thread which would result in the thread reaching into memory of the calling thread. I don't really understand why foo has to be static to compile. But this is really nice now :-). -- Bienlein

Possible to do receive on a delegate?

2014-02-19 Thread Bienlein
= &foo; send(tid, dg); } My solution of course doesn't compile. Thanks for any hint, Bienlein

Re: User defined attributes use

2013-09-16 Thread Bienlein
C is null Very interesting. Does this go beyond annotations in Java? Just out of curiosity, no language war intended. -- Bienlein

Re: Question about pure functions

2013-09-16 Thread Bienlein
thanks a lot. I like this pure feature and was already disappointed. Scala doesn't have it (has to remain interoperable with Java), so I was really happy to see it in D. Your answer saved my day :-) -- Bienlein

Question about pure functions

2013-09-16 Thread Bienlein
compiles and runs which I find confusing. I assumed that changing an inst var by a pure function is considered creating a side efect. But the compiler has no problems with this. Am I getting something wrong here? Thanks for any hints. Regards, Bienlein