Re: Setting field of struct object

2024-05-14 Thread Menjanahary R. R. via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:21 UTC, Danilo wrote: On Monday, 22 January 2024 at 08:35:01 UTC, Joel wrote: [...] Nonetheless, this usually used with Objects (new class/struct instances), like so: ```d import std; [...] Fluent Interface 

Re: Setting field of struct object

2024-02-01 Thread TheTeaLady via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the

Re: Setting field of struct object

2024-02-01 Thread Anonymouse via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) { this.email=email; return this; } auto withAge(ulong age) {

Re: Setting field of struct object

2024-02-01 Thread TheTeaLady via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:47:23 UTC, bachmeier wrote: On Monday, 22 January 2024 at 15:45:45 UTC, zjh wrote: On Monday, 22 January 2024 at 15:33:01 UTC, ryuukk_ wrote: it only took me 1 project to never want to touch C++ again.. D language used to have no `copy constructor`, isn't it

Re: Setting field of struct object

2024-01-25 Thread zjh via Digitalmars-d-learn
On Thursday, 25 January 2024 at 08:46:34 UTC, Renato wrote: ```d void main() { Person p = { "Joe", "j...@ab.com", 30}; writeln(p); } ``` I just tested it and it works. It's `great`!

Re: Setting field of struct object

2024-01-25 Thread Renato via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the

Re: Setting field of struct object

2024-01-22 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:56:59 UTC, zjh wrote: On Monday, 22 January 2024 at 15:51:37 UTC, zjh wrote: I spent `too much time` on D. And some of the inherent `drawbacks` of `C++` are too hateful. It's a package deal. Everything in C++ is there because there were benefits when they

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:51:37 UTC, zjh wrote: I spent `too much time` on D. And some of the inherent `drawbacks` of `C++` are too hateful.

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:47:23 UTC, bachmeier wrote: Sounds like you should be using C++. Why are you here? I spent `too much time` on D.

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:14:32 UTC, Bkoie wrote: D is totally different from C++ in D you usually you wont construct the struct directly use alias as. Stop being `unconventional` and quickly copy their `good things`. Otherwise, the `development speed` of the D language is really

Re: Setting field of struct object

2024-01-22 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:45:45 UTC, zjh wrote: On Monday, 22 January 2024 at 15:33:01 UTC, ryuukk_ wrote: it only took me 1 project to never want to touch C++ again.. D language used to have no `copy constructor`, isn't it now added in again? You have to admit the good aspects of

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 15:33:01 UTC, ryuukk_ wrote: it only took me 1 project to never want to touch C++ again.. D language used to have no `copy constructor`, isn't it now added in again? You have to admit the good aspects of `C++`. You should take a look at the `latest C++`. C++

Re: Setting field of struct object

2024-01-22 Thread ryuukk_ via Digitalmars-d-learn
I should note that it only took me 1 project to never want to touch C++ again.. that must be telling something, either about the language, or me, or both lol

Re: Setting field of struct object

2024-01-22 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the

Re: Setting field of struct object

2024-01-22 Thread Bkoie via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the `DRY` principle! Moreover, as the `package level, module level, class level, member level`, D

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` C++ can achieve ultimate `simplicity` without violating `DRY`, And here, D violates the `DRY` principle! Moreover, as the `package level, module

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 11:31:11 UTC, zjh wrote: D language violates integrity. Because D has no `class level` limit. These are all not `serious states`. It seems that D language is not `professional`.

Re: Setting field of struct object

2024-01-22 Thread FeepingCreature via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) {

Re: Setting field of struct object

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: VS:`C++` ```d struct Person { string name, email; ulong age; } Person a{"n","email",33}; ``` It's not much different in D. ;) ```d import std; struct Person { string name, email; ulong age; } void main() { auto p =

Re: Setting field of struct object

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:21 UTC, Danilo wrote: It's common OOP style in some frameworks. With latest D you can also just use named parameters: ```d import std; struct Person { /*private*/ string name, email; /*private*/ ulong age; } void main() { auto p = Person(

Re: Setting field of struct object

2024-01-22 Thread Joel via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote: On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) {

Re: Setting field of struct object

2024-01-22 Thread zjh via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) { this.email=email; return this; } auto withAge(ulong age) {

Re: Setting field of struct object

2024-01-22 Thread Danilo via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:35:01 UTC, Joel wrote: I've lost interest in the video, looks like horrible syntax (F#). Nonetheless, this usually used with Objects (new class/struct instances), like so: ```d import std; struct Person { string name, email; ulong age; auto

Re: Setting field of struct object

2024-01-22 Thread Joel via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: I've been watching a video (YouTube - "Pipeline-oriented programming - Scott Wlaschin - NDC Porto 2023") with something like the following code. This only sets the first method call, so I'm wanting to know how to make this work, for the

Setting field of struct object

2024-01-22 Thread Joel via Digitalmars-d-learn
I've been watching a video (YouTube - "Pipeline-oriented programming - Scott Wlaschin - NDC Porto 2023") with something like the following code. This only sets the first method call, so I'm wanting to know how to make this work, for the subsequent methods. ```d import std; struct Person {

Re: Building a wasm library, need to override .object._d_newitemT!T

2023-12-24 Thread Etienne via Digitalmars-d-learn
On Sunday, 24 December 2023 at 10:50:41 UTC, Johan wrote: _d_newitemT!T is fairly new, what compiler version are you using? -Johan Nevermind, I managed to get it working but I had to compile without including druntime and phobos and move everything into the library. I'm using ldc

Re: Building a wasm library, need to override .object._d_newitemT!T

2023-12-24 Thread Johan via Digitalmars-d-learn
On Saturday, 23 December 2023 at 20:42:37 UTC, Etienne Cimon wrote: I'm having a problem implementing the `new` keyword, so that I can start importing more libraries with minimal change. However, LDC calls .object._d_newitemT!T from the original druntime - which I need for compile-time

Building a wasm library, need to override .object._d_newitemT!T

2023-12-23 Thread Etienne Cimon via Digitalmars-d-learn
libraries with minimal change. However, LDC calls .object._d_newitemT!T from the original druntime - which I need for compile-time function execution, but my implementation in `module object` doesn't override it in the compiler and the original implementation tries import core.stdc.time which errors

Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
On Tuesday, 19 December 2023 at 14:01:31 UTC, John Kiro wrote: Thanks Adam. I agree, the behavior associated with the initialization here is confusing (compared for example to a similarly-looking code in Java). Also I don't get why an array of characters would be considered as an immutable

Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
Thanks Adam. I agree, the behavior associated with the initialization here is confusing (compared for example to a similarly-looking code in Java). Also I don't get why an array of characters would be considered as an immutable array of characters (that is a **string**). I agree this could be

Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread Adam D Ruppe via Digitalmars-d-learn
as an immutable string literal when it crosses the barrier into run time. Moreover, this would be a static instance of the initial array; the default reference is shared across all objects created (so if you modify intArray then `new` another object, you'll see the modified intArray!). You

SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread John Kiro via Digitalmars-d-learn
Hello there, First time to experiment with DLang, after a long time. I'm getting a weird behavior with an **array of chars**, where I get a segmentation fault upon writing to it (see code and output below). What makes this problem weird it two things: 1) Why there is no problem with the

Re: allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-11 Thread Jerry via Digitalmars-d-learn
The reason high bits are often set is because an address layout is actually 4 indicies into the page table and a page byte offset. So all the way to bit 48 there is index info the cpu uses.

Re: allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-09 Thread mw via Digitalmars-d-learn
On Monday, 9 October 2023 at 05:57:47 UTC, Richard (Rikki) Andrew Cattermole wrote: As far as I'm aware, no cpu that you can get ahold of support more than 48bit of address space at the hardware level. There is simply no reason at this time to support more, due to the fact that nobody has

Re: allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
As far as I'm aware, no cpu that you can get ahold of support more than 48bit of address space at the hardware level. There is simply no reason at this time to support more, due to the fact that nobody has implemented anywhere near that maximum. Also worth noting, the address a block of

allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-08 Thread mw via Digitalmars-d-learn
https://dlang.org/library/core/bitop/bsr.html I'm trying to find out allocated object's address' space: ``` import std.stdio; import core.bitop; void main() { const size_t ONE_G = 1 << 30; char[][128] ptrs; foreach (i, ref ptr; ptrs) { ptr = new char[ONE_G]; if (ptr is null) {

Re: change object class

2023-09-23 Thread Christian Köstlin via Digitalmars-d-learn
``` and methods with ```override``` keyword. ```VTable``` does the same thing as ```__vptr``` ? VTable is your structure .. it does exactly what you want it to do. __vptr is the internal implementation of virtual methods in the dlang object model. Line 20 and 21 in my example initialize the two `VTable`s

Re: change object class

2023-09-23 Thread Christian Köstlin via Digitalmars-d-learn
On 23.09.23 05:25, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! You could model it oop style like this: https://run.dlang.io/is/MJb5Fk This solution might not be to your taste, as it involves

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! You could model it oop style like this: https://run.dlang.io/is/MJb5Fk This solution might not be to your taste, as it involves interfaces, and classes and objects and garbage

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 21:37:37 UTC, Imperatorn wrote: On Friday, 22 September 2023 at 14:03:40 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 12:53:28 UTC, Imperatorn wrote: You're basically just describing polymorphism. I can post an example tomorrow, it's midnight here

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 19:50:17 UTC, Christian Köstlin wrote: another option could be to model your own VTable in a struct like this: https://run.dlang.io/is/3LTjP5 Kind regards, Christian Thank, Christian ! True nice tasty solution with ```VTable```! And further... the project is

Re: change object class

2023-09-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 22 September 2023 at 14:03:40 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 12:53:28 UTC, Imperatorn wrote: On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: [...] What I mean is, why not use other language constructs like mixins or inheritance with

Re: change object class

2023-09-22 Thread Christian Köstlin via Digitalmars-d-learn
On 17.09.23 17:05, Vitaliy Fadeev wrote: Hi! I want to change a method ```Draw``` on a custom object when the ```MouseIn``` event occurs. This is known as "Change State" of the object: ```Init``` -> ```Hovered```. I want to change the state of an object by changing its class, lik

Re: change object class

2023-09-22 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 12:53:28 UTC, Imperatorn wrote: On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 02:51:10 UTC, Vitaliy Fadeev wrote: ... ``` Chip id name Sense() Draw() ``` instance ``` chip = new Chip(); ```

Re: change object class

2023-09-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 02:51:10 UTC, Vitaliy Fadeev wrote: ... ``` Chip id name Sense() Draw() ``` instance ``` chip = new Chip(); ``` compiled to ``` chip __vtbl -> Chip

Re: change object class

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 03:33:08 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 02:51:10 UTC, Vitaliy Fadeev wrote: ... the most correct ``` chip __vtbl ---+ // one of __monitor | id| name | |-> Chip // init |

Re: change object class

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 02:51:10 UTC, Vitaliy Fadeev wrote: ... ``` Chip id name Sense() Draw() ``` instance ``` chip = new Chip(); ``` compiled to ``` chip __vtbl -> Chip __monitor Sense() idDraw()

Re: change object class

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Thursday, 21 September 2023 at 18:19:47 UTC, Imperatorn wrote: On Sunday, 17 September 2023 at 15:05:59 UTC, Vitaliy Fadeev wrote: Hi! I want to change a method ```Draw``` on a custom object when the ```MouseIn``` event occurs. This is known as "Change State" of the objec

Re: change object class

2023-09-21 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 17 September 2023 at 15:05:59 UTC, Vitaliy Fadeev wrote: Hi! I want to change a method ```Draw``` on a custom object when the ```MouseIn``` event occurs. This is known as "Change State" of the object: ```Init``` -> ```Hovered```. [...] Interesting, but why would y

Re: change object class

2023-09-17 Thread Johan via Digitalmars-d-learn
with that constraint of having exact memory layout then it should be ok. No, this is Undefined Behavior and will likely cause you trouble in the future (as in: some very hard to debug bugs may appear). Better to store the state in the object and select the behavior using a switch on the state. -Johan

Re: change object class

2023-09-17 Thread evilrat via Digitalmars-d-learn
(make sure to try it with const objects and optimized release builds before using this everywhere). An even better (at least safer, in theory) option would be to make "View" or handle struct that wraps an object(pointer) and tracks such transformations. Of course to think of it now

Re: change object class

2023-09-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Sunday, 17 September 2023 at 15:05:59 UTC, Vitaliy Fadeev wrote: ... Playground: https://run.dlang.io/is/hjcLCk

change object class

2023-09-17 Thread Vitaliy Fadeev via Digitalmars-d-learn
Hi! I want to change a method ```Draw``` on a custom object when the ```MouseIn``` event occurs. This is known as "Change State" of the object: ```Init``` -> ```Hovered```. I want to change the state of an object by changing its class, like this: ```d this.__vptr = typeid(

Re: class Object with Dependency Injection

2023-06-18 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 18 June 2023 at 16:58:15 UTC, Ali Çehreli wrote: The problem is with the deduced type of 'services'. I don't know the mechanism behind it but the common type of 'truck' and 'ship' are deduced to be Object. Apparently, their interfaces don't take part in that decision. I don't know

Re: class Object with Dependency Injection

2023-06-18 Thread Ali Çehreli via Digitalmars-d-learn
On 6/18/23 07:37, Salih Dincer wrote: >auto truck = new Truck; >auto ship = new Ship; > >auto services = [ truck, ship ]; The problem is with the deduced type of 'services'. I don't know the mechanism behind it but the common type of 'truck' and 'ship' are deduced

class Object with Dependency Injection

2023-06-18 Thread Salih Dincer via Digitalmars-d-learn
Hi, below is an example of DI-dependency injection with 3 versions nested in the code. If you remove the leading // characters, you will not get the "no property `deliver` for `service` of type `object.Object`" error. Because version-2I with interface wants its methods to depend

Re: Given an object, how to call an alias to a member function on it?

2023-05-04 Thread Quirin Schroll via Digitalmars-d-learn
On Wednesday, 3 May 2023 at 11:38:46 UTC, Adam D Ruppe wrote: On Tuesday, 2 May 2023 at 13:57:23 UTC, Steven Schveighoffer wrote: Isn't that what `__traits(child)` is for? https://dlang.org/spec/traits.html#child Yes, `__traits(child, object, method_alias)(args)` is the way to do

Re: Given an object, how to call an alias to a member function on it?

2023-05-03 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 3 May 2023 at 11:26:00 UTC, ag0aep6g wrote: On 03.05.23 13:13, Nick Treleaven wrote: void fun(alias method)(C c) {     void delegate() dg =     dg(); } No, it doesn't. You're not using the alias. You're just accessing `c.method` directly. If the actual method weren't

Re: Given an object, how to call an alias to a member function on it?

2023-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 2 May 2023 at 13:57:23 UTC, Steven Schveighoffer wrote: Isn't that what `__traits(child)` is for? https://dlang.org/spec/traits.html#child Yes, __traits(child, object, method_alias)(args) is the way to do it.

Re: Given an object, how to call an alias to a member function on it?

2023-05-03 Thread ag0aep6g via Digitalmars-d-learn
On 03.05.23 13:13, Nick Treleaven wrote: On Tuesday, 2 May 2023 at 13:06:41 UTC, ag0aep6g wrote: void fun(alias method)(C c) {     void delegate() dg;     dg.funcptr =     dg.ptr = cast(void*) c;     dg(); } This also works: void fun(alias method)(C c) {     void delegate() dg =    

Re: Given an object, how to call an alias to a member function on it?

2023-05-03 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 2 May 2023 at 13:06:41 UTC, ag0aep6g wrote: void fun(alias method)(C c) { void delegate() dg; dg.funcptr = dg.ptr = cast(void*) c; dg(); } This also works: void fun(alias method)(C c) { void delegate() dg = dg(); }

Re: Given an object, how to call an alias to a member function on it?

2023-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/23 8:52 AM, Quirin Schroll wrote: How do I invoke the member function in a reliable way? Given `obj` of the type of the object, I used `mixin("obj.", __traits(identifier, memberFunc), "(params)")`, but that has issues, among probably others, definitely with vis

Re: Given an object, how to call an alias to a member function on it?

2023-05-02 Thread ag0aep6g via Digitalmars-d-learn
On 02.05.23 14:52, Quirin Schroll wrote: How do I invoke the member function in a reliable way? Given `obj` of the type of the object, I used `mixin("obj.", __traits(identifier, memberFunc), "(params)")`, but that has issues, among probably others, definitely with vis

Given an object, how to call an alias to a member function on it?

2023-05-02 Thread Quirin Schroll via Digitalmars-d-learn
How do I invoke the member function in a reliable way? Given `obj` of the type of the object, I used `mixin("obj.", __traits(identifier, memberFunc), "(params)")`, but that has issues, among probably others, definitely with visibility. (The member function alias is a template parameter.)

Re: Assocative array lookup for object

2023-04-12 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 12 April 2023 at 13:09:07 UTC, Ali Çehreli wrote: Not every type is null'able but nullable. ;) So, a design may use the following: https://dlang.org/library/std/typecons/nullable.html I implemented Handler into the Voldermort build, which Walter loved so much. For convenience,

Re: Assocative array lookup for object

2023-04-12 Thread Ali Çehreli via Digitalmars-d-learn
On 4/12/23 04:35, Salih Dincer wrote: > I made a little mistake and I'll fix it before someone rub nose in it :) You asked for it! :) >auto opIndex(string key) { > if(auto ret = key in data) > { >return *ret; > } > return null; >} Not every type is

Re: Assocative array lookup for object

2023-04-12 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 12 April 2023 at 04:57:58 UTC, Salih Dincer wrote: I think you want to do an encapsulation like below. ```d auto opIndex(string key)    => *(key in data); ``` I made a little mistake and I'll fix it before someone rub nose in it :) ```d auto opIndex(string key) {

Re: Assocative array lookup for object

2023-04-11 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 12 April 2023 at 01:16:17 UTC, Chris Katko wrote: Should I be using opEquals? Or something different? The problem with 'alias this' here is I want to wrap access to the insides with getter functions that do various things like logging and error checking. I think you want to do

Re: Assocative array lookup for object

2023-04-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
You want the operator overload opIndex inside your class. https://dlang.org/spec/operatoroverloading.html#array

Assocative array lookup for object

2023-04-11 Thread Chris Katko via Digitalmars-d-learn
fferent? The problem with 'alias this' here is I want to wrap access to the insides with getter functions that do various things like logging and error checking. I mean, if I ruined some encapsulation, I could make a function called "bh" and have the usage: ```D bh("bar"); ``` and have it access a singleton object.

DMD: what's the proper way to get a list of symbols from a Module object?

2023-03-13 Thread ryuukk_ via Digitalmars-d-learn
of the ``StructDeclaration`` created to get a starting point The problem is the field ``members`` from ``Module`` only seems to list ``object`` module when it is trying to search for the symbol There should also be ``Tester`` with should be an ``EnumDeclaration``, why is it not listed? Am i

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-06 Thread bachmeier via Digitalmars-d-learn
On Sunday, 5 February 2023 at 03:38:04 UTC, thebluepandabear wrote: On Sunday, 5 February 2023 at 03:19:43 UTC, bachmeier wrote: Something of a puzzle that it works with Arch, though, but not Ubuntu/Mint. It doesn't sound like Arch has that problem. What problem doesn't Arch have, the

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-05 Thread thebluepandabear via Digitalmars-d-learn
Thanks. update: just set up a Manjaro vm and it seems to work, I guess I'll have no choice but to switch to Manjaro then if I want to use sfml

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread thebluepandabear via Digitalmars-d-learn
On Sunday, 5 February 2023 at 03:19:43 UTC, bachmeier wrote: On Saturday, 4 February 2023 at 23:51:17 UTC, thebluepandabear wrote: "Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] source/app.d:19 void

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread bachmeier via Digitalmars-d-learn
On Saturday, 4 February 2023 at 23:51:17 UTC, thebluepandabear wrote: "Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] source/app.d:19 void app.loadDyn() [0x55d86edd1931] source/app.d:24 _Dmain [0x55d86edd1954]

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread thebluepandabear via Digitalmars-d-learn
"Error: Missing Symbol, Message: sfText_getLineSpacing", "Error: Missing Symbol, Message: sfText_getLineSpacing"] source/app.d:19 void app.loadDyn() [0x55d86edd1931] source/app.d:24 _Dmain [0x55d86edd1954] ``` Oh yeah, that's another bug I had. You would need to downgrade the

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-04 Thread bachmeier via Digitalmars-d-learn
On Saturday, 4 February 2023 at 05:29:43 UTC, thebluepandabear wrote: I have tested on arch linux and everything works fine, i'll try to setup a linux mint / ubuntu VM tomorrow Thanks. It seems like an issue with my system then. I've been stuck on it for a week or so, but haven't been able

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
I have tested on arch linux and everything works fine, i'll try to setup a linux mint / ubuntu VM tomorrow Thanks. It seems like an issue with my system then. I've been stuck on it for a week or so, but haven't been able to find the root cause of the issue.

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 4 February 2023 at 04:42:04 UTC, ryuukk_ wrote: Are you sure you have installed the version 2.5 in your system? Can you check in y our library folder if it's there? Nvm, i saw your github issue, looks like you have the proper version I have tested on arch linux and everything

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread ryuukk_ via Digitalmars-d-learn
Are you sure you have installed the version 2.5 in your system? Can you check in y our library folder if it's there?

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
Could someone (that uses Linux) perhaps try and emulate my bug to see if it's an issue with the bindings or on my system? That would be greatly appreciated! Steps: 1. Open up the terminal and type in `sudo apt-get install libcsfml-dev` 2. Create a new D project and add the following to

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
bsfml-system.so.2.5: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2.0, Message: libcsfml-system.so.2.0: canno

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread bachmeier via Digitalmars-d-learn
install of CSFML and I am getting this errors when running my csfml D bindings program: ``` object.Exception@source/app.d(38): Fatal error(s) encountered whilst calling `loadSFML()` function: ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: cannot open shared object file: No such

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
bindings program: ``` object.Exception@source/app.d(38): Fatal error(s) encountered whilst calling `loadSFML()` function: ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2, Me

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
) encountered whilst calling `loadSFML()` function: ["Error: libcsfml-system.so, Message: libsfml-system.so.2.5: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: cannot open shared object file: No such fi

Re: SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread bachmeier via Digitalmars-d-learn
Error: libcsfml-system.so, Message: libsfml-system.so.2.5: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2.0, Message

SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

2023-02-03 Thread thebluepandabear via Digitalmars-d-learn
open shared object file: No such file or directory", "Error: libcsfml-system.so.2, Message: libcsfml-system.so.2: cannot open shared object file: No such file or directory", "Error: libcsfml-system.so.2.0, Message: libcsfml-system.so.2.0: cannot open shared object file: No such fi

Re: Address of a class object

2023-01-31 Thread Paul via Digitalmars-d-learn
rce the class objects to be on the stack as well: scope MyClassVar1 = new MyClass(); I replaced 'auto' with 'scope'. Ali I was tinkering with this use of 'scope' and the math for pointer location, object size, and alignment started working out.

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-26 Thread thebluepandabear via Digitalmars-d-learn
On Thursday, 26 January 2023 at 11:46:07 UTC, matheus wrote: On Tuesday, 24 January 2023 at 03:42:34 UTC, thebluepandabear wrote: ... if not please tell me and I will remove this... How you would do that? Matheus. The forums don't have a delete feature. I am used to most forums having a

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-26 Thread matheus via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 03:42:34 UTC, thebluepandabear wrote: ... if not please tell me and I will remove this... How you would do that? Matheus.

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-24 Thread thebluepandabear via Digitalmars-d-learn
The example shows calls to `update()` in the setters and in the constructor. The D method for binding this looks like `void sfShape_update(sfShape* shape);`. Ur a legend bro... It fixed it... Calling this in the `Rectangle` constructor: ```D class RectangleShape : Shape { this(Vector2f

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-24 Thread beerboy.22 via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 08:18:53 UTC, thebluepandabear wrote: On Tuesday, 24 January 2023 at 06:32:35 UTC, Christian Köstlin wrote: On 24.01.23 04:59, thebluepandabear wrote: Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone

Re: Library object name collision

2023-01-24 Thread frame via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 09:54:01 UTC, frame wrote: Thanks! it works well with the `-op` switch, didn't know I can do with libraries. Only drawback is that every path now stored as absolute path - any way to store only a relative one? Ah never mind, it seems only to do this with phobos

Re: Library object name collision

2023-01-24 Thread frame via Digitalmars-d-learn
a library - if any symbol is missing it will be a problem ;-) Now wrt. LNK4255, I'm not sure why its doing this. You haven't shown how you're building. But if you're doing it manually you may want to try: -od= write object & library files to directory -of=name output file to file

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-24 Thread thebluepandabear via Digitalmars-d-learn
On Tuesday, 24 January 2023 at 06:32:35 UTC, Christian Köstlin wrote: On 24.01.23 04:59, thebluepandabear wrote: Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone to help me because of that... but any sort of assistance or leads

Re: Library object name collision

2023-01-24 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
. But if you're doing it manually you may want to try: -od= write object & library files to directory -of=name output file to filename -op preserve source path for output files

Library object name collision

2023-01-24 Thread frame via Digitalmars-d-learn
When creating a linker library under Windows and having module a/b/foo.d but also d/c/foo.d the linker afterwards is bailing out: .lib(foo.obj) : warning LNK4255: library contain multiple objects of the same name; linking object as if no debug info And when I did inspect the library

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-23 Thread Christian Köstlin via Digitalmars-d-learn
On 24.01.23 04:59, thebluepandabear wrote: Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone to help me because of that... but any sort of assistance or leads would be greatly... greatly apprecaited... I do not know anything about

Re: Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-23 Thread thebluepandabear via Digitalmars-d-learn
Regards, thebluepandabear Btw I understand this question is extremely complex, don't want to pressure anyone to help me because of that... but any sort of assistance or leads would be greatly... greatly apprecaited...

Need some technical help an object oriented wrapper I am creating for bindbc.sfml

2023-01-23 Thread thebluepandabear via Digitalmars-d-learn
Hello everyone , hope everyone is having a good day. Hopefully I am allowed to ask technical questions here, if not please tell me and I will remove this. I am trying to create object oriented wrappers around `bindbc.sfml`, this is because I don't like the C-style syntax of CSFML. The C

  1   2   3   4   5   6   7   8   9   10   >