Struct multiple inheritance - another solution

2015-11-27 Thread Basile.B via Digitalmars-d
I've read latest months several related topics (multiple alias 
this, super struct, etc). But the problem is that these solutions 
still differ from a real interface and they don't solve the 
problem of casting the interface at run-time (with arbitrary 
parameters).


I'll expose another approach.

Let's take the following declarations:

```
interface I {uint fun(uint a);}

struct S {uint fun(uint a);}
```

The problem will all know is that a structure doesn't allow 
multiple inheritance. So even if I and S members are compatible 
there is no way to extract an I from a S. The layout of a struct 
is different the one from a class: no virtual table. No really, a 
struct cannot have a virtual table.


But why the hell should it have one ? What's needed is just to 
return an I.
Since I really want an interface, the only way to return an I for 
S is that the stuff has to be class.


This is how it would look:

```
class SI : I
{
void patch(void* instance)
{
//set fun_DG.ptr to instance, a pointer to a S.
//set fun_DG.funcptr to address in memory of S.fun
}

uint delegate(uint) fun_DG;
uint fun(uint a)
{
return fun_DG(a);
}
}
```

Ok, but how this class has to be declared ? Should it be written 
for each struct and for each interface I'd like to extract from a 
struct ?


Fortunately no, D has metaprogramming features so we can imagine 
a simple function template that returns a string to mix, this 
string representing the class that implements an interface for a 
struct containing the methods that match to the interface.


And this works:

http://dpaste.dzfl.pl/50a8a7aa1267

And this is almost usable, except for the additional

```
void patch(void* instance);
```

that has to be added to each interface.


perfect hash map in visual D

2016-04-15 Thread Basile.B via Digitalmars-d

https://github.com/BBasile/IsItThere
https://issues.dlang.org/show_bug.cgi?id=15901

when you want bro ;)


Re: My statements related to terminating my SAoC relationship

2018-10-18 Thread Basile.B via Digitalmars-d

On Monday, 15 October 2018 at 21:26:52 UTC, solidstate1991 wrote:
I have done two mistakes: I underestimated the scope of the 
project and overestimated my capabilities. This caused a chain 
reaction, which in turn made the first milestone unreachable.


At the same time, my sleep disorder became even worse. I 
started to sleep 10-12 hours a day while spending around 4-6 
hours in bed just to trying to fall asleep, and since I had to 
do some housekeeping work it cut the planned 8 hours per day 
work down to 4-6 at most. I have taped off all the status 
indicator LEDs on my electronics, I asked my brother and father 
to refrain from loud TV watching at night, all for nothing. 
Caffeine intake don't worsen my ability of sleep. I do get 
tired, but somehow still don't feel myself sleepy. Tried to 
tell my doctors, but they just told me to do the stuff I've 
already done plus to refrain from using computers as much as 
possible and instead look for a job that don't require them. 
However, thanks to I had to use a "desk" with no leg room, my 
spine is all busted now, barely able to manage to lift 20kg 
without screaming in agony.


I try to resume my work on improving mago, but on a much 
smaller scale and lower priority since I have to spend time 
finding a job, which is a very hard thing in this fascist 
country called Hungary, while also not supporting said fascist 
regime. While the state propaganda says there's a big shortage 
on workforce (to the point that supposedly humanitarians are 
being reeducated for Java developers), I also see a lot of 
people being rejected with bogus claims which tells me that 
there's something fishy, and hearing some controversies of 
political opponents' families suddenly losing their jobs says 
me that they're persecuting their political opponents at any 
means possible.


Losing the funds put me in danger of homelessness, since I 
haven't been able to pay my father for rent and food for years, 
not to mention my PC is on its deathbed with its dried up CPU 
VRM capacitors, and USB and LAN ports fried after a 
thunderstorm and our previous ISP being skeptical with 
overvoltage protection (we got a direct hit into the antenna, 
which blew up his equipment, and fried by router, the LAN port, 
several USB ports, a cheap membrane keyboard, and a Logitech 
mouse I just have repaired).


I think I'll take a few days of doing other stuff, since my 
sleeping disorder sabotaged my free time too and now I have to 
find a job, (preferably internship) to calm down a bit.


Try to complete some stuff. Even if it's not the main goal. 
**complete** is the important thing.


Best of lucks.