Re: dmd as a library

2022-11-07 Thread vushu via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 06:35:43 UTC, Mike Parker wrote:

On Tuesday, 8 November 2022 at 06:21:11 UTC, vushu wrote:



So I do feel, that I am in need for some learning materials or 
guidance.


You might find Lucian Danescu's DConf '22 presentation helpful:

https://youtu.be/JYkb3PjIn4c


thanks :)


Re: dmd as a library

2022-11-07 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 06:21:11 UTC, vushu wrote:



So I do feel, that I am in need for some learning materials or 
guidance.


You might find Lucian Danescu's DConf '22 presentation helpful:

https://youtu.be/JYkb3PjIn4c



Re: dmd as a library

2022-11-07 Thread vushu via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 02:55:34 UTC, max haughton wrote:

On Tuesday, 8 November 2022 at 00:05:18 UTC, vushu wrote:

Any where to find learning material for using dmd as a library?

thanks.


What do you want to do with it.


Im trying to understand the idiomatic way of using visitors, 
since I am interested in making some tooling. I tried to 
understand the code by looking into some bits and bites within 
dmd.


example:

```
auto someFunc() {
  return "hello";
}


```
I parsed it' using Parser!ASTCodegen
created a class which inherits SemanticTimeTransitiveVisitor and 
parsed it into.


I override visit(ASTCodegen.FuncDeclaration fd)

Now the question is:
If I want to deduce someFunc's return type I look at it's 
fd.type.nextOf value

in this case it's null since it's return type is set to auto.

what would be the right way of deducing that it's return type 
would be fact a string?


Should I just keep traversing and that way deduce the return 
type? or should I use other methods?

I see that the ASTCodegen.FuncDeclaration has a function named
```
functionSemantic();
```

which I thought I should use, but failed to.

So I do feel, that I am in need for some learning materials or 
guidance.







Re: dmd as a library

2022-11-07 Thread vushu via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 03:11:15 UTC, Tejas wrote:

On Tuesday, 8 November 2022 at 00:05:18 UTC, vushu wrote:

Any where to find learning material for using dmd as a library?

thanks.


https://github.com/Superbelko/dmdlib-notes

This is the only resource I know of


Ah thanks that's nice to have some examples.


Re: dmd as a library

2022-11-07 Thread Tejas via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 00:05:18 UTC, vushu wrote:

Any where to find learning material for using dmd as a library?

thanks.


https://github.com/Superbelko/dmdlib-notes

This is the only resource I know of


Re: dmd as a library

2022-11-07 Thread max haughton via Digitalmars-d-learn

On Tuesday, 8 November 2022 at 00:05:18 UTC, vushu wrote:

Any where to find learning material for using dmd as a library?

thanks.


What do you want to do with it.


dmd as a library

2022-11-07 Thread vushu via Digitalmars-d-learn

Any where to find learning material for using dmd as a library?

thanks.


RDBMS internal operation

2022-11-07 Thread Soham Mukherjee via Digitalmars-d-learn
I have a table with ten columns and would want to choose column 1 
and column 9 from it. How many columns should be selected 
internally in RDBMS? Also, I'm not an expert in 3-Level 
Architecture of DBMS to understand [data 
independence](https://www.scaler.com/topics/data-independence-in-dbms/) but I've read several resources.


I'm asking about Oracle, but I'm also learning hbase, so I'm a 
little confused. I'm not a database guy; I'm a java guy who is 
now into Hadoop and hasn't touched a database in over a year. 
There are other reasons for this, but we will not go into them. I 
am very aware of what I am doing. I'm a newbie MR coder, but I'm 
doing okay with my part of the code.


Re: Drawing a line code

2022-11-07 Thread rikki cattermole via Digitalmars-d-learn

On 07/11/2022 10:29 PM, Joel wrote:

Ok, this is working:


I'm glad to hear it!

Pathing algorithms can be quite fun to mess around with.


Re: Drawing a line code

2022-11-07 Thread Joel via Digitalmars-d-learn
On Sunday, 6 November 2022 at 17:15:03 UTC, rikki cattermole 
wrote:

On 07/11/2022 5:48 AM, Joel wrote:
The algorithm is too hard for me to work out and dg2d doesn't 
help either. I want my code fixed up so that works from any 
two points.


Its not as complex as that page initially looks.

```
plotLine(x0, y0, x1, y1)
dx = abs(x1 - x0)
sx = x0 < x1 ? 1 : -1
dy = -abs(y1 - y0)
sy = y0 < y1 ? 1 : -1
error = dx + dy

while true
plot(x0, y0)
if x0 == x1 && y0 == y1 break
e2 = 2 * error
if e2 >= dy
if x0 == x1 break
error = error + dy
x0 = x0 + sx
end if
if e2 <= dx
if y0 == y1 break
error = error + dx
y0 = y0 + sy
end if
end while
```

That is the pseudo code you want.

Its just a matter of typing the variables to something like int.

I can recommend:

https://www.amazon.com/Computer-Graphics-Principles-Practice-3rd/dp/0321399528

and

https://www.amazon.com/Computer-Graphics-C-Version-2nd/dp/0135309247

(The updated version should be fine too)

If you wish to understand it.


Ok, this is working:

```d
void drawLine(Dot s, Dot e) {
Dot d=s;
int x0=s.pos.Xi, y0=s.pos.Yi;
int x1=e.pos.Xi, y1=e.pos.Yi;

int dx = abs(x1 - x0);
int sx = x0 < x1 ? 1 : -1;
int dy = -abs(y1 - y0);
int sy = y0 < y1 ? 1 : -1;
int error = dx + dy;

while(true) {
d.setPos(Point(x0,y0));
drawDot(d);
if (x0 == x1 && y0 == y1)
break;
int e2 = 2 * error;
if (e2 >= dy) {
if (x0 == x1) break;
error = error + dy;
x0 = x0 + sx;
}
if (e2 <= dx) {
if (y0 == y1) break;
error = error + dx;
y0 = y0 + sy;
}
}
}
//[...]
void mouseDraw(ref Dot d) {
int lmx=g_mx, lmy=g_my, mx,my;
int mstate = SDL_GetMouseState(,);
if (mstate & SDL_BUTTON_LEFT) {
if (mx>0 && my>0) {
g_mx=mx/3;
g_my=my/3;
auto s=d, e=d;
s.setPos(Point(lmx, lmy));
e.setPos(Point(g_mx, g_my));
//mixin(tce("lmx lmy g_mx g_my".split));
g_df.drawLine(s,e);
}
} else {
if (mx>0 && my>0) {
g_mx=mx/3;
g_my=my/3;
}
}
}
```